submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s920562669
p00255
C++
#include<cstdio> #include<algorithm> using namespace std; int main(){ long long int n; while(scanf("%d",&n),n){ long long int p[10000]={0}; long long int x = 0; long long int y = 0; long long int ans = 0; for(long long int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); long long int j[10000]={0}; for(long long int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; long long int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(long long int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%d\n",ans); } return 0; } #include<cstdio> #include<algorithm> using namespace std; int main(){ long long int n; while(scanf("%d",&n),n){ long long int p[10000]={0}; long long int x = 0; long long int y = 0; long long int ans = 0; for(long long int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); long long int j[10000]={0}; for(long long int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; long long int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(long long int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%d\n",ans); } return 0; }
a.cc:48:5: error: redefinition of 'int main()' 48 | int main(){ | ^~~~ a.cc:4:5: note: 'int main()' previously defined here 4 | int main(){ | ^~~~
s604945917
p00255
C++
#include<cstdio> #include<algorithm> using namespace std; int main(){ int n; while(scanf("%d",&n),n){ int p[10000]={0}; int x = 0; int y = 0; int ans = 0; for(int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); int j[10000]={0}; for(int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%d\n",ans); } return 0; } #include<cstdio> #include<algorithm> using namespace std; int main(){ int n; while(scanf("%d",&n),n){ int p[10000]={0}; int x = 0; int y = 0; int ans = 0; for(int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); int j[10000]={0}; for(int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%d\n",ans); } return 0; } #include<cstdio> #include<algorithm> using namespace std; int main(){ int n; while(scanf("%d",&n),n){ int p[10000]={0}; int x = 0; int y = 0; int ans = 0; for(int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); int j[10000]={0}; for(int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%d\n",ans); } return 0; } #include<cstdio> #include<algorithm> using namespace std; int main(){ int n; while(scanf("%d",&n),n){ int p[10000]={0}; int x = 0; int y = 0; int ans = 0; for(int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); int j[10000]={0}; for(int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%d\n",ans); } return 0; }
a.cc:48:5: error: redefinition of 'int main()' 48 | int main(){ | ^~~~ a.cc:4:5: note: 'int main()' previously defined here 4 | int main(){ | ^~~~ a.cc:92:5: error: redefinition of 'int main()' 92 | int main(){ | ^~~~ a.cc:4:5: note: 'int main()' previously defined here 4 | int main(){ | ^~~~ a.cc:136:5: error: redefinition of 'int main()' 136 | int main(){ | ^~~~ a.cc:4:5: note: 'int main()' previously defined here 4 | int main(){ | ^~~~
s179732517
p00255
C++
#include<cstdio> #include<vector> #include<iostream> #include<algorithm> using namespace std; int main(){ long long n,a; while(cin >> n,n){ long long int p = 0; vector<long long> J(n-1); for(int i = 0; i < n; i++){ cin >> a; p += a; } int ans = p * n; for(int i = 1; i < n; i++){ cin >> J[i-1]; } sort(J.begin(),J.end()); for(int i = n - 1; i >= 1; i--){ p += J[i-1]; ans = max(ans,p * i); } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:22:34: error: no matching function for call to 'max(int&, long long int)' 22 | ans = max(ans,p * i); | ~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:22:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 22 | ans = max(ans,p * i); | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:22:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 22 | ans = max(ans,p * i); | ~~~^~~~~~~~~~~
s414953280
p00255
C++
#include<iostream> using namespace std; int n,a,c,honsu,tp,tj,mx; int p[65000]; int j[1001]; void syokika(){ tp=0; tj=0; mx=0; c=0; } int main(){ while(true){ cin>>n; if(n==0)break; syokika(); for(int i=0;i<n;i++){ cin>>p[i]; tp+=p[i]; } for(int i=0;i<n-1;i++){ cin>>j[i]; tj+=j[i]; } sort(j,j+n-1); for(int i=0;i<n-1;i++){ cout<<j[i]<<endl; } for(int i=1;i<=n;i++){ a=i*(tp+tj); if(mx<a)mx=a; tj-=j[c]; c++; } cout<<mx<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:5: error: 'sort' was not declared in this scope; did you mean 'short'? 25 | sort(j,j+n-1); | ^~~~ | short
s442286957
p00255
C++
#include<iostream> using namespace std; int n,a,c,honsu,tp,tj,mx; int p[65000]; int j[1001]; void syokika(){ tp=0; tj=0; mx=0; c=0; } int main(){ while(true){ cin>>n; if(n==0)break; syokika(); for(int i=0;i<n;i++){ cin>>p[i]; tp+=p[i]; } for(int i=0;i<n-1;i++){ cin>>j[i]; tj+=j[i]; } sort(j,j+n-1); for(int i=0;i<n-1;i++){ cout<<j[i]<<endl; } for(int i=1;i<=n;i++){ a=i*(tp+tj); if(mx<a)mx=a; tj-=j[c]; c++; } cout<<mx<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:5: error: 'sort' was not declared in this scope; did you mean 'short'? 25 | sort(j,j+n-1); | ^~~~ | short
s732155210
p00255
C++
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; int main(void) { int f1, n, p, cnt, *J; unsigned int k, sum, max; while( scanf("%d", &n) && n > 0) { J = new int [n - 1]; sum = 0; cnt = 1; for(f1 = 0; f1 < n; f1++) { scanf("%d", &p); sum += p; } for(f1 = 0; f1 < n-1; f1++) { scanf("%d", &p); sum += p; J[f1] = p; J.push_back(p); } max = sum; sort(J, J + (n - 1)); //平均O(nlogn) for(f1 = 0; f1 < n - 1; f1++) { sum -= J[f1]; k = ++cnt * sum; if(k > max) max = k; t++; } printf("%u\n", max); } return 0; }
a.cc: In function 'int main()': a.cc:26:27: error: request for member 'push_back' in 'J', which is of non-class type 'int*' 26 | J.push_back(p); | ^~~~~~~~~ a.cc:38:25: error: 't' was not declared in this scope 38 | t++; | ^
s341292214
p00255
C++
#include<iostream> #include<algorithm> using namespace std; static const int MAX = 65000; typedef long long llong; main(){ llong n, totalp; llong P[MAX], J[MAX]; int tcase = 0; while(1){ cin >> n; if ( n == 0 ) break; tcase++; totalp = 0; for ( int i = 0; i < n; i++ ) { cin >> P[i]; totalp += P[i]; } for ( int i = 0; i < n-1; i++ ) { cin >> J[i]; } llong maxv = 0; sort(J, J+(n-1)); reverse(J, J+(n-1)); for ( llong j = 0, t = n, totalj = 0; t >= 1; t--, j++ ){ llong v = t*(totalj + totalp); totalj += J[j]; maxv = max(v, maxv); } cout << maxv << endl; } assert( tcase <= 100 ); }
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:36:3: error: 'assert' was not declared in this scope 36 | assert( tcase <= 100 ); | ^~~~~~ a.cc:3:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 2 | #include<algorithm> +++ |+#include <cassert> 3 | using namespace std;
s943182198
p00255
C++
#include<iostream> #include<algorithm> using namespace std; static const int MAX = 65000; typedef long long llong; main(){ llong n, totalp; llong P[MAX], J[MAX]; int tcase = 0; while(1){ cin >> n; if ( n == 0 ) break; tcase++; totalp = 0; for ( int i = 0; i < n; i++ ) { cin >> P[i]; totalp += P[i]; } for ( int i = 0; i < n-1; i++ ) { cin >> J[i]; } llong maxv = 0; sort(J, J+(n-1)); reverse(J, J+(n-1)); totalj = 0; for ( llong j = 0, t = n; t >= 1; t--, j++ ){ llong v = t*(totalj + totalp); totalj += J[j]; maxv = max(v, maxv); } cout << maxv << endl; } }
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:27:5: error: 'totalj' was not declared in this scope; did you mean 'totalp'? 27 | totalj = 0; | ^~~~~~ | totalp
s296523116
p00255
C++
#include <iostream> #include <algorithm> int main() { std::vector<int> data; int ddata; int num; int maxvul; int count,length; std::cin>>num; while(num){ data.resize(num-1); maxvul=0; for(int i=0;i<num;i++){ std::cin>>ddata; maxvul+=ddata; } ddata=maxvul; maxvul*=num; for(int i=0;i<num-1;i++){ std::cin>>data[i]; } std::sort(data.begin(),data.end(),std::greater<int>()); for(int i=0;i<data.size();i++){ ddata+=data[i]; if(maxvul<ddata*(num-i-1)){ maxvul=ddata*(num-i-1); } } std::cout<<maxvul<<std::endl; std::cin>>num; } }
a.cc: In function 'int main()': a.cc:6:10: error: 'vector' is not a member of 'std' 6 | std::vector<int> data; | ^~~~~~ a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 2 | #include <algorithm> +++ |+#include <vector> 3 | a.cc:6:17: error: expected primary-expression before 'int' 6 | std::vector<int> data; | ^~~ a.cc:13:17: error: 'data' was not declared in this scope; did you mean 'std::data'? 13 | data.resize(num-1); | ^~~~ | std::data In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: 'std::data' declared here 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~
s787060054
p00255
C++
#include <iostream> #include <algorithm> int main() { std::vector<int> data; int ddata; int num; int maxvul; int count,length; std::cin>>num; while(num){ data.resize(num-1); maxvul=0; for(int i=0;i<num;i++){ std::cin>>ddata; maxvul+=ddata; } ddata=maxvul; maxvul*=num; for(int i=0;i<num-1;i++){ std::cin>>data[i]; } std::sort(data.begin(),data.end(),std::greater<int>()); for(int i=0;i<data.size();i++){ ddata+=data[i]; if(maxvul<ddata*(num-i-1)){ maxvul=ddata*(num-i-1); } } std::cout<<maxvul<<std::endl; std::cin>>num; } }
a.cc: In function 'int main()': a.cc:6:10: error: 'vector' is not a member of 'std' 6 | std::vector<int> data; | ^~~~~~ a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 2 | #include <algorithm> +++ |+#include <vector> 3 | a.cc:6:17: error: expected primary-expression before 'int' 6 | std::vector<int> data; | ^~~ a.cc:13:17: error: 'data' was not declared in this scope; did you mean 'std::data'? 13 | data.resize(num-1); | ^~~~ | std::data In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: 'std::data' declared here 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~
s199904623
p00255
C++
#include <vector> #include <map> #include <set> #include <stack> #include <queue> #include <algorithm> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <string> #include <cstring> #include <complex> #include <ctime> #include <cstdlib> using namespace std; inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;} template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();} typedef long long ll; int main() { int n; while(cin >> n, n) { vector<int> J; int mx = 0, a; int pipe = 0; for(int i = 0; i < n; i++) { pipe += a; } for(int i = 0; i < n-1; i++) { cin >> a; J.push_back(a); } sort(J.begin(), J.end(), greater<int>()); for(int i = 0; i <= J.size(); i++) { int sum = pipe; for(int j = 0; j < i; j++) { sum += J[j]; } sum *= (P.size() - i); mx = max(mx, sum); } cout << mx << endl; } }
a.cc: In function 'int main()': a.cc:53:33: error: 'P' was not declared in this scope 53 | sum *= (P.size() - i); | ^
s736511900
p00256
C
#include<iostream> #include<string.h> #include<stdlib.h> #include<time.h> #include<stdio.h> using namespace std; struct tm T; struct tm *a; int maya[5]={144000,7200,360,20,1}; int sugi[5]={1,20,20,18,20}; int main(){ if(sizeof(time_t)!=8)exit(1); time_t tt,kin,ans,s=1356015600; char koyomi[50]; int i,j; int n[5]={0}; while(1){ cin>>koyomi; if(koyomi[0]=='#'){ break; } memset(n,0,sizeof(n)); j=0; cout<<strlen(koyomi)<<endl; for(i=0;i<strlen(koyomi);i++){ if(koyomi[i]=='.'){ j++; } } cout<<j<<endl; if(j==2){ sscanf(koyomi,"%d.%d.%d",&n[0],&n[1],&n[2]); T.tm_year=n[0]-1900; T.tm_mon=n[1]-1; T.tm_mday=n[2]; tt=(mktime(&T)-s)/86400%1872000; //cout<<tt<<endl; printf("%d.%d.%d.%d.%d\n",tt/144000,tt/7200%20,tt/360%20,tt/20%18,tt%20); } else{ sscanf(koyomi,"%d.%d.%d.%d.%d",&n[0],&n[1],&n[2],&n[3],&n[4]); tt=(n[0]*144000+n[1]*7200+n[2]*360+n[3]*20+n[4])*86400+s; a=localtime(&tt); printf("%d.%d.%d\n",a->tm_year+1900,a->tm_mon+1,a->tm_mday); } } return 0; exit(0); }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s171183221
p00256
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; ll gettime64(ll y,ll m,ll d){ struct tm poi; poi.tm_year = y-1900; poi.tm_mon = m-1; poi.tm_mday = d; poi.tm_hour = poi.tm_min = poi.tm_sec = 0; poi.tm_isdst = -1; return _mktime64(&poi); } int toint(string s){ return atoi(s.c_str()); } vi split(string base, char spl){ vi result; string::size_type pos = 0; string::size_type bef = 0; base += spl; while( (pos = base.find_first_of(spl,bef)) != string::npos ){ result.push_back(toint(base.substr(bef,pos-bef))); bef = pos+1; } return result; } #define AD 146097 #define MAYA 1872000 int main(){ while(true){ string s; cin>>s; if(s=="#")break; vi input = split(s,'.'); if(input.size()==3){ // yyyy.mm.dd ll y = input[0]; ll m = input[1]; ll d = input[2]; ll year_down = (y - 2013)/400; y -= year_down*400; ll birth = gettime64(y,m,d); ll origin = gettime64(2012,12,21); ll sub = (birth-origin)/24/60/60; sub += year_down*AD%MAYA; sub %= MAYA; int ki = sub%20; sub/=20; int w = sub%18; sub/=18; int t = sub%20; sub/=20; int ka = sub%20; int b = sub/20; printf("%d.%d.%d.%d.%d\n",b,ka,t,w,ki); }else{ // b.ka.t.w.ki ll val = 0; val += input[0]; val *= 20; val += input[1]; val *= 20; val += input[2]; val *= 18; val += input[3]; val *= 20; val += input[4]; ll year_add = val/AD; val %= AD; val *= 24*60*60; val += gettime64(2012,12,21); struct tm *birth = _gmtime64((__time64_t*)&val); int year = birth->tm_year + 1900 + year_add*400; int month = birth->tm_mon + 1; int day = birth->tm_mday + 1; printf("%d.%d.%d\n",year,month,day); } } return 0; }
a.cc: In function 'll gettime64(ll, ll, ll)': a.cc:15:10: error: '_mktime64' was not declared in this scope; did you mean 'mktime'? 15 | return _mktime64(&poi); | ^~~~~~~~~ | mktime a.cc: In function 'int main()': a.cc:73:37: error: '__time64_t' was not declared in this scope; did you mean '__timer_t'? 73 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^~~~~~~~~~ | __timer_t a.cc:73:48: error: expected primary-expression before ')' token 73 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^ a.cc:73:26: error: '_gmtime64' was not declared in this scope; did you mean 'gmtime_r'? 73 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^~~~~~~~~ | gmtime_r
s116730226
p00256
C++
#include <bits/stdc++.h> #include <time.h> using namespace std; typedef long long ll; typedef vector<int> vi; ll gettime64(ll y,ll m,ll d){ struct tm poi; poi.tm_year = y-1900; poi.tm_mon = m-1; poi.tm_mday = d; poi.tm_hour = poi.tm_min = poi.tm_sec = 0; poi.tm_isdst = -1; return _mktime64(&poi); } int toint(string s){ return atoi(s.c_str()); } vi split(string base, char spl){ vi result; string::size_type pos = 0; string::size_type bef = 0; base += spl; while( (pos = base.find_first_of(spl,bef)) != string::npos ){ result.push_back(toint(base.substr(bef,pos-bef))); bef = pos+1; } return result; } #define AD 146097 #define MAYA 1872000 int main(){ while(true){ string s; cin>>s; if(s=="#")break; vi input = split(s,'.'); if(input.size()==3){ // yyyy.mm.dd ll y = input[0]; ll m = input[1]; ll d = input[2]; ll year_down = (y - 2013)/400; y -= year_down*400; ll birth = gettime64(y,m,d); ll origin = gettime64(2012,12,21); ll sub = (birth-origin)/24/60/60; sub += year_down*AD%MAYA; sub %= MAYA; int ki = sub%20; sub/=20; int w = sub%18; sub/=18; int t = sub%20; sub/=20; int ka = sub%20; int b = sub/20; printf("%d.%d.%d.%d.%d\n",b,ka,t,w,ki); }else{ // b.ka.t.w.ki ll val = 0; val += input[0]; val *= 20; val += input[1]; val *= 20; val += input[2]; val *= 18; val += input[3]; val *= 20; val += input[4]; ll year_add = val/AD; val %= AD; val *= 24*60*60; val += gettime64(2012,12,21); struct tm *birth = _gmtime64((__time64_t*)&val); int year = birth->tm_year + 1900 + year_add*400; int month = birth->tm_mon + 1; int day = birth->tm_mday + 1; printf("%d.%d.%d\n",year,month,day); } } return 0; }
a.cc: In function 'll gettime64(ll, ll, ll)': a.cc:16:10: error: '_mktime64' was not declared in this scope; did you mean 'mktime'? 16 | return _mktime64(&poi); | ^~~~~~~~~ | mktime a.cc: In function 'int main()': a.cc:74:37: error: '__time64_t' was not declared in this scope; did you mean '__timer_t'? 74 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^~~~~~~~~~ | __timer_t a.cc:74:48: error: expected primary-expression before ')' token 74 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^ a.cc:74:26: error: '_gmtime64' was not declared in this scope; did you mean 'gmtime_r'? 74 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^~~~~~~~~ | gmtime_r
s651864875
p00256
C++
#include <bits/stdc++.h> #include <time.h> using namespace std; typedef long long ll; typedef vector<int> vi; ll gettime64(ll y,ll m,ll d){ struct tm poi; poi.tm_year = y-1900; poi.tm_mon = m-1; poi.tm_mday = d; poi.tm_hour = poi.tm_min = poi.tm_sec = 0; poi.tm_isdst = -1; return _mktime64(&poi); } int toint(string s){ return atoi(s.c_str()); } vi split(string base, char spl){ vi result; string::size_type pos = 0; string::size_type bef = 0; base += spl; while( (pos = base.find_first_of(spl,bef)) != string::npos ){ result.push_back(toint(base.substr(bef,pos-bef))); bef = pos+1; } return result; } #define AD 146097 #define MAYA 1872000 int main(){ while(true){ string s; cin>>s; if(s=="#")break; vi input = split(s,'.'); if(input.size()==3){ // yyyy.mm.dd ll y = input[0]; ll m = input[1]; ll d = input[2]; ll year_down = (y - 2013)/400; y -= year_down*400; ll birth = gettime64(y,m,d); ll origin = gettime64(2012,12,21); ll sub = (birth-origin)/24/60/60; sub += year_down*AD%MAYA; sub %= MAYA; int ki = sub%20; sub/=20; int w = sub%18; sub/=18; int t = sub%20; sub/=20; int ka = sub%20; int b = sub/20; printf("%d.%d.%d.%d.%d\n",b,ka,t,w,ki); }else{ // b.ka.t.w.ki ll val = 0; val += input[0]; val *= 20; val += input[1]; val *= 20; val += input[2]; val *= 18; val += input[3]; val *= 20; val += input[4]; ll year_add = val/AD; val %= AD; val *= 24*60*60; val += gettime64(2012,12,21); struct tm *birth = _gmtime64((__time64_t*)&val); int year = birth->tm_year + 1900 + year_add*400; int month = birth->tm_mon + 1; int day = birth->tm_mday + 1; printf("%d.%d.%d\n",year,month,day); } } return 0; }
a.cc: In function 'll gettime64(ll, ll, ll)': a.cc:16:10: error: '_mktime64' was not declared in this scope; did you mean 'mktime'? 16 | return _mktime64(&poi); | ^~~~~~~~~ | mktime a.cc: In function 'int main()': a.cc:74:37: error: '__time64_t' was not declared in this scope; did you mean '__timer_t'? 74 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^~~~~~~~~~ | __timer_t a.cc:74:48: error: expected primary-expression before ')' token 74 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^ a.cc:74:26: error: '_gmtime64' was not declared in this scope; did you mean 'gmtime_r'? 74 | struct tm *birth = _gmtime64((__time64_t*)&val); | ^~~~~~~~~ | gmtime_r
s690987371
p00256
C++
#include <bits/stdc++.h> #include <time.h> using namespace std; typedef long long ll; typedef vector<int> vi; ll gettime64(ll y,ll m,ll d){ struct tm poi; poi.tm_year = y-1900; poi.tm_mon = m-1; poi.tm_mday = d; poi.tm_hour = poi.tm_min = poi.tm_sec = 0; poi.tm_isdst = -1; return mktime(&poi); } int toint(string s){ return atoi(s.c_str()); } vi split(string base, char spl){ vi result; string::size_type pos = 0; string::size_type bef = 0; base += spl; while( (pos = base.find_first_of(spl,bef)) != string::npos ){ result.push_back(toint(base.substr(bef,pos-bef))); bef = pos+1; } return result; } #define AD 146097 #define MAYA 1872000 int main(){ while(true){ string s; cin>>s; if(s=="#")break; vi input = split(s,'.'); if(input.size()==3){ // yyyy.mm.dd ll y = input[0]; ll m = input[1]; ll d = input[2]; ll year_down = (y - 2013)/400; y -= year_down*400; ll birth = gettime64(y,m,d); ll origin = gettime64(2012,12,21); ll sub = (birth-origin)/24/60/60; sub += year_down*AD%MAYA; sub %= MAYA; int ki = sub%20; sub/=20; int w = sub%18; sub/=18; int t = sub%20; sub/=20; int ka = sub%20; int b = sub/20; printf("%d.%d.%d.%d.%d\n",b,ka,t,w,ki); }else{ // b.ka.t.w.ki ll val = 0; val += input[0]; val *= 20; val += input[1]; val *= 20; val += input[2]; val *= 18; val += input[3]; val *= 20; val += input[4]; ll year_add = val/AD; val %= AD; val *= 24*60*60; val += gettime64(2012,12,21); struct tm *birth = gmtime(&val); int year = birth->tm_year + 1900 + year_add*400; int month = birth->tm_mon + 1; int day = birth->tm_mday + 1; printf("%d.%d.%d\n",year,month,day); } } return 0; }
a.cc: In function 'int main()': a.cc:74:33: error: invalid conversion from 'll*' {aka 'long long int*'} to 'const time_t*' {aka 'const long int*'} [-fpermissive] 74 | struct tm *birth = gmtime(&val); | ^~~~ | | | ll* {aka long long int*} In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54, from a.cc:1: /usr/include/time.h:132:41: note: initializing argument 1 of 'tm* gmtime(const time_t*)' 132 | extern struct tm *gmtime (const time_t *__timer) __THROW; | ~~~~~~~~~~~~~~^~~~~~~
s973318709
p00256
C++
#include<iostream> #include<string.h> #include<stdlib.h> #include<time.h> #include<stdio.h> using namespace std; struct tm T; struct tm *a; int maya[5]={144000,7200,360,20,1}; int sugi[5]={1,20,20,18,20}; int main(){ time_t tt,kin,ans,s=1356015600; char koyomi[50]; int i,j; int n[5]={0}; while(1){ cin>>koyomi; if(koyomi[0]=='#'){ break; } memset(n,0,sizeof(n)); j=0; cout<<strlen(koyomi)<<endl; for(i=0;i<strlen(koyomi);i++){ if(koyomi[i]=='.'){ j++; } } cout<<j<<endl; if(j==2){ sscanf(koyomi,"%d.%d.%d",&n[0],&n[1],&n[2]); T.tm_year=n[0]-1900; T.tm_mon=n[1]-1; T.tm_mday=n[2]; tt=(mktime(&T)-s)/86400%1872000; //cout<<tt<<endl; printf("%11d.%11d.%11d.%11d.%11d\n",tt/144000,tt/7200%20,tt/360%20,tt/20%18,tt%20); } else{ sscanf(koyomi,"%d.%d.%d.%d.%d",&n[0],&n[1],&n[2],&n[3],&n[4]); tt=(n[0]*144000+n[1]*7200+n[2]*360+n[3]*20+n[4])*86400+s; localtime_r(&tt,&T); printf("%d.%d.%d\n",T.tm_year+1900,T.tm_mon+1,T.tm_mday); } return 0; }
a.cc: In function 'int main()': a.cc:46:2: error: expected '}' at end of input 46 | } | ^ a.cc:11:11: note: to match this '{' 11 | int main(){ | ^
s926239848
p00256
C++
v#include<bits/stdc++.h> #define LL long long int #define INF 734858 using namespace std; int main(void) { LL b,ka,t,w,ki,y,m,d,sum,cnt,mon,day,year; LL i,j,k; LL maya[5]={144000,7200,360,20,1}; LL month[2][12]={ {31,28,31,30,31,30,31,31,30,31,30,31}, {31,29,31,30,31,30,31,31,30,31,30,31} }; char s[100]; while(1) { cin>>s; if(s[0]=='#') break; cnt=0; for(i=0;i<strlen(s);i++) { if(s[i]=='.') cnt++; } if(cnt==2) { //?\????????????? sum=0; string sum2; sum2=s[0]; for(i=1;i<strlen(s);i++) { if(s[i]=='.') break; else sum2+=s[i]; } int mx; mx=atoi(sum2.c_str()); //sum=?\????????¨? for(i=1;i<mx;i++) { if(i%4==0&&i%100!=0||i%400==0) sum+=366; else sum+=365; } //?????°????¨???? int f=0; for(i=0;i<strlen(s);i++) { if(s[i]=='.'&&s[i+2]=='.') { sum2=s[i+1]; if(f==0) mon=atoi(sum2.c_str()); else day=atoi(sum2.c_str()); f=1; } else if(s[i]=='.'&&s[i+2]!='.') { sum2=s[i+1]; sum2+=s[i+2]; if(f==0) mon=atoi(sum2.c_str()); else day=atoi(sum2.c_str()); f=1; } } //cout<<mon<<" "<<day<<endl; //?????°???sum????¶?????????????????????´??¨????????§????????¨????????????????????? int test=0; for(i=0;i<mon-1;i++) { if(mx%4==0&&mx%100!=0||mx%400==0) sum+=month[1][i]; else sum+=month[0][i]; } //??\????????????????????§???????????§??????????????§?????\??§?¨???? sum+=day,sum-=INF; b=sum/maya[0],sum=sum%maya[0],b=b%13; ka=sum/maya[1],sum=sum%maya[1],ka=ka%20; t=sum/maya[2],sum=sum%maya[2],t=t%20; w=sum/maya[3],ki=sum%maya[3],w=w%18,ki%20; //cout<<b%13<<"."<<ka%20<<"."<<t%20<<"."<<w%18<<"."<<ki%20<<endl; cout<<b<<"."<<ka<<"."<<t<<"."<<w<<"."<<ki<<endl; } else { //??????????\???? sum=0; LL swi=1,x; string sum3; //????????????????????§??? if(s[1]=='.') sum3=s[0],sum+=atoi(sum3.c_str())*maya[0]; else if(s[1]!='.') sum3=s[0],sum3+=s[1],sum+=atoi(sum3.c_str())*maya[0]; for(i=0;i<strlen(s);i++) { if(s[i]=='.'&&s[i+2]=='.') { sum3=s[i+1]; sum+=atoi(sum3.c_str())*maya[swi]; swi++; } else if(s[i]=='.'&&s[i+2]!='.') { sum3=s[i+1],sum3+=s[i+2]; sum+=atoi(sum3.c_str())*maya[swi]; swi++; } } // cout<<sum<<endl; int zan=10;//zan???21????£????10???????´????????????????sum?????????10??????????????? if(sum<11) { cout<<"2012.12."<<sum+21<<endl; } else { sum-=10; LL suu=2013; while(1) { if(suu%4==0&&suu%100!=0||suu%400==0) { if(sum>366) { sum-=366; } else if(sum==366) { sum-=366; mon=12,day=31; } else { mon=1; for(i=0;i<12;i++) { if(sum>=month[1][i]) { if(sum-month[1][i]==0) break; sum-=month[1][i]; mon++; } } day=sum; sum=0; } } else { if(sum>365) { sum-=365; } else if(sum==365) { sum-=365; mon=12,day=31; } else { mon=1; //cout<<"sum=="<<sum<<endl; for(i=0;i<12;i++) { if(sum>=month[0][i]) { if(sum-month[0][i]==0) break; sum-=month[0][i]; mon++; //cout<<"sum=="<<sum<<endl; } } day=sum; sum=0; } } if(sum==0) break; suu++; } cout<<suu<<"."<<mon<<"."<<day<<endl; } } } }
a.cc:1:2: error: stray '#' in program 1 | v#include<bits/stdc++.h> | ^ a.cc:1:1: error: 'v' does not name a type 1 | v#include<bits/stdc++.h> | ^ a.cc: In function 'int main()': a.cc:16:17: error: 'cin' was not declared in this scope 16 | cin>>s; | ^~~ a.cc:19:27: error: 'strlen' was not declared in this scope 19 | for(i=0;i<strlen(s);i++) { | ^~~~~~ a.cc:1:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' +++ |+#include <cstring> 1 | v#include<bits/stdc++.h> a.cc:24:25: error: 'string' was not declared in this scope 24 | string sum2; | ^~~~~~ a.cc:25:25: error: 'sum2' was not declared in this scope; did you mean 'sum'? 25 | sum2=s[0]; | ^~~~ | sum a.cc:26:35: error: 'strlen' was not declared in this scope 26 | for(i=1;i<strlen(s);i++) { | ^~~~~~ a.cc:26:35: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:31:28: error: 'atoi' was not declared in this scope 31 | mx=atoi(sum2.c_str()); | ^~~~ a.cc:39:35: error: 'strlen' was not declared in this scope 39 | for(i=0;i<strlen(s);i++) { | ^~~~~~ a.cc:39:35: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:68:25: error: 'cout' was not declared in this scope 68 | cout<<b<<"."<<ka<<"."<<t<<"."<<w<<"."<<ki<<endl; | ^~~~ a.cc:68:68: error: 'endl' was not declared in this scope 68 | cout<<b<<"."<<ka<<"."<<t<<"."<<w<<"."<<ki<<endl; | ^~~~ a.cc:73:25: error: 'string' was not declared in this scope 73 | string sum3; | ^~~~~~ a.cc:75:39: error: 'sum3' was not declared in this scope; did you mean 'sum'? 75 | if(s[1]=='.') sum3=s[0],sum+=atoi(sum3.c_str())*maya[0]; | ^~~~ | sum a.cc:75:54: error: 'atoi' was not declared in this scope 75 | if(s[1]=='.') sum3=s[0],sum+=atoi(sum3.c_str())*maya[0]; | ^~~~ a.cc:76:44: error: 'sum3' was not declared in this scope; did you mean 'sum'? 76 | else if(s[1]!='.') sum3=s[0],sum3+=s[1],sum+=atoi(sum3.c_str())*maya[0]; | ^~~~ | sum a.cc:76:70: error: 'atoi' was not declared in this scope 76 | else if(s[1]!='.') sum3=s[0],sum3+=s[1],sum+=atoi(sum3.c_str())*maya[0]; | ^~~~ a.cc:77:35: error: 'strlen' was not declared in this scope 77 | for(i=0;i<strlen(s);i++) { | ^~~~~~ a.cc:77:35: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:79:41: error: 'sum3' was not declared in this scope; did you mean 'sum'? 79 | sum3=s[i+1]; | ^~~~ | sum a.cc:80:46: error: 'atoi' was not declared in this scope 80 | sum+=atoi(sum3.c_str())*maya[swi]; | ^~~~ a.cc:84:41: error: 'sum3' was not declared in this scope; did you mean 'sum'? 84 | sum3=s[i+1],sum3+=s[i+2]; | ^~~~ | sum a.cc:85:46: error: 'atoi' was not declared in this scope 85 | sum+=atoi(sum3.c_str())*maya[swi]; | ^~~~ a.cc:92:33: error: 'cout' was not declared in this scope 92 | cout<<"2012.12."<<sum+21<<endl; | ^~~~ a.cc:92:59: error: 'endl' was not declared in this scope 92 | cout<<"2012.12."<<sum+21<<endl; | ^~~~ a.cc:145:33: error: 'cout' was not declared in this scope 145 | cout<<suu<<"."<<mon<<"."<<day<<endl; | ^~~~ a.cc:145:64: error: 'endl' was not declared in this scope 145 | cout<<suu<<"."<<mon<<"."<<day<<endl; | ^~~~
s252257737
p00256
C++
#include <stdio.h> #include <ctype.h> char *gets(char *); char buf[100], *p; int getInt(void) { int n = 0; while (isspace(*p) || *p == '.') p++; if (!*p) return -1; while (isdigit(*p)) n = 10 * n + (*p++ - '0'); return n; } #define MAGIC 2456283 // 2012.12.21 long long greg2jd(int year, int month, int day) { long long a, y, m; long long j; a = (14 - month) / 12; y = year + 4800 - a; m = month + 12 * a - 3; j = day + (153 * m + 2) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 32045; return j; } int jd2greg(int *year, int *month, int *day, int jd) { int a, b, c; int d, e, m; int yy; int m1; a = jd + 32044; b = (4 * a + 3) / 146097; c = a - (146097 * b) / 4; d = (4 * c + 3) / 1461; e = c - (1461 * d) / 4; m = (5 * e + 2) / 153; m1 = m / 10; *day = e - (153 * m + 2) / 5 + 1; *month = m + 3 - 12 * m1; yy = 100 * b + d - 4800 + m1; if (yy <= 0) { *year = -yy + 1; return -1; } *year = yy; return 1; } int main() { int b, ka, t, w, ki; int y, m, d; int a, k; long long x; while (1) { gets(p = buf); if (*p == '#') break; y = getInt(), m = getInt(), d = getInt(), a = getInt(); if (a >= 0) { // maya -> Gregorian b = y, ka = m, t = d, w = a, ki = getInt(); k = (((20 * b + ka) * 20 + t) * 18 + w) * 20 + ki; k += MAGIC; jd2greg(&y, &m, &d, k); printf("%d.%d.%d\n", y, m, d); } else { x = (greg2jd(y, m, d) - MAGIC) % 1872000; k = (int)x; b = k / 144000, k %= 144000; ka = k / 7200, k %= 7200; t = k / 360, k %= 360; w = k / 20, ki = k % 20; printf("%d.%d.%d.%d.%d\n", b, ka, t, w, ki); } } return 0; }
/usr/bin/ld: /tmp/ccmmUhOM.o: in function `main': a.cc:(.text+0x398): undefined reference to `gets(char*)' collect2: error: ld returned 1 exit status
s422692828
p00256
C++
#include <stdio.h> #include <ctype.h> char *gets(char *); char buf[100], *p; int getInt(void) { int n = 0; while (isspace(*p) || *p == '.') p++; if (!*p) return -1; while (isdigit(*p)) n = 10 * n + (*p++ - '0'); return n; } #define MAGIC 2456283 // 2012.12.21 long long greg2jd(int year, int month, int day) { long long a, y, m; long long j; a = (14 - month) / 12; y = year + 4800 - a; m = month + 12 * a - 3; j = day + (153 * m + 2) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 32045; return j; } int jd2greg(int *year, int *month, int *day, int jd) { int a, b, c; int d, e, m; int yy; int m1; a = jd + 32044; b = (4 * a + 3) / 146097; c = a - (146097 * b) / 4; d = (4 * c + 3) / 1461; e = c - (1461 * d) / 4; m = (5 * e + 2) / 153; m1 = m / 10; *day = e - (153 * m + 2) / 5 + 1; *month = m + 3 - 12 * m1; yy = 100 * b + d - 4800 + m1; if (yy <= 0) { *year = -yy + 1; return -1; } *year = yy; return 1; } int main() { int b, ka, t, w, ki; int y, m, d; int a, k; long long x; while (1) { gets(p = buf); if (*p == '#') break; y = getInt(), m = getInt(), d = getInt(), a = getInt(); if (a >= 0) { // maya -> Gregorian b = y, ka = m, t = d, w = a, ki = getInt(); k = (((20 * b + ka) * 20 + t) * 18 + w) * 20 + ki; k += MAGIC; jd2greg(&y, &m, &d, k); printf("%d.%d.%d\n", y, m, d); } else { x = (greg2jd(y, m, d) - MAGIC) % 1872000; k = (int)x; b = k / 144000, k %= 144000; ka = k / 7200, k %= 7200; t = k / 360, k %= 360; w = k / 20, ki = k % 20; printf("%d.%d.%d.%d.%d\n", b, ka, t, w, ki); } } return 0; }
/usr/bin/ld: /tmp/ccIeUlRE.o: in function `main': a.cc:(.text+0x398): undefined reference to `gets(char*)' collect2: error: ld returned 1 exit status
s810716488
p00257
Java
import java.io.BufferedReader; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); while(true){ final int max =sc.nextInt(); if(max == 0){ break; } final int n = sc.nextInt(); final int size = n + 2; int[] map = new int[size]; for(int i = 1; i <= n; i++){ map[i] = sc.nextInt(); } //int[][] adj = new int[size][max]; boolean[][] adj = new boolean[size][size]; for(int i = 0; i < size; i++){ for(int j = 0; j < max; j++){ if(i == size - 1){ adj[i][i] = true; continue; } final int num = j + 1; final int to = Math.min(size - 1, Math.max(0, i + num)); final int dist = Math.min(size - 1, Math.max(0, to + map[to])); adj[i][dist] = true; } } for(int k = 0; k < size; k++){ for(int i = 0; i < size; i++){ for(int j = 0; j < size; j++){ adj[i][j] = adj[i][j] || (adj[i][k] && adj[k][j]); } } } boolean flag = true; for(int i = 0; i < size; i++){ //System.out.print(i + " "); //System.out.print(adj[0][i] + " "); //System.out.println(adj[i][size-1]); if(adj[0][i] && !adj[i][size-1]){ System.out.println("NG"); flag = false; break; } } if(flag){ System.out.println("OK"); } } } }
Main.java:5: error: cannot find symbol public static void main(String[] args) throws IOException { ^ symbol: class IOException location: class Main Main.java:6: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:6: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main 3 errors
s123884830
p00257
C++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s715805802
p00257
C++
#include<cstdio> #include<queue> #include<vector> #define rep(i,a) for( int i = 0; i != (a); ++i ) #define repi(i,a,b) for( int i = (a); i != (b); ++i ) int ma; int n; int d[252]; std::vector<int> G[252], rG[252]; bool reach[252], rev[252]; void dfs( int v ) { rev[v] = true; rep( i, rG[v].size() ) if( !rev[rG[v][i]] ) dfs( rG[v][i] ); return; } void dfs2( int v ) { reach[v] = true; rep( i, G[v].size() ) if( !reach[G[v][i]] ) dfs2( G[v][i] ); return; } int main() { while( scanf( "%d", &ma ), ma ) { rep( i, 252 ) G[i].clear(), rG[i].clear(); scanf( "%d", &n ); repi( i, 1, n+1 ) scanf( "%d", d+i ); rep( i, n+1 ) { rep( j, ma ) { if( i+j+1 >= n+2 ) break; int to = std::max( 0, std::min( i+j+1+d[i+j+1], n+1 ) ); G[i].push_back( to ); rG[to].push_back( i ); } } memset( reach, false, sizeof( reach ) ); memset( rev, false, sizeof( rev ) ); dfs( n+1 ); dfs2( 0 ); bool fl = true; rep( i, n+2 ) if( reach[i] && !rev[i] ) fl = false; puts( fl ? "OK" : "NG" ); } return 0; }
a.cc: In function 'int main()': a.cc:60:17: error: 'memset' was not declared in this scope 60 | memset( reach, false, sizeof( reach ) ); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<queue> +++ |+#include <cstring> 3 | #include<vector>
s092725041
p00257
C++
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; template<class T> using Table = vector<vector<T>>; const ld eps=1e-9; // < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" typedef int Weight; struct Edge { int src, dst; Weight weight; Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { } }; struct Dscc { public: //belongs,newedges pair<vector<vector<int>>, vector<vector<int>>>get(const vector<vector<int>>&edges) { nums.resize(edges.size()); fill(nums.begin(), nums.end(), -1); vector<vector<int>>revedges(edges.size()); for (int i = 0; i < edges.size(); ++i) { for (auto j : edges[i]) { revedges[j].push_back(i); } } int num = 0; for (int i = 0; i < edges.size(); ++i) { dfs(i, num, edges); } vector<int>big(nums.size()); for (int i = 0; i < nums.size(); ++i) { big[nums[i]] = i; } reverse(big.begin(), big.end()); unis.resize(edges.size()); fill(unis.begin(), unis.end(), -1); num = 0; for (int i = 0; i < big.size(); ++i) { dfs2(big[i], num, revedges); num++; } vector<int>nums; for (int i = 0; i < unis.size(); ++i) { nums.push_back(unis[i]); } sort(nums.begin(), nums.end()); nums.erase(unique(nums.begin(), nums.end()), nums.end()); map<int, int>mp; for (int i = 0; i < nums.size(); ++i) { mp[nums[i]] = i; } for (int i = 0; i < unis.size(); ++i) { unis[i] = mp[unis[i]]; } vector<vector<int>>belongs(nums.size()); for (int i = 0; i < unis.size(); ++i) { belongs[unis[i]].push_back(i); } vector<vector<int>>newedges(nums.size()); for (int i = 0; i < edges.size(); ++i) { for (auto j : edges[i]) { if (unis[i] != unis[j]) { newedges[unis[i]].push_back(unis[j]); } } } return make_pair(belongs, newedges); } //belongs,newedges pair<vector<vector<int>>, vector<vector<Edge>>>get(const vector<vector<Edge>>&edges) { const int old_node_size = edges.size(); nums.resize(old_node_size); fill(nums.begin(), nums.end(), -1); vector<vector<Edge>>revedges(old_node_size); for (const auto& e : edges) { for (const auto& j : e) { revedges[j.dst].push_back(Edge(j.dst, j.src, j.weight)); } } int num = 0; for (int i = 0; i < old_node_size; ++i) { dfs(i, num, edges); } vector<int>big(old_node_size); for (int i = 0; i < old_node_size; ++i) { big[nums[i]] = i; } reverse(big.begin(), big.end()); unis.resize(old_node_size); fill(unis.begin(), unis.end(), -1); num = 0; for (int i = 0; i < old_node_size; ++i) { dfs2(big[i], num, revedges); num++; } vector<int>nums; for (int i = 0; i < old_node_size; ++i) { nums.push_back(unis[i]); } sort(nums.begin(), nums.end()); nums.erase(unique(nums.begin(), nums.end()), nums.end()); const int new_node_size = nums.size(); map<int, int>mp; for (int i = 0; i < new_node_size; ++i) { mp[nums[i]] = i; } for (int i = 0; i < old_node_size; ++i) { unis[i] = mp[unis[i]]; } vector<vector<int>>belongs(new_node_size); for (int i = 0; i < old_node_size; ++i) { belongs[unis[i]].push_back(i); } vector<vector<Edge>>newedges(new_node_size); for (const auto& e : edges) { for (const auto& j : e) { if (unis[j.src] != unis[j.dst]) { newedges[unis[j.src]].push_back(Edge(unis[j.src], unis[j.dst], j.weight)); } } } return make_pair(belongs, newedges); } private: vector<int>nums; vector<int>unis; void dfs(const int id, int &num, const vector<vector<int>>&edges) { if (nums[id] != -1)return; else { nums[id] = -2; for (auto i : edges[id]) { dfs(i, num, edges); } } nums[id] = num++; return; } void dfs2(const int id, const int &num, const vector<vector<int>>&edges) { if (unis[id] != -1)return; else { unis[id] = -2; for (auto i : edges[id]) dfs2(i, num, edges); } unis[id] = num; return; } void dfs(const int id, int &num, const vector<vector<Edge>>&edges) { if (nums[id] != -1)return; else { nums[id] = -2; for (auto i : edges[id]) { dfs(i.dst, num, edges); } } nums[id] = num++; return; } void dfs2(const int id, const int &num, const vector<vector<Edge>>&edges) { if (unis[id] != -1)return; else { unis[id] = -2; for (auto i : edges[id]) { dfs2(i.dst, num, edges); } } unis[id] = num; return; } }dscc; bool dfs(const int now,const vector<vector<int>>&edges, const int goal) { if (now == goal)return true; else { if (edges[now].empty())return false; for (auto e : edges[now]) { if (!dfs(e, edges, goal))return false; } return true; } } int main() { while (1) { int amax; cin >> amax; if (!amax)break; int N; cin >> N; const int goal = N + 1; const int start = 0; vector<int>ds(goal+1); for (int i = 0; i < N; ++i) { cin >> ds[i+1]; } vector<vector<int>>edges(N + 2); for (int i = 0; i < N + 1; ++i) { for (int j = 1; j <= amax; ++j) { int next; if (i + j >= goal) { next = goal; } else { if (i + j + ds[i + j] >= goal) { next = goal; } else if (i + j + ds[i+j]<0) { next = 0; } else { next = i + j + ds[i + j]; } } if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { edges[i].push_back(next); } } } auto p=dscc.get(edges); int newstart; int newgoal; for (int i = 0; i < p.first.size();++i) { auto b = p.first[i]; if (find(b.begin(), b.end(), 0)!=b.end()) { newstart = i; } if (find(b.begin(), b.end(), goal) != b.end()) { newgoal= i; } } auto newedges = p.second; bool ans = dfs(newstart, newedges, newgoal); if (ans) { cout << "OK" << endl; } else { cout << "NG" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:231:82: error: no match for 'operator==' (operand types are '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'std::vector<std::vector<int> >::iterator') 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~~~~~~~~ | | | | __normal_iterator<int*,vector<int>> __normal_iterator<std::vector<int>*,vector<std::vector<int>>> In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1274 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed: a.cc:231:95: note: 'std::vector<std::vector<int> >::iterator' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1441 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed: a.cc:231:95: note: 'std::vector<std::vector<int> >::iterator' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1613 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::pair<_T1, _T2>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::reverse_iterator<_Iterator>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::reverse_iterator<_Iterator>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:231:95: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::move_iterator<_IteratorL>' 231 | if (find(edges[i].begin(), edges[i].end(), next) == edges.end()) { | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_i
s731482620
p00257
C++
if(Solve(x+i)==true)return true; } } flg[x]=false; return false; } int main(){ while(cin>>mx , mx){ cin >> n; d[0]=0; for(int i=1; i<=n; i++){ cin>>d[i]; flg[i]=false; } if(Solve(0)==true)cout<<"OK"<<endl; else cout<<"NG"<<endl; } return 0; }
a.cc:1:6: error: expected unqualified-id before 'if' 1 | if(Solve(x+i)==true)return true; | ^~ a.cc:2:5: error: expected declaration before '}' token 2 | } | ^ a.cc:4:3: error: expected declaration before '}' token 4 | } | ^ a.cc:6:3: error: 'flg' does not name a type 6 | flg[x]=false; | ^~~ a.cc:8:3: error: expected unqualified-id before 'return' 8 | return false; | ^~~~~~ a.cc:9:1: error: expected declaration before '}' token 9 | } | ^ a.cc: In function 'int main()': a.cc:14:9: error: 'cin' was not declared in this scope 14 | while(cin>>mx , mx){ | ^~~ a.cc:14:14: error: 'mx' was not declared in this scope 14 | while(cin>>mx , mx){ | ^~ a.cc:15:12: error: 'n' was not declared in this scope 15 | cin >> n; | ^ a.cc:16:5: error: 'd' was not declared in this scope 16 | d[0]=0; | ^ a.cc:19:7: error: 'flg' was not declared in this scope 19 | flg[i]=false; | ^~~ a.cc:22:8: error: 'Solve' was not declared in this scope 22 | if(Solve(0)==true)cout<<"OK"<<endl; | ^~~~~ a.cc:22:23: error: 'cout' was not declared in this scope 22 | if(Solve(0)==true)cout<<"OK"<<endl; | ^~~~ a.cc:22:35: error: 'endl' was not declared in this scope 22 | if(Solve(0)==true)cout<<"OK"<<endl; | ^~~~ a.cc:23:10: error: 'cout' was not declared in this scope 23 | else cout<<"NG"<<endl; | ^~~~ a.cc:23:22: error: 'endl' was not declared in this scope 23 | else cout<<"NG"<<endl; | ^~~~
s522500780
p00257
C++
#include<bits/stdc++.h> using namespace std; #define pb push_back int M; int N; int D[259]; int main() { while(true){ scanf("%d",&M); if(M==0)break; scanf("%d",&N); for(int i=1;i<=N;i++)scanf("%d",&D[i]); vector<int> G[259]; for(int i=1;i<=N;i++){ if(i+D[i]<0)G[i].pb(0); else if(i+D[i]>N+1)G[i].pb(N+1); else G[i].pb(i+D[i]); for(int j=1;j<=M;j++){ if(i+j<=N+1)G[i].pb(i+j); } } for(int j=1;j<=M;j++){ if(j<=N+1)G[0].pb(j); } bool F[259]; for(int i=0;i<=N+1;i++)F[i]=false; vector<int>S;S.pb(0); int l=0; while(l<(int)S.size()){ int v=S[l]; if(F[v])continue; F[v]=true; for(int i=0;i<(int)G[v].size();i++){ if(!F[G[v][i]]){ S.pb(G[v][i]); r++; } } l++; } bool ans=true; bool F1[259]; for(int i=0;i<=N+1;i++){ if(!F[i])continue; for(int j=0;j<=N+1;j++){ F1[i]=false; } S.clear(); S.pb(i); l=0; while(l<(int)S.size()&&!F1[N+1]){ int v=S[l]; if(F1[v])continue; F1[v]=true; for(int i=0;i<(int)G[v].size();i++){ if(!F1[G[v][i]]){ S.pb(G1[v][i]); r++; } } l++; } if(!F1[N+1])ans=false; } if(ans)printf("OK\n"); else printf("NG\n"); } return 0; }
a.cc: In function 'int main()': a.cc:37:41: error: 'r' was not declared in this scope 37 | r++; | ^ a.cc:58:54: error: 'G1' was not declared in this scope; did you mean 'F1'? 58 | S.pb(G1[v][i]); | ^~ | F1 a.cc:59:49: error: 'r' was not declared in this scope 59 | r++; | ^
s951172836
p00257
C++
#include <iostream> #include <queue> #include <algorithm> using namespace std; const INF = 1 << 22; int main() { int Max,n; while(cin >> Max, Max){ int map[252] = {}; int dist[252][252]; cin >> n; for(int i = 1; i <= n; ++i){ cin >> map[i]; } fill((int*)dist,(int*)(dist + n + 2),INF); queue<int> q; q.push(0); while(!q.empty()){ int x = q.front(); q.pop(); for(int i = 1; i <= Max; ++i){ int nx = x + i; if(nx >= n + 1){ dist[x][nx] = 1; } else { int t = nx; nx += map[t]; if(nx >= n + 1){ dist[x][n + 1] = 1; } else if(nx <= 0){ dist[x][0] = 1; } else if(dist[x][nx] == INF){ dist[x][nx] = 1; q.push(nx); } } } } for(int i = 0; i < n + 2; ++i){ dist[i][i] = 0; } for(int k = 0; k < n + 2; ++k){ for(int i = 0; i < n + 2; ++i){ for(int j = 0; j < n + 2; ++j){ dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]); } } } bool f = false; for(int i = 0; i < n + 1; ++i){ if(dist[0][i] != INF && dist[i][n + 1] == INF){ cout << "NG" << endl; f = true; break; } } if(!f){ cout << "OK" << endl; } } }
a.cc:6:7: error: 'INF' does not name a type 6 | const INF = 1 << 22; | ^~~ a.cc: In function 'int main()': a.cc:17:46: error: 'INF' was not declared in this scope 17 | fill((int*)dist,(int*)(dist + n + 2),INF); | ^~~
s028224734
p00257
C++
#include <iostream> #include <vector> #include <queue> #include <deque> #include <vector> #include <string> using namespace std; int maxCount, n; vector<int> kouka; int memo[252];//251があがり0がふりだし int passed[252]; const int AGARI = 100000; bool dfs(int index) { if(passed[index]) return false; passed[index] = true; index = min(n + 1, max(0 ,kouka[index] + index)); if(kouka[index] == AGARI) return true; for (int i = 1; i <= maxCount; i++) { int next = index + i; if(memo[next]) if(memo[next] = dfs(next)) return true; } passed[index] = false; return false; } bool solve() { for (int i = 1; i <= maxCount; i++) { if(dfs(i)) return true; } return false; } int main() { while(cin >> maxCount && maxCount) { cin >> n; kouka.resize(n + 2); kouka[0] = -1;//ふりだし for (int i = 1; i < n + 1; i++) { cin >> kouka[i]; } kouka[n + 1] = AGARI;//あがり memset(memo, true, sizeof(memo)); memset(passed, false, sizeof(memo)); cout << (solve()? "OK" : "NG") << endl; } }
a.cc: In function 'int main()': a.cc:56:17: error: 'memset' was not declared in this scope 56 | memset(memo, true, sizeof(memo)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <queue> +++ |+#include <cstring> 4 | #include <deque>
s867004081
p00257
C++
#include <iostream> #include <vector> #include <queue> #include <deque> #include <vector> #include <string> using namespace std; int maxCount, n; vector<int> kouka; int memo[252];//251があがり0がふりだし int passed[252]; const int AGARI = 100000; bool dfs(int index) { if(passed[index]) return false; passed[index] = true; index = min(n + 1, max(0 ,kouka[index] + index)); if(kouka[index] == AGARI) return true; for (int i = 1; i <= maxCount; i++) { int next = index + i; if(memo[next]) if(memo[next] = dfs(next)) return true; } passed[index] = false; return false; } bool solve() { for (int i = 1; i <= maxCount; i++) { if(dfs(i)) return true; } return false; } int main() { while(cin >> maxCount && maxCount) { cin >> n; kouka.resize(n + 2); kouka[0] = -1;//ふりだし for (int i = 1; i < n + 1; i++) { cin >> kouka[i]; } kouka[n + 1] = AGARI;//あがり memset(memo, true, sizeof(memo)); memset(passed, false, sizeof(memo)); cout << (solve()? "OK" : "NG") << endl; } }
a.cc: In function 'int main()': a.cc:56:17: error: 'memset' was not declared in this scope 56 | memset(memo, true, sizeof(memo)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <queue> +++ |+#include <cstring> 4 | #include <deque>
s504398744
p00257
C++
#include <iostream> #include <vector> #include <queue> #include <deque> #include <vector> #include <string> using namespace std; int maxCount, n; vector<int> kouka; int memo[252];//251があがり0がふりだし int passed[252]; const int AGARI = 100000; bool dfs(int index) { if(passed[index]) return false; passed[index] = true; index = min(n + 1, max(0 ,kouka[index] + index)); if(kouka[index] == AGARI) return true; for (int i = 1; i <= maxCount; i++) { int next = index + i; if(memo[next]) if(memo[next] = dfs(next)) return true; } passed[index] = false; return false; } bool solve() { for (int i = 1; i <= maxCount; i++) { if(dfs(i)) return true; } return false; } int main() { while(cin >> maxCount && maxCount) { cin >> n; kouka.resize(n + 2); kouka[0] = -1;//ふりだし for (int i = 1; i < n + 1; i++) { cin >> kouka[i]; } kouka[n + 1] = AGARI;//あがり memset(memo, true, sizeof(memo)); memset(passed, false, sizeof(memo)); cout << (solve()? "OK" : "NG") << endl; } }
a.cc: In function 'int main()': a.cc:56:17: error: 'memset' was not declared in this scope 56 | memset(memo, true, sizeof(memo)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <queue> +++ |+#include <cstring> 4 | #include <deque>
s396518566
p00257
C++
#include <iostream> #include <vector> #include <string> using namespace std; int maxCount, n; vector<int> kouka; int memo[252];//251があがり0がふりだし int passed[252]; const int AGARI = 100000; bool dfs(int index) { if(passed[index]) return false; passed[index] = true; index = min(n + 1, max(0 ,kouka[index] + index)); if(kouka[index] == AGARI) return true; for (int i = 1; i <= maxCount; i++) { int next = index + i; if(memo[next]) if(memo[next] = dfs(next)) return true; } passed[index] = false; return false; } bool solve() { for (int i = 1; i <= maxCount; i++) { if(dfs(i)) return true; } return false; } int main() { while(cin >> maxCount && maxCount) { cin >> n; kouka.resize(n + 2); kouka[0] = -1;//ふりだし for (int i = 1; i < n + 1; i++) { cin >> kouka[i]; } kouka[n + 1] = AGARI;//あがり memset(memo, true, sizeof(memo)); memset(passed, false, sizeof(memo)); cout << (solve()? "OK" : "NG") << endl; } }
a.cc: In function 'int main()': a.cc:53:17: error: 'memset' was not declared in this scope 53 | memset(memo, true, sizeof(memo)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <vector> +++ |+#include <cstring> 3 | #include <string>
s729677270
p00257
C++
#include <iostream> #include <vector> #include <bitset> using namespace std; int M, N, D[256]; bool G[256][256]; int main() { for(; cin >> M && M; ) { memset(G, false, sizeof G); cin >> N; for(int i = 1; i <= N; i++) { cin >> D[i]; } for(int i = 0; i <= N; i++) { for(int j = 1; j <= M; j++) { if(i+j >= N+1) G[i][N+1] = true; else G[i][max(0, min(i+j+D[i+j], N+1))] = true; } } for(int i = 0; i <= N+1; i++) { for(int j = 0; j <= N+1; j++) { for(int k = 0; k <= N+1; k++) { G[i][j] |= (G[i][k] && G[k][j]); } } } bool res = G[0][N+1]; for(int i = 1; i <= N; i++) { res &= (G[0][i] ? G[i][N+1] : true); } cout << (res ? "OK" : "NG") << endl; } }
a.cc: In function 'int main()': a.cc:14:17: error: 'memset' was not declared in this scope 14 | memset(G, false, sizeof G); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <bitset> +++ |+#include <cstring> 4 | using namespace std;
s435671760
p00258
C
#include <iostream> #include <algorithm> using namespace std; int n, c, a[32], b[32], dp[32][65536], st[32][65536]; int bit_count(int x){ int res = 0; for(int i = 0 ; i < 16 ; i++ ){ if( x & (1 << i) ) res++; } return res; } int main(){ while( cin >> n >> c, n || c ){ fill(a, a + 32, 0); fill(b, b + 32, 0); for(int i = 0 ; i < n ; i++ ){ for(int j = 0 ; j < 16 ; j++ ){ int e; cin >> e; a[i] |= e << j; } } for(int i = 0 ; i < c ; i++ ){ for(int j = 0 ; j < 16 ; j++ ){ int e; cin >> e; b[i] |= e << j; } } b[c] = 0; c++; for(int i = 0 ; i < c ; i++ ){ for(int j = 0 ; j < (1 << 16) ; j++ ){ st[i][j] = bit_count(j & b[i]); } } for(int i = 0 ; i < 32 ; i++ ) fill(dp[i], dp[i] + 65536, -1); dp[0][0] = 0; int ans = 0; for(int i = 0 ; i < n ; i++ ){ for(int j = 0 ; j < (1 << 16) ; j++ ){ if( dp[i][j] == -1 ) continue; int nx = j | a[i]; for(int k = 0 ; k < c ; k++ ){ int tx = nx & ~b[k]; dp[i+1][tx] = max(dp[i+1][tx], dp[i][j] + st[k][nx]); ans = max(ans, dp[i+1][tx]); } } } cout << ans << endl; } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s256211004
p00258
C++
#include<iostream> using namespace std; int n,c; int a[33]; int b[33]; int memo[31][1 << 16 + 1]; int dp(int index,int bit); int main(){ while(1){ cin >> n >> c; if(n == 0 && c == 0) break; for(int i=0;i<n;i++){ a[i] = 0; for(int j=0;j<16;j++){ int aa; cin >> aa; if(aa) a[i] |= 1 << j; } } for(int i=0;i<c;i++){ b[i] = 0; for(int j=0;j<16;j++){ int bb; cin >> bb; if(bb) b[i] |= 1 << j; } } memset(memo,0,sizeof(memo)); cout << dp(0,a[0]) << endl; } } int dp(int index,int bit){ if(index == n) return 0; if(memo[index][bit]) return memo[index][bit]; int ans = 0; for(int i=0;i<c;i++){ ans = max(ans,dp(index+1,(bit & ~b[i]) | a[index+1]) + __builtin_popcount(bit & b[i])); } return memo[index][bit] = ans; }
a.cc: In function 'int main()': a.cc:31:17: error: 'memset' was not declared in this scope 31 | memset(memo,0,sizeof(memo)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | using namespace std;
s930285341
p00258
C++
#include <iostream> #include <stdio.h> #include <utility> #include <algorithm> #include <functional> #include <string> using namespace std; typedef long long ll; int st[31][1<<16],dp[31][1<<16]; int count(int num){ int res=0; for(int i=0;i<16;i++)if((num>>i)&1)res++; return res; } int main() { int n,c; while(cin>>n>>c&&n){ memset(st,0,sizeof(st)); memset(dp,-1,sizeof(dp)); int light[31],push[31],tmp; for(int i=0;i<n;i++) for(int j=0;j<16;j++){ cin>>tmp; light[i]<<1; light[i]+=tmp; } for(int i=0;i<c;i++){ for(int j=0;j<16;j++){ cin>>tmp; push[i]*=2; push[i]+=tmp; } for(int j=0;j<(1<<16);j++){ st[i][j]=count(push[i]&j); dp[0][j]=0; } } for(int i=0;i<n;i++){ for(int j=0;j<(1<<16);j++){ if(dp[i][j]<0)continue; int nx=j|light[i]; dp[i+1][nx]=max(dp[i+1][nx],dp[i][j]); for(int k=0;k<c;k++){ int tx=nx&~push[j]; dp[i+1][tx]=max(dp[i+1][tx],dp[i][j]+st[k][nx]); } } } int ans=0; for(int i=0;i<(1<<16);i++)ans=max(ans,dp[n][i]); printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:19:17: error: 'memset' was not declared in this scope 19 | memset(st,0,sizeof(st)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <functional> +++ |+#include <cstring> 6 | #include <string>
s941202690
p00258
C++
#include <iostream> #include <stdio.h> #include <utility> #include <algorithm> #include <functional> #include <string> #include <set> using namespace std; typedef long long ll; int st[31][1<<16],dp[31][1<<16]; int count(int num){ int res=0; for(int i=0;i<16;i++)if((num>>i)&1)res++; return res; } int main() { int n,c; while(cin>>n>>c&&n){ memset(st,0,sizeof(st)); memset(dp,-1,sizeof(dp)); int light[31]={},push[31]={},tmp; for(int i=0;i<n;i++){ for(int j=0;j<16;j++){ cin>>tmp; light[i]*=2; light[i]+=tmp; } light[i]=light[i]&((1<<16)-1); //printf("light[%d]:%d\n",i,light[i]); } for(int i=0;i<c;i++){ for(int j=0;j<16;j++){ cin>>tmp; push[i]*=2; push[i]+=tmp; } for(int j=0;j<(1<<16);j++){ st[i][j]=count(push[i]&j); } push[i]=push[i]&((1<<16)-1); //printf("push[%d]:%d\n",i,push[i]); } dp[0][0]=0; for(int i=0;i<n;i++){ for(int j=0;j<(1<<16);j++){ if(dp[i][j]<0)continue; int nx=j|light[i]; //dp[i+1][nx]=max(dp[i+1][nx],dp[i][j]); for(int k=0;k<c;k++){ int tx=nx-(nx&push[i]); dp[i+1][tx]=max(dp[i+1][tx],dp[i][j]+st[k][nx]); } } } int ans=0; for(int i=0;i<(1<<16);i++)ans=max(ans,dp[n][i]); printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: 'memset' was not declared in this scope 20 | memset(st,0,sizeof(st)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <set> +++ |+#include <cstring> 8 | using namespace std;
s339972208
p00258
C++
const int pannels=16; const int bits=2<<pannels; int DP[bits+1][31]={}; int main(){ while(true){ int n,c,tmp; cin >> n >> c; if(n==0) break; queue<bitset<pannels> > qoo[2]; vector<bitset<pannels> > light; vector<bitset<pannels> > push; for(int i=0;i<bits;i++) for(int j=0;j<31;j++) DP[i][j]=0; for(int i=0;i<n;i++){ light.push_back(bitset<pannels>(0)); for(int j=0;j<pannels;j++){ cin >> tmp; light[i].set(j,tmp); } } for(int i=0;i<c;i++){ push.push_back(bitset<pannels>(0)); for(int j=0;j<pannels;j++){ cin >> tmp; push[i].set(j,tmp); } } bitset<pannels> lig(0),score(0),get(0); for(int i=0;i<c;i++){ lig=light[0]^(light[0]&push[i]); get=light[0]&push[i]; // cout << lig << endl; if(!DP[lig.to_ulong()][0]){ qoo[1].push(lig); } DP[lig.to_ulong()][0]=max((int)get.count(),DP[lig.to_ulong()][0]); } for(int i=1;i<n;i++){ while(!qoo[i%2].empty()){ score=qoo[i%2].front(); // cout << score << endl; qoo[i%2].pop(); for(int k=0;k<c;k++){ lig=(score|light[i])^(push[k]&(score|light[i])); get=(score|light[i])&push[k]; if(DP[lig.to_ulong()][i]) qoo[(i+1)%2].push(lig); DP[lig.to_ulong()][i]=max((int)bitset<pannels>(get).count()+DP[score.to_ulong()][i-1],DP[lig.to_ulong()][i]); } } } int ans=0; for(int i=0;i<bits;i++) ans=max(ans,DP[i][n-1]); cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:7:3: error: 'cin' was not declared in this scope 7 | cin >> n >> c; | ^~~ a.cc:10:3: error: 'queue' was not declared in this scope 10 | queue<bitset<pannels> > qoo[2]; | ^~~~~ a.cc:10:9: error: 'bitset' was not declared in this scope; did you mean 'bits'? 10 | queue<bitset<pannels> > qoo[2]; | ^~~~~~ | bits a.cc:10:25: error: expected primary-expression before '>' token 10 | queue<bitset<pannels> > qoo[2]; | ^ a.cc:10:27: error: 'qoo' was not declared in this scope 10 | queue<bitset<pannels> > qoo[2]; | ^~~ a.cc:11:3: error: 'vector' was not declared in this scope 11 | vector<bitset<pannels> > light; | ^~~~~~ a.cc:11:26: error: expected primary-expression before '>' token 11 | vector<bitset<pannels> > light; | ^ a.cc:11:28: error: 'light' was not declared in this scope 11 | vector<bitset<pannels> > light; | ^~~~~ a.cc:12:26: error: expected primary-expression before '>' token 12 | vector<bitset<pannels> > push; | ^ a.cc:12:28: error: 'push' was not declared in this scope 12 | vector<bitset<pannels> > push; | ^~~~ a.cc:31:19: error: 'lig' was not declared in this scope 31 | bitset<pannels> lig(0),score(0),get(0); | ^~~ a.cc:31:26: error: 'score' was not declared in this scope 31 | bitset<pannels> lig(0),score(0),get(0); | ^~~~~ a.cc:31:35: error: 'get' was not declared in this scope 31 | bitset<pannels> lig(0),score(0),get(0); | ^~~ a.cc:39:27: error: 'max' was not declared in this scope 39 | DP[lig.to_ulong()][0]=max((int)get.count(),DP[lig.to_ulong()][0]); | ^~~ a.cc:51:31: error: 'max' was not declared in this scope 51 | DP[lig.to_ulong()][i]=max((int)bitset<pannels>(get).count()+DP[score.to_ulong()][i-1],DP[lig.to_ulong()][i]); | ^~~ a.cc:57:11: error: 'max' was not declared in this scope 57 | ans=max(ans,DP[i][n-1]); | ^~~ a.cc:58:3: error: 'cout' was not declared in this scope 58 | cout << ans << endl; | ^~~~ a.cc:58:18: error: 'endl' was not declared in this scope 58 | cout << ans << endl; | ^~~~
s050611388
p00258
C++
#include <iostream> #include <vector> using namespace std; int popcount(unsigned i) { i = ((i & 0xaaaaaaaa) >> 1) + (i & 0x55555555); i = ((i & 0xcccccccc) >> 2) + (i & 0x33333333); i = ((i & 0xf0f0f0f0) >> 4) + (i & 0x0f0f0f0f); i = ((i & 0xff00ff00) >> 8) + (i & 0x00ff00ff); i = ((i & 0xffff0000) >> 16) + (i & 0x0000ffff); return i; } bool solve() { int N, C; if(!(cin >> N >> C)) return false; if(!N &&! C) return false; vector<int> patterns(N), press_patterns(C); for(int i = 0; i < N; ++i) { int v = 0; for(int j = 0; j < 16; ++j) { int b; cin >> b; v <<= 1; v += b; } patterns[i] = v; } for(int i = 0; i < C; ++i) { int v = 0; for(int j = 0; j < 16; ++j) { int b; cin >> b; v <<= 1; v += b; } press_patterns[i] = v; } vector<int> memo[2]; memo[0].resize(1<<16, -1); memo[1].resize(1<<16, -1); memo[0][0] = 0; for(int pat : patterns) { fill(memo[1].begin(), memo[1].end(), -1); for(int prev = 0; prev < (1<<16); ++prev) { if(memo[0][prev] == -1) continue; const int cur = pat | prev; for(int press : press_patterns) { const int np = cur & (~press); const int ns = memo[0][prev] + popcount(cur & press); memo[1][np] = max(memo[1][np], ns); } } memo[0].swap(memo[1]); } cout << *max_element(memo[0].begin(), memo[0].end()) << endl; return true; } int main() { cin.tie(0); ios::sync_with_stdio(0); while(solve()) ; return 0; }
a.cc: In function 'bool solve()': a.cc:59:14: error: 'max_element' was not declared in this scope 59 | cout << *max_element(memo[0].begin(), memo[0].end()) << endl; | ^~~~~~~~~~~
s147730084
p00259
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main_TLE_2 { public static final int SIZE = 100000; public static int[] queue = new int[SIZE + 1]; public static int tp = 0; public static int bp = 0; public static int next_index(int index){ return (index + 1) % SIZE; } public static int prev_index(int index){ return (SIZE + index - 1) % SIZE; } public static void push(int x){ queue[tp] = x; tp = next_index(tp); } public static int pop(){ int old = bp; bp = next_index(bp); return queue[old]; } public static int peek(){ return queue[bp]; } public static void del(){ bp = next_index(bp); } public static int size(){ return tp - bp; } public static boolean is_empty(){ return tp == bp; } public static void clean(){ tp = bp = 0; } public static final int ADD = -1; public static final int SUB = -2; public static final int MUL = -3; public static final int DIV = -4; public static final int KAKKO_L = -5; public static final int KAKKO_R = -6; public static interface Expr{ public int eval(int mod); } public static class Inner implements Expr{ Expr inner; public Inner(Expr inner) { super(); this.inner = inner; } @Override public int eval(int mod) { return inner.eval(mod); } @Override public String toString(){ return "(" + inner + ")"; } } public static class Plus implements Expr{ Expr left, right; public Plus(Expr left, Expr right) { super(); this.left = left; this.right = right; } @Override public int eval(int mod) { return (left.eval(mod) + right.eval(mod)) % mod; } @Override public String toString(){ return left + "+" + right; } } public static class Minus implements Expr{ Expr left, right; public Minus(Expr left, Expr right) { super(); this.left = left; this.right = right; } @Override public int eval(int mod) { return (mod + left.eval(mod) - right.eval(mod)) % mod; } @Override public String toString(){ return left + "-" + right; } } public static class Mul implements Expr{ Expr left, right; public Mul(Expr left, Expr right) { super(); this.left = left; this.right = right; } @Override public int eval(int mod) { return (left.eval(mod) * right.eval(mod)) % mod; } @Override public String toString(){ return left + "*" + right; } } public static int mod_pow(int x, int p, int mod){ if(p == 1){ return x % mod; }else if(p == 0){ return x == 1 ? 1 : 0; } if(p % 2 == 0){ int ret = mod_pow(x, p / 2, mod); return (ret * ret) % mod; }else{ return (mod_pow(x, p - 1, mod) * x) % mod; } } public static class Div implements Expr{ Expr left, right; public Div(Expr left, Expr right) { super(); this.left = left; this.right = right; } @Override public int eval(int mod) { final int right_ret = right.eval(mod); if(right_ret == 0){ throw new ArithmeticException(""); } int inv = mod_pow(right_ret, mod - 2, mod); if(inv == 0){ throw new ArithmeticException(""); } return (left.eval(mod) * inv) % mod; } @Override public String toString(){ return left + "/" + right; } } public static class Const implements Expr{ int cons; public Const(int cons){ this.cons = cons; } @Override public int eval(int mod){ return cons; } @Override public String toString(){ return cons + ""; } } //+, - public static Expr parse_1(){ Expr left = parse_2(); if(left == null){ return null; } //System.out.println("t"); while(!is_empty()){ if(!(peek() == ADD) && !(peek() == SUB)){ return left; } int type = pop(); Expr right = parse_2(); if(type == ADD){ left = new Plus(left, right); }else{ left = new Minus(left, right); } } return left; } //*, / public static Expr parse_2(){ Expr left = parse_3(); if(left == null){ return null; } while(!is_empty()){ if(!(peek() == MUL) && !(peek() == DIV)){ return left; } int type = pop(); Expr right = parse_3(); if(type == MUL){ left = new Mul(left, right); }else{ left = new Div(left, right); } } return left; } //primitive, () public static Expr parse_3(){ if(is_empty()){ return null; }else if(peek() >= 0){ return new Const(pop()); }else if(peek() == KAKKO_L){ del(); Expr expr = parse_1(); if(peek() == KAKKO_R){ del(); return new Inner(expr); }else{ return null; } } return null; } public static void add_stack(String line){ clean(); char[] input = line.toCharArray(); int count = -1; for(char c : input){ if('0' <= c && c <= '9'){ if(count == -1){ count = 0; } count *= 10; count += c - '0'; }else{ if(count != -1){ push(count); } count = -1; } switch(c){ case '+': push(ADD); break; case '-': push(SUB); break; case '*': push(MUL); break; case '/': push(DIV); break; case '(': push(KAKKO_L); break; case ')': push(KAKKO_R); break; } //System.out.println(stack); } if(count != -1){ push(count); } } public static void main(String[] args) throws IOException { //Scanner sc = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int count = 0; while(true){ String input = br.readLine(); if("0:".equals(input)){ break; } //count++; //if(count > 4){ // count = 0; // System.gc(); //} System.gc(); String[] in = input.split(":"); //String[] tokens = in[1].split(" "); //System.out.println(Arrays.toString(tokens)); //stack.clear(); /* for(int i = 0; i < tokens.length; i++){ if(tokens[i].equals("") || tokens[i].equals(" ")){ continue; } add_stack(tokens[i], stack); } */ add_stack(in[1]); //System.out.println(stack); final int mod = Integer.parseInt(in[0]); Expr node = parse_1(); try{ int result = node.eval(mod); System.out.println(node + " = " + result + " (mod " + mod + ")"); }catch(ArithmeticException e){ System.out.println("NG"); }catch(NullPointerException e){ for(int i = 0; i < size(); i++){ System.out.print(queue[i] + " "); } System.out.println(); System.err.println(input + "\n" + "\n" /*Arrays.toString(queue)*/); } } br.close(); } }
Main.java:8: error: class Main_TLE_2 is public, should be declared in a file named Main_TLE_2.java public class Main_TLE_2 { ^ 1 error
s158939390
p00259
C++
#include<iostream> using namespace std; int power(int x,int k,int p){ if(k==0)return 1; int tmp=power(x,k/2,p); tmp*=tmp; tmp%=p; if(k%2==1){tmp*=x; tmp%=p;} return tmp; } int plus(int x,int y,int p){ return (x+y)%p; } int minus(int x,int y,int p){ return (x-y+p)%p; } int mul(int x,int y,int p){ return (x*y)%p; } int div(int x,int y,int p){ return (x*power(y,p-2,p))%p; } string t = ""; int x = -1; int get() { if(t[x]=='(')return rec(); int ret = 0; while(x++) { if(t[x]-'0' < 0 || t[x]-'0' > 9) return ret; ret = (ret*10+t[x]-'0'); } } int rec() { x++; int cur = 0; int sum = 0; bool minu = false; while(1) { cur = get(); while(t[x] == '*' || t[x] == '/') { char C=t[x]; x++; int aaa=get(); if(C=='*')cur=mul(cur,aaa,p); else cur=div(cur,aaa,p); } if(t[x] == '+' || t[x] == '-') { if(minu) sum -= cur; else sum += cur; } if(t[x]==')'){ if(minu) sum -= cur; else sum += cur; return sum; } } } int main() { while(1) { string s; cin >> s; bool beg = false; int p = 0; for(int i=0;i<s.size();i++) { if(beg && s[i] != ' ') t.pb(s[i]); if(s[i] == ':') beg = true; if(!beg) p = (p*10+(s[i]-'0')); } cout<<t" = "; t.pb(')'); int res = rec(); printf("%d",res); cout<<" (mod "<<p<<")\n"; } }
a.cc: In function 'int get()': a.cc:31:29: error: 'rec' was not declared in this scope 31 | if(t[x]=='(')return rec(); | ^~~ a.cc: In function 'int rec()': a.cc:53:51: error: 'p' was not declared in this scope 53 | if(C=='*')cur=mul(cur,aaa,p); | ^ a.cc:54:46: error: 'p' was not declared in this scope 54 | else cur=div(cur,aaa,p); | ^ a.cc: In function 'int main()': a.cc:82:50: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'pb' 82 | if(beg && s[i] != ' ') t.pb(s[i]); | ^~ a.cc:86:8: error: expected ';' before string constant 86 | cout<<t" = "; | ^~~~~ | ; a.cc:87:19: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'pb' 87 | t.pb(')'); | ^~
s451106790
p00259
C++
#include <cassert> #include <cstdlib> #include <iostream> #include <sstream> using namespace std; int mod; const char *p; int mod_pow(int x, int n) { int res = 1; while(n > 0) { if(n & 1) res = (res * x) % mod; x = (x * x) % mod; n >>= 1; } return res; } int mod_inverse(int x) { return mod_pow(x, mod - 2); } int expr(); int term(); int factor(); int number(); int expr() { int res = term(); while(*p == '+' || *p == '-') { switch(*(p++)) { case '+': res = (res + term()) % mod; break; case '-': res = (res - term() + mod) % mod; break; } } return res; } int term() { int res = factor(); while(*p == '*' || *p == '/') { switch(*(p++)) { case '*': res = (res * factor()) % mod; break; case '/': const int divisor = factor(); if(divisor == 0) throw "NG"; res = (res * mod_inverse(divisor)) % mod; break; } } return res; } int factor() { if(*p == '(') { ++p; const int res = expr(); ++p; return res; } assert(isdigit(*p)); return number(); } int number() { int res = 0; while(isdigit(*p)) { res = res * 10 + *(p++) - '0'; } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); for(string input; getline(cin, input);) { const unsigned separator = input.find(':'); mod = stoi(input.substr(0, separator)); if(mod == 0) break; string s = input.substr(separator + 1); s.erase(remove(s.begin(), s.end(), ' '), s.end()); p = s.c_str(); try { ostringstream os; os << s << " = " << expr() << " (mod " << mod << ")\n"; cout << os.str(); } catch(const char *) { cout << "NG\n"; } } return EXIT_SUCCESS; }
a.cc: In function 'int main()': a.cc:86:39: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*' 86 | s.erase(remove(s.begin(), s.end(), ' '), s.end()); | ~~~~~~~^~ | | | std::__cxx11::basic_string<char>::iterator In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)' 158 | extern int remove (const char *__filename) __THROW; | ~~~~~~~~~~~~^~~~~~~~~~
s376639875
p00259
C++
#include <algorithm> #include <cctype> #include <iostream> #include <vector> #include <string> #include <sstream> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; #define reps(i,f,n) for(int i=f; i<int(n); ++i) #define rep(i,n) reps(i,0,n) int p; int expr(string& s, int& t); int inv(int n) { if(n == 0) throw 0; int r = 1; rep(i, p-2) r = (r * n) % p; return r; } int num(string& s, int& t) { if(s[t] == '('){ ++t; int v = expr(s, t); ++t; return v; } else{ int v = 0; while(isnumber(s[t])){ v = v * 10 + s[t] - '0'; ++t; } return v; } } int term2(string& s, int& t) { char c = s[t]; if(c != '*' && c != '/') return 1; ++t; int u = num(s, t); if(c == '/') u = inv(u); return (u * term2(s, t)) % p; } int term(string& s, int& t) { int u = num(s, t); return (u * term2(s, t)) % p; } int expr2(string& s, int& t) { char c = s[t]; if(c != '+' && c != '-') return 0; ++t; int u = term(s, t); if(c == '-') u *= -1; int r = (p + u + expr2(s, t)) % p; return r; } int expr(string& s, int& t) { int u = term(s, t); return (u + expr2(s, t)) % p; } string func(string str) { p = stoi(str); stringstream sstr(str.substr(str.find(':') + 1)); str = ""; for(string t; sstr >> t;){ str += t; } str += '\0'; try{ int t = 0; return str + " = " + to_string(expr(str, t)) + " (mod " + to_string(p) + ")"; } catch(...){ return "NG"; } } int main() { string str; while(getline(cin, str), str != "0:"){ cout << func(str) << endl; } }
a.cc: In function 'int num(std::string&, int&)': a.cc:40:15: error: 'isnumber' was not declared in this scope 40 | while(isnumber(s[t])){ | ^~~~~~~~
s803103081
p00259
C++
/* package whatever; // don't place package name! */ import java.util.*; import java.util.regex.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main(String[] args) { try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) { while (true) { String line = in.readLine().replaceAll(" ", ""); String[] split = line.split(":"); int p = Integer.parseInt(split[0]); if (p == 0) break; int[] rep = new int[p]; for (int i = 0; i < p; i++) { rep[i] = 1; for (int j = 0; j < p - 2; j++) { rep[i] *= i; rep[i] %= p; } } try { StringBuffer expression = new StringBuffer(split[1]); while (true) { Matcher matcher = parPattern.matcher(expression); if (!matcher.find()) break; StringBuffer buffer = new StringBuffer(); do { int val = eval(matcher.group(1), p, rep); matcher.appendReplacement(buffer, val + ""); } while (matcher.find()); matcher.appendTail(buffer); expression = buffer; } int val = eval(expression.toString(), p, rep); System.out.println(split[1]+" = " +val + " (mod " + p + ")"); } catch (IllegalArgumentException e) { System.out.println("NG"); } } } catch (IOException e) { e.printStackTrace(); } } private static Pattern parPattern = Pattern.compile("\\(([^()]*)\\)"); private static Pattern pattern2 = Pattern.compile("([+-])([^+-]+)"); private static Pattern pattern3 = Pattern.compile("([*/])([0-9]+)"); private static int eval(String expression, int p, int[] rep) { Matcher matcher = pattern2.matcher("+" + expression); int ans = 0; while (matcher.find()) { int result = eval2(matcher.group(2), p, rep) % p; if (matcher.group(1).equals("+")) { ans += result; } else { ans += p - result; } ans %= p; } return ans; } private static int eval2(String expression, int p, int[] rep) { Matcher matcher = pattern3.matcher("*" + expression); int ans = 1; while (matcher.find()) { int num = Integer.parseInt(matcher.group(2)); if (matcher.group(1).equals("*")) { ans *= num; } else { if (num == 0) throw new IllegalArgumentException(); ans *= rep[num]; } ans %= p; } return ans; } }
a.cc:3:1: error: 'import' does not name a type 3 | import java.util.*; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.regex.*; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.lang.*; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.io.*; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: expected unqualified-id before 'public' 9 | public class Main | ^~~~~~
s411457144
p00259
C++
#line 0 "cmacro.cpp" #include <bits/stdc++.h> using namespace std; #define in , #define esc_paren(...) __VA_ARGS__ #define pp_empty(...) #define pp_cat_i(x, y) x ## y #define pp_cat(x, y) pp_cat_i(x, y) #define pp_inc0 1 #define pp_inc1 2 #define pp_inc2 3 #define pp_inc3 4 #define pp_inc4 5 #define pp_inc5 6 #define pp_inc6 7 #define pp_inc7 8 #define pp_inc8 9 #define pp_inc(i) pp_cat(pp_inc, i) #define pp_arg10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, ...) _9 #define pp_has_comma(...) pp_arg10(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 0) #define pp_trigger_paren(...) , #define pp_is_empty(...) \ pp_is_empty1( \ pp_has_comma(__VA_ARGS__), \ pp_has_comma(pp_trigger_paren __VA_ARGS__), \ pp_has_comma(__VA_ARGS__()), \ pp_has_comma(pp_trigger_paren __VA_ARGS__()) \ ) #define pp_paste5(_0, _1, _2, _3, _4) _0 ## _1 ## _2 ## _3 ## _4 #define pp_is_empty1(_0, _1, _2, _3) pp_has_comma(pp_paste5(pp_is_empty_case_, _0, _1, _2, _3)) #define pp_is_empty_case_0001 , #define pp_is_one(...) pp_is_one_(__VA_ARGS__, pp_one_seq) #define pp_is_one_(...) pp_is_one_n(__VA_ARGS__) #define pp_is_one_n(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10, N, ...) N #define pp_one_seq 0,0,0,0,0,0,0,0,0,1,0 #define pp_narg(...) \ pp_narg_(__VA_ARGS__, pp_narg_seq) #define pp_narg_(...) \ pp_narg_n(__VA_ARGS__) #define pp_narg_n( \ _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \ _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ _61,_62,_63,n,...) n #define pp_narg_seq \ 63,62,61,60, \ 59,58,57,56,55,54,53,52,51,50, \ 49,48,47,46,45,44,43,42,41,40, \ 39,38,37,36,35,34,33,32,31,30, \ 29,28,27,26,25,24,23,22,21,20, \ 19,18,17,16,15,14,13,12,11,10, \ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 #define pp_if_0(x, y) y #define pp_if_1(x, y) x #define pp_if(cond, x, y) pp_cat(pp_if_, cond)(x, y) #define pp_foreach_i9(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i8(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i7(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i6(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i5(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i4(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i3(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i2(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i1(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i0(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i(i, f, ...) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach(f, ...) pp_foreach_i(0, f, __VA_ARGS__) typedef long long ll; #define down_queue(x) priority_queue<x> #define up_queue(x) priority_queue<x, vector<x>, greater<x>> #define all(x) x.begin(), x.end() #define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++) #define digit(x) ((int)log10((double)(x)) + 1) #define mp(x,y) make_pair(x,y) #define pb(x) push_back(x) #define pf(x) push_front(x) #define vec_cpy(to,from) copy(all(to),back_inserter(from)) #define ary_cpy(to,from) memcpy(to, from, sizeof(from)) #define MOD 1000000007 #define INF 999999999 struct RepIterator { int i; RepIterator() : i(0) {} RepIterator(int n) : i(n) {} bool operator ==(const RepIterator& rhs) { return i == rhs.i; } bool operator !=(const RepIterator& rhs) { return i != rhs.i; } int operator *() { return i; } RepIterator operator ++() {i++; return *this; }; }; struct RepLoop { int i; RepLoop(int n) : i(n) {} RepIterator begin() { return RepIterator(); } RepIterator end() { return RepIterator(i); } }; template <typename T> struct rep_range { static T range(T v) { return v; } }; template <> struct rep_range<int> { static RepLoop range(int n) { return RepLoop(n); } }; #define rep(...) rep1(rep2, (__VA_ARGS__)) #define rep1(X, A) X A #define rep2(i, ...) pp_if(pp_is_one(__VA_ARGS__), rep_len1(i, __VA_ARGS__), rep3(i, __VA_ARGS__)) #define rep_len1(i, end, ...) for (auto i : rep_range<decltype(end)>::range(end)) #define rep3(i, iter, ...) rep4(rep5, (iter, i, esc_paren __VA_ARGS__)) #define rep4(X, A) X A #define rep5(iter, ...) iter(__VA_ARGS__) #define up up_iter , #define up_iter3(i, start, end) for (int i = start; i < end; i++) #define up_iter4(i, start, end, up) for (int i = start; i < end; i += up) #define up_iter(...) pp_cat(up_iter, pp_narg(__VA_ARGS__))(__VA_ARGS__) #define down down_iter , #define down_iter2(i, end) for(int i = end-1; i >= 0; i--) #define down_iter3(i, start, end) for (int i = end-1; i >= start; i--) #define down_iter4(i, start, end, down) for (int i = end-1; i >= start; i -= down) #define down_iter(...) pp_cat(down_iter, pp_narg(__VA_ARGS__))(__VA_ARGS__) #define pp_init2(cnt, body) struct _InitStruct ## cnt { _InitStruct ## cnt() { body } } _initstruct ## cnt; #define pp_init1(f, cnt, body) f(cnt, body) #define pp_init(body) pp_init1(pp_init2, __COUNTER__, body) #define init_array(arr, N, val) pp_init(rep (i in N) { arr[i] = val; }) #define iota_array(arr, N, start) pp_init(rep (i in N) { arr[i] = start + i; }) #define debug_var_elem(v) << #v << "=" << v << " " #ifdef DEBUG #define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl #define debug_var(...) cout << "L" << __LINE__ << ": " pp_foreach(debug_var_elem, __VA_ARGS__) << endl #define debug_time2(i, e) auto start ## i = clock(); e; auto end ## i = clock(); cout << (double)(end ## i - start ## i) << "ms" << endl; #define debug_time1(f, i, e) f(i, e) #define debug_time(e) debug_time1(debug_time2, __COUNTER__, e) #else #define debug_echo(e) #define debug_var(...) #define debug_time(e) #endif #define pp_gen_field(list) pp_gen_field1 list #define pp_gen_field1(name, val) decltype(val) name; #define pp_gen_init(list) pp_gen_init1 list #define pp_gen_init1(name, val) ,val #define pp_gen_find_set_wrap(ufnodename) ufnodename pp_gen_find_set #define pp_gen_find_set(list) pp_gen_find_set1 list #define pp_gen_find_set1(name, val) \ find_set_ ## name(int x, decltype(val) v) { \ if (nodes[x].parent == x) { \ nodes[x].name = v; \ return nodes[x]; \ } else { \ return nodes[x] = find_set_ ## name(nodes[x].parent, v); \ } \ } #define pp_gen_unite_set(list) pp_gen_unite_set1 list #define pp_gen_unite_set1(name, val) \ if (nodes[x].name == val) { \ find_set_ ## name(x, find(y).name); \ } \ if (nodes[y].name == val) { \ find_set_ ## name(y, find(x).name); \ } #define def_unionfind(ufname, ufnodename, ...) \ struct ufnodename { \ int parent; \ pp_foreach(pp_gen_field, __VA_ARGS__) \ }; \ struct ufname { \ vector<ufnodename> nodes; \ vector<int> rank; \ ufname(int n) : nodes(n+1), rank(n+1) { \ rep (i in n) { \ nodes[i] = ufnodename{i pp_foreach(pp_gen_init, __VA_ARGS__)}; \ rank[i] = 0; \ } \ } \ ufnodename find(int x) { \ if (nodes[x].parent == x) { \ return nodes[x]; \ } else { \ return nodes[x] = find(nodes[x].parent); \ } \ } \ pp_foreach(pp_gen_find_set_wrap(ufnodename), __VA_ARGS__) \ void unite(int x, int y) { \ x = find(x).parent; \ y = find(y).parent; \ if (x == y) return; \ if (rank[x] < rank[y]) { \ pp_foreach(pp_gen_unite_set, __VA_ARGS__); \ nodes[x].parent = y; \ } else { \ pp_foreach(pp_gen_unite_set, __VA_ARGS__); \ nodes[y].parent = x; \ if (rank[x] == rank[y]) rank[x]++; \ } \ } \ bool same(int x, int y) { \ return find(x).parent == find(y).parent; \ } \ } ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;} ll lcm(ll a,ll b){return a / gcd(a,b) * b;} #define def_varargs(name, f) \ template<typename First> \ inline First name(First first) { return first; } \ template<typename First, typename... Rest> \ inline First name(First first, Rest... rest) { return f(first, name(rest...)); } #line 1 "procon.cpp" enum OpNodeKind { opAdd, opSub, opMul, opDiv, opSP, opEP, opVal }; struct OpNode { OpNodeKind kind; ll val; OpNode(OpNodeKind k) : kind(k) {} OpNode(ll v) : kind(opVal), val(v) {} }; void deletespace(string& s) { size_t pos; while ((pos = s.find_first_of(" ")) != string::npos) { s.erase(pos, 1); } } int priority(OpNodeKind kind) { if (kind == opAdd || kind == opSub) { return 1; } else if (kind == opMul || kind == opDiv) { return 2; } else { assert(false); } } OpNodeKind getkind(char c) { if (c == '(') { return opSP; } else if (c == ')') { return opEP; } else if (c == '+') { return opAdd; } else if (c == '-') { return opSub; } else if (c == '*') { return opMul; } else if (c == '/') { return opDiv; } else { assert(false); } } bool is_num(char c) { return '0' <= c && c <= '9'; } ll parsenum(string s, int& pos) { string n; while ((size_t)pos < s.size() && is_num(s[pos])) { n += s[pos]; pos++; } return (ll)stoi(n); } OpNode term(string s, int& pos) { if (is_num(s[pos])) { OpNode ret(parsenum(s, pos)); return ret; } else { OpNode ret(getkind(s[pos])); pos++; return ret; } } vector<OpNode> revpoland(string s, int& pos) { stack<OpNode> st; vector<OpNode> res; res.reserve(100000); while ((size_t)pos < s.size()) { OpNode curop = term(s, pos); if (curop.kind == opVal) { res.pb(curop); } else if (curop.kind == opSP) { st.push(curop); } else if (curop.kind == opEP) { while (!st.empty()) { if (st.top().kind == opSP) { st.pop(); break; } res.pb(st.top()); st.pop(); } } else { if (st.empty()) { st.push(curop); } else if (st.top().kind == opSP) { st.push(curop); } else if (priority(st.top().kind) < priority(curop.kind)) { st.push(curop); } else { while (!st.empty() && st.top().kind != opSP && priority(st.top().kind) >= priority(curop.kind)) { res.pb(st.top()); st.pop(); } st.push(curop); } } } while (!st.empty()) res.pb(st.top()), st.pop(); return res; } ll calcop(ll p, OpNode op, ll lres, ll rres) { if (op.kind == opAdd) { ll res = lres + rres; return res % p; } else if (op.kind == opSub) { ll m = p - (rres % p); ll res = lres + m; return res % p; } else if (op.kind == opMul) { ll res = lres * rres; return res % p; } else if (op.kind == opDiv) { if (rres == 0) return -1; if (rres == 1) return lres % p; ll m = p-2; ll x = 1; ll k = rres; while (m) { if (m&1) { x *= k; x %= p; } m >>= 1; k *= k; k %= p; } ll n = lres * x; return n % p; } else { assert(false); } } ll calc(ll p, vector<OpNode> nodes) { stack<ll> st; rep (e in nodes) { if (e.kind == opVal) { st.push(e.val); } else { ll r = st.top(); st.pop(); ll l = st.top(); st.pop(); ll res = calcop(p, e, l, r); if (res == -1) return -1; st.push(res); } } return st.top(); } int main() { ll p; char colon; while (cin >> p && p) { cin >> colon; string s; getline(cin, s); debug_time(deletespace(s)); int pos = 0; debug_time(vector<OpNode> revp = revpoland(s, pos)); debug_time(ll res = calc(p, revp)); if (res == -1) { cout << "NG" << endl; } else { cout << s << " = " << res << " (mod " << p << ")" << endl; } } }
procon.cpp: In function 'int main()': procon.cpp:172:9: error: 'res' was not declared in this scope; did you mean 'rep'?
s787678740
p00259
C++
#include <iostream> #include <vector> #include <cmath> // ?????? #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--) #define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end()) typedef long long ll; using namespace std; long long inv_mod(long long n, long long mod) { long long a = n % mod, b = mod - 2, ret = 1; while (b > 0) { if (b & 1) ret = (ret * a) % mod; a = (a * a) % mod; b >>= 1; } return ret; } struct FourArithmeticOperationParser { int pos; bool div_zero; string Formula; long long mod; const long long INF = 0x7fffffffffffffff; long long operator () (string F, long long m) { pos = 0; div_zero = false; Formula = F; mod = m; long long ret = expr(); return div_zero ? INF : ret; } long long number() { long long ret = 0; while (pos != Formula.size()) { if (Formula[pos] < '0' || Formula[pos] > '9') { break; } else { ret *= 10; ret += (Formula[pos++] - '0'); } } return ret % mod; } long long expr() { long long x = term(); while (pos < Formula.size()) { switch (Formula[pos]) { case '+': pos++; x += term(); continue; case '-': pos++; x -= term(); continue; } break; } return x % mod; } long long term() { long long x = factor(); while (pos < Formula.size()) { switch (Formula[pos]) { case '*': pos++; x *= factor(); continue; case '/': pos++; long long div = factor(); if (div == 0) { div_zero = true; } else { div = inv_mod(div, mod); x *= div; x %= mod; } continue; } break; } return x % mod; } long long factor() { if (pos < Formula.size()) { if (Formula[pos] == '(') { pos++; long long ret = expr(); if (Formula[pos] == ')') { pos++; } return ret; } } return number(); } }; int main() { string mod; string f; while (true) { cin >> mod; long long m = stoi(mod.substr(0, mod.size() - 1)); if (m == 0) break; getline(cin, f); REMOVE(f, ' '); ll ans = FourArithmeticOperationParser()(f, m); if (ans == FourArithmeticOperationParser().INF) cout << "NG" << endl; else { ans %= m; ans = (ans + m * 2) % m; cout << f << " = " << ans << " (mod " << m << ")" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:9:53: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*' 9 | #define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end()) | ~~~~~~~~~~~^~ | | | std::__cxx11::basic_string<char>::iterator a.cc:124:9: note: in expansion of macro 'REMOVE' 124 | REMOVE(f, ' '); | ^~~~~~ In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)' 158 | extern int remove (const char *__filename) __THROW; | ~~~~~~~~~~~~^~~~~~~~~~
s846810579
p00259
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <cfloat> #include <ctime> #include <cassert> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <numeric> #include <list> #include <iomanip> #include <fstream> #include <bitset> &#160;&#160;&#160;&#160; using namespace std; &#160;&#160;&#160;&#160; &#160;&#160; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it) #define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it) #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define CL(arr, val) memset(arr, val, sizeof(arr)) #define COPY(dest, src) memcpy(dest, src, sizeof(dest)) #define ten(n) ((long long)(1e##n)) #define bin(n) (1LL << (n)) #define erep(i, n) for (int i = 0; i <= (int)(n); ++i) #define revrep(i, n) for (int i = (n); i >= 0; --i) #define pb push_back &#160; template <class T> void chmax(T& a, const T& b) { a = max(a, b); } template <class T> void chmin(T& a, const T& b) { a = min(a, b); } &#160; template <class T> T round_up(T a, T b) { return (a + b - 1) / b; } &#160; template <class T> void uniq(vector<T>& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); } &#160;&#160; template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); } template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; } &#160;&#160;&#160; template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; } &#160;&#160;&#160; template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; } template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; } template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {&#160;&#160;&#160; if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; } &#160;&#160;&#160;&#160; template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; } template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; } &#160; void fix_pre(int n) { cout.setf(ios::fixed, ios::floatfield); cout.precision(10); } void fast_io() { cin.tie(0); ios::sync_with_stdio(false); } #define trace(x) (cout << #x << ": " << (x) << endl) &#160;&#160; bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; } &#160;&#160; &#160; typedef long long ll; typedef pair<int, int> pint; &#160;&#160; // y(v): v>^<&#160; y(^): ^>v< const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { 1, 0, -1, 0 }; &#160; const double PI = acos(-1.0); &#160; #define F first #define S second &#160; &#160; &#160; vector<string> split(string str, const string& deli_chars) { &#160;&#160;&#160;&#160;for (int i = 0; i < str.size(); ++i) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; &#160;&#160;&#160;&#160;stringstream ss(str); &#160;&#160;&#160;&#160;vector<string> res; &#160;&#160;&#160;&#160;for (string s; ss >> s; ) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res.push_back(s); &#160;&#160;&#160;&#160;return res; } ll ext_gcd(ll a, ll b, ll &x, ll &y) { &#160;&#160;&#160;&#160;if (b) &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ll g = ext_gcd(b, a % b, y, x); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;y -= (a / b) * x; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return g; &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;else &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;x = 1, y = 0; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return a; &#160;&#160;&#160;&#160;} } ll mod_inverse(ll a, ll mod) { &#160;&#160;&#160;&#160;ll x, y; &#160;&#160;&#160;&#160;if (ext_gcd((a + mod) % mod, mod, x, y) == 1) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return (mod + x % mod) % mod; &#160;&#160;&#160;&#160;else &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return 0; } &#160; &#160; ll mod; bool error; int pos; string s; void init(const string& s, int p) { &#160;&#160;&#160;&#160;::s = s; &#160;&#160;&#160;&#160;pos = 0; &#160;&#160;&#160;&#160;error = false; &#160;&#160;&#160;&#160;mod = p; } ll expr(); ll factor(); ll term(); ll add(ll a, ll b) { &#160;&#160;&#160;&#160;return (a + b) % mod; } ll sub(ll a, ll b) { &#160;&#160;&#160;&#160;return (a - b + mod) % mod; } ll mul(ll a, ll b) { &#160;&#160;&#160;&#160;return a * b % mod; } ll divi(ll a, ll b) { &#160;&#160;&#160;&#160;if (b == 0) &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;error = true; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return 0; &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;return a * mod_inverse(b, mod) % mod; } ll expr() { &#160;&#160;&#160;&#160;ll res = factor(); &#160;&#160;&#160;&#160;while (pos < s.size() && s[pos] == '+' || s[pos] == '-') &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (s[pos] == '+') &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;++pos; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res = add(res, factor()); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;++pos; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res = sub(res, factor()); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;return res; } ll factor() { &#160;&#160;&#160;&#160;ll res = term(); &#160;&#160;&#160;&#160;while (s[pos] == '*' || s[pos] == '/') &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (s[pos] == '*') &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;++pos; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res = mul(res, term()); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;++pos; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res = divi(res, term()); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;return res; } ll term() { &#160;&#160;&#160;&#160;if (s[pos] == '(') &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;++pos; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ll res = expr(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;++pos; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return res; &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;else &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ll res = 0; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;while (isdigit(s[pos])) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res = res * 10 + (s[pos] - '0'); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;++pos; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res %= mod; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return res; &#160;&#160;&#160;&#160;} } int main() { &#160;&#160;&#160;&#160;string in; &#160;&#160;&#160;&#160;while (getline(cin , in), in[0] != '0') &#160;&#160;&#160;&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;vector<string> spl = split(in, " "); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;int p = to_T<int>(spl[0].substr(0, spl[0].size() - 1)); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;string s = accumulate(spl.begin()+1, spl.end(), string()); &#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;init(s, p); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ll res = expr(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (error) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;cout << "NG" << endl; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;printf("%s = %lld (mod %d)\n", s.c_str(), res, p); &#160;&#160;&#160;&#160;} }
a.cc:27:2: error: stray '#' in program 27 | &#160;&#160;&#160;&#160; | ^ a.cc:27:8: error: stray '#' in program 27 | &#160;&#160;&#160;&#160; | ^ a.cc:27:14: error: stray '#' in program 27 | &#160;&#160;&#160;&#160; | ^ a.cc:27:20: error: stray '#' in program 27 | &#160;&#160;&#160;&#160; | ^ a.cc:29:2: error: stray '#' in program 29 | &#160;&#160;&#160;&#160; | ^ a.cc:29:8: error: stray '#' in program 29 | &#160;&#160;&#160;&#160; | ^ a.cc:29:14: error: stray '#' in program 29 | &#160;&#160;&#160;&#160; | ^ a.cc:29:20: error: stray '#' in program 29 | &#160;&#160;&#160;&#160; | ^ a.cc:30:2: error: stray '#' in program 30 | &#160;&#160; | ^ a.cc:30:8: error: stray '#' in program 30 | &#160;&#160; | ^ a.cc:43:2: error: stray '#' in program 43 | &#160; | ^ a.cc:46:2: error: stray '#' in program 46 | &#160; | ^ a.cc:48:2: error: stray '#' in program 48 | &#160; | ^ a.cc:50:2: error: stray '#' in program 50 | &#160;&#160; | ^ a.cc:50:8: error: stray '#' in program 50 | &#160;&#160; | ^ a.cc:53:2: error: stray '#' in program 53 | &#160;&#160;&#160; | ^ a.cc:53:8: error: stray '#' in program 53 | &#160;&#160;&#160; | ^ a.cc:53:14: error: stray '#' in program 53 | &#160;&#160;&#160; | ^ a.cc:55:2: error: stray '#' in program 55 | &#160;&#160;&#160; | ^ a.cc:55:8: error: stray '#' in program 55 | &#160;&#160;&#160; | ^ a.cc:55:14: error: stray '#' in program 55 | &#160;&#160;&#160; | ^ a.cc:58:142: error: stray '#' in program 58 | template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {&#160;&#160;&#160; if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; } | ^ a.cc:58:148: error: stray '#' in program 58 | template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {&#160;&#160;&#160; if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; } | ^ a.cc:58:154: error: stray '#' in program 58 | template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {&#160;&#160;&#160; if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; } | ^ a.cc:59:2: error: stray '#' in program 59 | &#160;&#160;&#160;&#160; | ^ a.cc:59:8: error: stray '#' in program 59 | &#160;&#160;&#160;&#160; | ^ a.cc:59:14: error: stray '#' in program 59 | &#160;&#160;&#160;&#160; | ^ a.cc:59:20: error: stray '#' in program 59 | &#160;&#160;&#160;&#160; | ^ a.cc:62:2: error: stray '#' in program 62 | &#160; | ^ a.cc:66:2: error: stray '#' in program 66 | &#160;&#160; | ^ a.cc:66:8: error: stray '#' in program 66 | &#160;&#160; | ^ a.cc:68:2: error: stray '#' in program 68 | &#160;&#160; | ^ a.cc:68:8: error: stray '#' in program 68 | &#160;&#160; | ^ a.cc:69:2: error: stray '#' in program 69 | &#160; | ^ a.cc:72:2: error: stray '#' in program 72 | &#160;&#160; | ^ a.cc:72:8: error: stray '#' in program 72 | &#160;&#160; | ^ a.cc:76:2: error: stray '#' in program 76 | &#160; | ^ a.cc:78:2: error: stray '#' in program 78 | &#160; | ^ a.cc:81:2: error: stray '#' in program 81 | &#160; | ^ a.cc:82:2: error: stray '#' in program 82 | &#160; | ^ a.cc:83:2: error: stray '#' in program 83 | &#160; | ^ a.cc:86:2: error: stray '#' in program 86 | &#160;&#160;&#160;&#160;for (int i = 0; i < str.size(); ++i) | ^ a.cc:86:8: error: stray '#' in program 86 | &#160;&#160;&#160;&#160;for (int i = 0; i < str.size(); ++i) | ^ a.cc:86:14: error: stray '#' in program 86 | &#160;&#160;&#160;&#160;for (int i = 0; i < str.size(); ++i) | ^ a.cc:86:20: error: stray '#' in program 86 | &#160;&#160;&#160;&#160;for (int i = 0; i < str.size(); ++i) | ^ a.cc:87:2: error: stray '#' in program 87 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) | ^ a.cc:87:8: error: stray '#' in program 87 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) | ^ a.cc:87:14: error: stray '#' in program 87 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) | ^ a.cc:87:20: error: stray '#' in program 87 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) | ^ a.cc:87:26: error: stray '#' in program 87 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) | ^ a.cc:87:32: error: stray '#' in program 87 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) | ^ a.cc:87:38: error: stray '#' in program 87 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) | ^ a.cc:87:44: error: stray '#' in program 87 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (deli_chars.find(str[i]) != string::npos) | ^ a.cc:88:2: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:8: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:14: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:20: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:26: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:32: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:38: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:44: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:50: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:56: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:62: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:88:68: error: stray '#' in program 88 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;str[i] = ' '; | ^ a.cc:89:2: error: stray '#' in program 89 | &#160;&#160;&#160;&#160;stringstream ss(str); | ^ a.cc:89:8: error: stray '#' in program 89 | &#160;&#160;&#160;&#160;stringstream ss(str); | ^ a.cc:89:14: error: stray '#' in program 89 | &#160;&#160;&#160;&#160;stringstream ss(str); | ^ a.cc:89:20: error: stray '#' in program 89 | &#160;&#160;&#160;&#160;stringstream ss(str); | ^ a.cc:90:2: error: stray '#' in program 90 | &#160;&#160;&#160;&#160;vector<string> res; | ^ a.cc:90:8: error: stray '#' in program 90 | &#160;&#160;&#160;&#160;vector<string> res; | ^ a.cc:90:14: error: stray '#' in program 90 | &#160;&#160;&#160;&#160;vector<string> res; | ^ a.cc:90:20: error: stray '#' in program 90 | &#160;&#160;&#160;&#160;vector<string> res; | ^ a.cc:91:2: error: stray '#' in program 91 | &#160;&#160;&#160;&#160;for (string s; ss >> s; ) | ^ a.cc:91:8: error: stray '#' in program 91 | &#160;&#160;&#160;&#160;for (string s; ss >> s; ) | ^ a.cc:91:14: error: stray '#' in program 91 | &#160;&#160;&#160;&#160;for (string s; ss >> s; ) | ^ a.cc:91:20: error: stray '#' in program 91 | &#160;&#160;&#160;&#160;for (string s; ss >> s; ) | ^ a.cc:92:2: error: stray '#' in program 92 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res.push_back(s); | ^ a.cc:92:8: error: stray '#' in program 92 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res.push_back(s); | ^ a.cc:92:14: error: stray '#' in program 92 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;res.push_back(s); | ^ a.cc:92:20: error: stray '#' in pr
s089113821
p00259
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <cfloat> #include <ctime> #include <cassert> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <numeric> #include <list> #include <iomanip> #include <fstream> #include <bitset> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it) #define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it) #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define CL(arr, val) memset(arr, val, sizeof(arr)) #define COPY(dest, src) memcpy(dest, src, sizeof(dest)) #define ten(n) ((long long)(1e##n)) #define bin(n) (1LL << (n)) #define erep(i, n) for (int i = 0; i <= (int)(n); ++i) #define revrep(i, n) for (int i = (n); i >= 0; --i) #define pb push_back template <class T> void chmax(T& a, const T& b) { a = max(a, b); } template <class T> void chmin(T& a, const T& b) { a = min(a, b); } template <class T> T round_up(T a, T b) { return (a + b - 1) / b; } template <class T> void uniq(vector<T>& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); } template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); } template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; } template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; } template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; } template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; } template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; } template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; } template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; } void fix_pre(int n) { cout.setf(ios::fixed, ios::floatfield); cout.precision(10); } void fast_io() { cin.tie(0); ios::sync_with_stdio(false); } #define trace(x) (cout << #x << ": " << (x) << endl) bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; } typedef long long ll; typedef pair<int, int> pint; // y(v): v>^< y(^): ^>v< const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { 1, 0, -1, 0 }; const double PI = acos(-1.0); #define F first #define S second vector<string> split(string str, const string& deli_chars) { for (int i = 0; i < str.size(); ++i) if (deli_chars.find(str[i]) != string::npos) str[i] = ' '; stringstream ss(str); vector<string> res; for (string s; ss >> s; ) res.push_back(s); return res; } ll ext_gcd(ll a, ll b, ll &x, ll &y) { if (b) { ll g = ext_gcd(b, a % b, y, x); y -= (a / b) * x; return g; } else { x = 1, y = 0; return a; } } ll mod_inverse(ll a, ll mod) { ll x, y; if (ext_gcd((a + mod) % mod, mod, x, y) == 1) return (mod + x % mod) % mod; else return 0; } ll mod; bool error; int pos; string s; void init(const string& s, int p) { ::s = s; pos = 0; error = false; mod = p; } ll expr(); ll factor(); ll term(); ll add(ll a, ll b) { return (a + b) % mod; } ll sub(ll a, ll b) { return (a - b + mod) % mod; } ll mul(ll a, ll b) { return a * b % mod; } ll divi(ll a, ll b) { if (b == 0) { error = true; return 0; } return a * mod_inverse(b, mod) % mod; } ll expr() { ll res = factor(); while (pos < s.size() && s[pos] == '+' || s[pos] == '-') { if (s[pos] == '+') { ++pos; res = add(res, factor()); } else { ++pos; res = sub(res, factor()); } } return res; } ll factor() { ll res = term(); while (s[pos] == '*' || s[pos] == '/') { if (s[pos] == '*') { ++pos; res = mul(res, term()); } else { ++pos; res = divi(res, term()); } } return res; } ll term() { if (s[pos] == '(') { ++pos; ll res = expr(); ++pos; return res; } else { ll res = 0; while (isdigit(s[pos])) { res = res * 10 + (s[pos] - '0'); ++pos; res %= mod; } return res; } } int main() { string in; while (getline(cin , in), in[0] != '0') { vector<string> spl = split(in, " "); int p = to_T<int>(spl[0].substr(0, spl[0].size() - 1)); string s = accumulate(spl.begin()+1, spl.end(), string()); s.erase(remove(all(s)), s.end())); init(s, p); ll res = expr(); if (error) cout << "NG" << endl; else printf("%s = %lld (mod %d)\n", s.c_str(), res, p); } }
a.cc: In function 'int main()': a.cc:219:16: error: no matching function for call to 'remove(std::__cxx11::basic_string<char>::iterator, std::__cxx11::basic_string<char>::iterator)' 219 | s.erase(remove(all(s)), s.end())); | ~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:86, from a.cc:16: /usr/include/c++/14/pstl/glue_algorithm_defs.h:224:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::remove(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 224 | remove(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:224:1: note: candidate expects 4 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:788:5: note: candidate: 'template<class _FIter, class _Tp> _FIter std::remove(_FIter, _FIter, const _Tp&)' 788 | remove(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:788:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/cstdio:42, from a.cc:1: /usr/include/stdio.h:158:12: note: candidate: 'int remove(const char*)' 158 | extern int remove (const char *__filename) __THROW; | ^~~~~~ /usr/include/stdio.h:158:12: note: candidate expects 1 argument, 2 provided
s050528497
p00259
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <cfloat> #include <ctime> #include <cassert> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <numeric> #include <list> #include <iomanip> #include <fstream> #include <bitset> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it) #define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it) #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define CL(arr, val) memset(arr, val, sizeof(arr)) #define COPY(dest, src) memcpy(dest, src, sizeof(dest)) #define ten(n) ((long long)(1e##n)) #define bin(n) (1LL << (n)) #define erep(i, n) for (int i = 0; i <= (int)(n); ++i) #define revrep(i, n) for (int i = (n); i >= 0; --i) #define pb push_back template <class T> void chmax(T& a, const T& b) { a = max(a, b); } template <class T> void chmin(T& a, const T& b) { a = min(a, b); } template <class T> T round_up(T a, T b) { return (a + b - 1) / b; } template <class T> void uniq(vector<T>& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); } template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); } template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; } template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; } template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; } template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; } template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; } template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; } template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; } void fix_pre(int n) { cout.setf(ios::fixed, ios::floatfield); cout.precision(10); } void fast_io() { cin.tie(0); ios::sync_with_stdio(false); } #define trace(x) (cout << #x << ": " << (x) << endl) bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; } typedef long long ll; typedef pair<int, int> pint; // y(v): v>^< y(^): ^>v< const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { 1, 0, -1, 0 }; const double PI = acos(-1.0); #define F first #define S second vector<string> split(string str, const string& deli_chars) { for (int i = 0; i < str.size(); ++i) if (deli_chars.find(str[i]) != string::npos) str[i] = ' '; stringstream ss(str); vector<string> res; for (string s; ss >> s; ) res.push_back(s); return res; } ll ext_gcd(ll a, ll b, ll &x, ll &y) { if (b) { ll g = ext_gcd(b, a % b, y, x); y -= (a / b) * x; return g; } else { x = 1, y = 0; return a; } } ll mod_inverse(ll a, ll mod) { ll x, y; if (ext_gcd((a + mod) % mod, mod, x, y) == 1) return (mod + x % mod) % mod; else return 0; } ll mod; bool error; int pos; string s; void init(const string& s, int p) { ::s = s; pos = 0; error = false; mod = p; } ll expr(); ll factor(); ll term(); ll add(ll a, ll b) { return (a + b) % mod; } ll sub(ll a, ll b) { return (a - b + mod) % mod; } ll mul(ll a, ll b) { return a * b % mod; } ll divi(ll a, ll b) { if (b == 0) { error = true; return 0; } return a * mod_inverse(b, mod) % mod; } ll expr() { ll res = factor(); while (pos < s.size() && s[pos] == '+' || s[pos] == '-') { if (s[pos] == '+') { ++pos; res = add(res, factor()); } else { ++pos; res = sub(res, factor()); } } return res; } ll factor() { ll res = term(); while (s[pos] == '*' || s[pos] == '/') { if (s[pos] == '*') { ++pos; res = mul(res, term()); } else { ++pos; res = divi(res, term()); } } return res; } ll term() { if (s[pos] == '(') { ++pos; ll res = expr(); ++pos; return res; } else { ll res = 0; while (isdigit(s[pos])) { res = res * 10 + (s[pos] - '0'); ++pos; res %= mod; } return res; } } int main() { string in; while (getline(cin , in), in[0] != '0') { vector<string> spl = split(in, " "); int p = to_T<int>(spl[0].substr(0, spl[0].size() - 1)); string s = accumulate(spl.begin()+1, spl.end(), string()); s.erase(remove(all(s)), s.end()); init(s, p); ll res = expr(); if (error) cout << "NG" << endl; else printf("%s = %lld (mod %d)\n", s.c_str(), res, p); } }
a.cc: In function 'int main()': a.cc:219:16: error: no matching function for call to 'remove(std::__cxx11::basic_string<char>::iterator, std::__cxx11::basic_string<char>::iterator)' 219 | s.erase(remove(all(s)), s.end()); | ~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/algorithm:86, from a.cc:16: /usr/include/c++/14/pstl/glue_algorithm_defs.h:224:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::remove(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 224 | remove(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:224:1: note: candidate expects 4 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:788:5: note: candidate: 'template<class _FIter, class _Tp> _FIter std::remove(_FIter, _FIter, const _Tp&)' 788 | remove(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:788:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/cstdio:42, from a.cc:1: /usr/include/stdio.h:158:12: note: candidate: 'int remove(const char*)' 158 | extern int remove (const char *__filename) __THROW; | ^~~~~~ /usr/include/stdio.h:158:12: note: candidate expects 1 argument, 2 provided
s590414429
p00259
C++
#include <iostream> #include <cstdio> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <cstring> #include <sstream> #include <stack> #include <climits> #include <deque> #include <bitset> #include <cassert> #include <ctime> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int dy[]={-1,0,1,0},dx[]={0,1,0,-1}; // adjust problem by problem const double EPS=1e-8; const double PI=acos(-1.0); #ifdef __GNUC__ int popcount(int n){return __builtin_popcount(n);} int popcount(ll n){return __builtin_popcountll(n);} #endif #ifndef __GNUC__ template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;} #endif template<class T>int SIZE(T a){return a.size();} template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();} template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;} template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);} template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;} template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}} bool EQ(double a,double b){return abs(a-b)<EPS;} void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);} vector<string> split(string str,char del){ vector<string> res; for(int i=0,s=0;i<SIZE(str);i++){ if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;} else if(i==SIZE(str)-1){res.push_back(str.substr(s));} } return res; } int P; // O(logn)で繰り返し二乗法によりnum^p%modを計算 ll mod_pow(ll num,ll p,ll mod){ ll mul=num; ll res=1; while(p){ if(p%2)res=(res*mul)%mod; p/=2; mul=(mul*mul)%mod; } return res; } // fermerの小定理を用いてmodの割算を計算 ll div_mod(ll num,ll mod){ return mod_pow(num,mod-2,mod); } int analysis(string &s,int head,int tail){ bool isNumber=true; for(int i=head;i<=tail;i++){ if(!(s[i]>='0'&&s[i]<='9')){ isNumber=false; break; } } if(isNumber){ int num=0; for(int i=head;i<=tail;i++)num=num*10+(s[i]-'0'); return num; } else{ if(s[head]=='('){ int cnt=1; bool ok=true; for(int i=head;i<=tail;i++){ if(s[i]=='(')cnt++; else if(s[i]==')')cnt--; if(cnt==0){ ok=false; break; } } if(ok&&cnt==1&&s[tail]==')') return analysis(s,head+1,tail-1); } { int cnt=0; for(int i=tail;i>=head;i--){ if(s[i]==')')cnt++; else if(s[i]=='(')cnt--; else if(cnt==0&&(s[i]=='+'||s[i]=='-')){ int res1=analysis(s,head,i-1); int res2=analysis(s,i+1,tail); if(res1==-1||res2==-1)return -1; if(s[i]=='+')return (res1+res2)%P; else return (res1-res2+P)%P; } } } { int cnt=0; for(int i=tail;i>=head;i--){ if(s[i]==')')cnt++; else if(s[i]=='(')cnt--; else if(cnt==0&&(s[i]=='*'||s[i]=='/')){ int res1=analysis(s,head,i-1); int res2=analysis(s,i+1,tail); if(res1==-1||res2==-1)return -1; if(s[i]=='*')return (res1*res2)%P; else{ if(res2==0)return -1; return (res1*div_mod(res2,P))%P; } } } } } return -1 } int main(){ string str; while(getline(cin,str)&&str!="0:"){ vector<string> tmp=split(str,':'); P=StringToInt<int>(tmp[0]); string exp; for(int i=0;i<(int)tmp[1].size();i++) if(tmp[1][i]!=' ')exp+=tmp[1][i]; int res=analysis(exp,0,exp.size()-1); if(res==-1)cout<<"NG"<<endl; else{ cout<<exp<<" = "; cout<<res<<" (mod "<<P<<")"<<endl; } } return 0; }
a.cc: In function 'int analysis(std::string&, int, int)': a.cc:132:12: error: expected ';' before '}' token 132 | return -1 | ^ | ; 133 | } | ~
s520813380
p00260
C++
#include <cstdio> #include <vector> #include <algorithm> #include <complex> #include <cmath> #include <climits> #include <utility> #include <bitset> #include <iostream> using namespace std; #define EPS 1e-7 typedef vector<double> vdouble; typedef complex<double> P; typedef const P &rP; typedef pair<double,int> pdi; inline double dot(rP a, rP b){ return real(a) * real(b) + imag(a) * imag(b); } inline double cross(rP a, rP b){ return real(a) * imag(b) - imag(a) * real(b); } inline bool contain_s_p(rP a1, rP a2, rP b){ return abs(abs(a1 - b) + abs(a2 - b) - abs(a1 - a2)) < EPS; } inline bool contain_hl_p(rP a1, rP a2, rP b){ return contain_s_p(a1, a2, b) || contain_s_p(a1, b, a2); } inline vdouble intersect_hl_s(rP pa1, rP pa2, rP pb1, rP pb2){ P da12 = pa2 - pa1; P db21 = pb1 - pb2; P dab1 = pb1 - pa1; double D = cross(da12, db21); vdouble ret; if(abs(D) > EPS){ double t = cross(dab1, db21) / D; double s = cross(da12, dab1) / D; if( -EPS < t && (-EPS < s && s < 1.0 + EPS) ){ ret.push_back(t); ret.push_back(s); } } else if(contain_hl_p(pa1, pa2, pb1)){ ret.push_back(abs(dab1) / abs(da12)); ret.push_back(0.0); ret.push_back(abs(pb2 - pa1) / abs(da12)); ret.push_back(1.0); } return ret; } struct intrinfo{ double t; int idx; double s; bool operator< (const intrinfo &i) const{ return t < i.t; } }; int n; vector<P> plg; double pi; double checkarg(rP base, rP pa, rP pb, rP pc){ double a = arg(pa - base); double b = arg(pb - base); double c = arg(pc - base); if(b + EPS < a) b += 2.0 * pi; if(c + EPS < a) c += 2.0 * pi; return a < b + EPS && b < c + EPS; } bool checkrange(vector<pdi> &v){ v.push_back(pdi(0.5, 0)); int m = v.size(); sort(v.begin(), v.end()); v.push_back(pdi(2.0, 0)); int c = 0; for(int i = 0; i < m; ++i){ if(v[i].first > 1.0 - EPS) return true; if(c == 0 && v[i].first > EPS){ if(v[i+1].first - v[i].first > EPS){ return false; } } c -= v[i].second; } return true; } int solve(){ int ans = n; vector<vdouble> mins(n, vdouble(n, 2.0)); vector<vdouble> maxs(n, vdouble(n, -1.0)); //(plg[i], plg[j]) _ (plg[k], plg[k+1]) for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ if(i == j){ continue; } if(!checkarg(plg[i], plg[i+1], plg[j], plg[(i-1+n)%n])){ continue; } vector<intrinfo> v; int k = i; do{ vdouble ret = intersect_hl_s(plg[i], plg[j], plg[k], plg[k+1]); for(int u = 0; u < ret.size(); u += 2){ v.push_back((intrinfo){ret[u], k, ret[u+1]}); } k = (k + 1) % n; } while(k != i); double cuts = DBL_MAX; double c1 = 1.0; for(k = 0; k < v.size(); ++k){ double c2 = cross(plg[j] - plg[i], plg[v[k].idx + 1] - plg[i]); if(abs(c2) > EPS && c1 * c2 < 0.0){ cuts = min(cuts, v[k].s); c1 = -c1; } } sort(v.begin(), v.end()); for(k = v.size() - 1; k >= 0; --k){ if(v[k].s < cuts + EPS){ v[k].resize(k + 1); break; } } for(k = 0; k < v.size(); ++k){ int q = v[k].idx; mins[i][q] = min(mins[i][q], v[k].s); maxs[i][q] = max(maxs[i][q], v[k].s); } } } for(int S = (1 << n) - 1; S > 0; --S){ int cnt = 0; vector<vector<pdi> > imos(n); for(int i = 0; i < n; ++i){ if(!(S >> i & 1)) continue; ++cnt; for(int j = 0; j < n; ++j){ if(mins[i][j] + EPS < maxs[i][j]){ imos[j].push_back(pdi(mins[i][j], -1)); imos[j].push_back(pdi(maxs[i][j], 1)); } } } if(cnt >= ans) continue; bool ok = true; for(int i = 0; i < n; ++i){ if(!checkrange(imos[i])){ ok = false; break; } } if(ok){ ans = cnt; } } return ans; } int main(){ pi = acos(-1.0); double x, y; while(scanf("%d", &n), n){ plg.resize(n + 1); for(int i = 0; i < n; ++i){ scanf("%lf%lf", &x, &y); plg[i] = P(x, y); } plg[n] = plg[0]; printf("%d\n", solve()); } }
a.cc: In function 'int solve()': a.cc:135:39: error: 'DBL_MAX' was not declared in this scope 135 | double cuts = DBL_MAX; | ^~~~~~~ a.cc:11:1: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>' 10 | #include <iostream> +++ |+#include <cfloat> 11 | a.cc:148:46: error: '__gnu_cxx::__alloc_traits<std::allocator<intrinfo>, intrinfo>::value_type' {aka 'struct intrinfo'} has no member named 'resize' 148 | v[k].resize(k + 1); | ^~~~~~
s951645918
p00260
C++
#include<stdio.h> #include<algorithm> #include<math.h> using namespace std; double x[20]; double y[20]; double Abs(int a){ return max(a,-a); } const double EPS=1e-10; const double INF=1e+6; const double PI=acos(-1); int sig(double r){return (r<-EPS)?-1:(r>+EPS)?+1:0;} struct Pt{ double x,y; Pt(){} Pt(double x,double y):x(x),y(y){} Pt operator+(const Pt&a)const{return Pt(x+a.x,y+a.y);} Pt operator-(const Pt&a)const{return Pt(x-a.x,y-a.y);} Pt operator*(const Pt&a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);} Pt operator-()const{return Pt(-x,-y);} Pt operator*(const double &k)const{return Pt(x*k,y*k);} Pt operator/(const double &k)const{return Pt(x/k,y/k);} bool operator==(const Pt &a)const{return x==a.x&&y==a.y;} bool operator<(const Pt &a)const{return (a.x!=x)?(a.x<x):(a.y<y);} double Abs()const{return sqrt(x*x+y*y);} double Abs2()const{return x*x+y*y;} double arg()const{return atan2(y,x);} double dot(const Pt&a)const{return x*a.x+y*a.y;} double det(const Pt&a)const{return x*a.y-y*a.x;} }; double tri(const Pt&a,const Pt &b,const Pt&c){return (b-a).det(c-a);} int iSP(Pt a,Pt b,Pt c){ int s=sig((b-a).det(c-a)); if(s)return s; if(sig((b-a).dot(c-a))<0)return -2; if(sig((a-b).dot(c-b))<0)return +2; return 0; } int iLL(Pt a,Pt b, Pt c,Pt d){ if(sig((b-a).det(d-c)))return 1; if(sig((b-a).det(c-a)))return 0; return -1; } bool iLS(Pt a,Pt b,Pt c,Pt d){ return(sig(tri(a,b,c))*sig(tri(a,b,d))<=0); } Pt pLL(Pt a,Pt b,Pt c,Pt d){ b=b-a;d=d-c;return a+b*(c-a).det(d)/b.det(d); } int sGP(int n,Pt p[],Pt a){ int side=-1,i; p[n]=p[0]; for(i=0;i<n;i++){ Pt p0=p[i]-a,p1=p[i+1]-a; if(sig(p0.det(p1))==0&&sig(p0.dot(p1))<=0)return 0; if(p0.y>p1.y)swap(p0,p1); if(sig(p0.y)<=0&&0<sig(p1.y)&&sig(p0.det(p1))>0)side=-side; } return side; } int sAP(Pt a,Pt b,Pt c){ return sig(a.det(c))-sig(b.det(c))-sig(a.det(b)); } int s_a[500],s_b[500],s_ab[500]; bool iGSstrict(int n,Pt p[],Pt a,Pt b){ int i; p[n]=p[0]; p[n+1]=p[1]; if(sGP(n,p,a)>0||sGP(n,p,b)>0)return 1; for(i=0;i<=n;i++){ s_a[i]=sig(tri(p[i],p[i+1],a)); s_b[i]=sig(tri(p[i],p[i+1],b)); s_ab[i]=sig(tri(a,b,p[i])); } for(i=0;i<n;i++){ if(s_a[i]*s_b[i]<0&&s_ab[i]*s_ab[i+1]<0)return 1; } for(i=0;i<n;i++){ if(s_a[i]==0&&s_b[i]>0&&sig((a-p[i]).dot(a-p[i+1]))<0)return 1; if(s_b[i]==0&&s_a[i]>0&&sig((b-p[i]).dot(b-p[i+1]))<0)return 1; } for(i=0;i<n;i++)if(s_ab[i+1]==0&&sig((p[i+1]-a).dot(p[i+1]-b))<=0){ if(!(p[i+1]==a)&&sAP(p[i+2]-p[i+1],p[i]-p[i+1],a-p[i+1])>0)return 1; if(!(p[i+1]==b)&&sAP(p[i+2]-p[i+1],p[i]-p[i+1],b-p[i+1])>0)return 1; } return 0; } Pt point[20]; Pt val[10000]; Pt val2[10000]; bool ka[10000][300]; Pt poly[300]; int main(){ int a; while(scanf("%d",&a),a){ int S=0; for(int i=0;i<a;i++){ scanf("%lf%lf",x+i,y+i); if(x[S]<x[i]||(x[S]==x[i]&&y[S]<y[i]))S=i; point[i]=Pt(x[i],y[i]); } int ret=9999; int N=5+a; poly[0]=Pt(INF,INF); poly[1]=Pt(-INF,INF); poly[2]=Pt(-INF,-INF); poly[3]=Pt(INF,-INF); poly[4]=Pt(INF,INF-EPS); for(int i=0;i<a;i++)poly[5+i]=point[(S-i+a)%a]; int Sz=0; for(int i=0;i<a;i++){ for(int j=i+1;j<a;j++){ for(int k=0;k<a;k++){ if(iLL(point[i],point[j],point[k],point[(k+1)%a])==1&&iLS(point[i],point[j],point[k],point[(k+1)%a])){ val2[Sz++]=point[k]+(pLL(point[i],point[j],point[k],point[(k+1)%a]-point[k])*(1.0-EPS); val2[Sz++]=point[(k+1)%a]+(pLL(point[i],point[j],point[k],point[(k+1)%a]-point[(k+1)%a])*(1.0-EPS);&#160;} } } } std::sort(val2,val2+Sz); int sz=0; for(int i=0;i<Sz;i++){ if(i==0||(val2[i]-val2[i-1]).Abs2()>EPS){ val[sz++]=val2[i]; } } // for(int i=0;i<sz;i++)printf("%f %f\n",val[i].x,val[i].y); for(int i=0;i<sz;i++){ for(int j=0;j<a;j++){ ka[i][j]=iGSstrict(N,poly,point[j],val[i]); } } for(int i=0;i<(1<<a);i++){ bool ok=true; for(int j=0;j<sz;j++){ bool OK=false; for(int k=0;k<a;k++){ if(!(i&(1<<k)))continue; if(!ka[j][k]){OK=true;break;} } if(!OK){ok=false;break;} } if(ok){ // if(__builtin_popcount(i)==1)printf("%d\n",i); ret=min(ret,__builtin_popcount(i)); } } printf("%d\n",ret); } }
a.cc:117:101: error: stray '#' in program 117 | val2[Sz++]=point[(k+1)%a]+(pLL(point[i],point[j],point[k],point[(k+1)%a]-point[(k+1)%a])*(1.0-EPS);&#160;} | ^ a.cc: In function 'int main()': a.cc:116:87: error: expected ')' before ';' token 116 | val2[Sz++]=point[k]+(pLL(point[i],point[j],point[k],point[(k+1)%a]-point[k])*(1.0-EPS); | ~ ^ | ) a.cc:117:99: error: expected ')' before ';' token 117 | val2[Sz++]=point[(k+1)%a]+(pLL(point[i],point[j],point[k],point[(k+1)%a]-point[(k+1)%a])*(1.0-EPS);&#160;} | ~ ^ | ) a.cc:117:102: error: lvalue required as unary '&' operand 117 | val2[Sz++]=point[(k+1)%a]+(pLL(point[i],point[j],point[k],point[(k+1)%a]-point[(k+1)%a])*(1.0-EPS);&#160;} | ^~~
s991262808
p00260
C++
#include<stdio.h> #include<algorithm> #include<math.h> using namespace std; double x[20]; double y[20]; double Abs(int a){ return max(a,-a); } const double EPS=1e-10; const double INF=1e+6; const double PI=acos(-1); int sig(double r){return (r<-EPS)?-1:(r>+EPS)?+1:0;} struct Pt{ double x,y; Pt(){} Pt(double x,double y):x(x),y(y){} Pt operator+(const Pt&a)const{return Pt(x+a.x,y+a.y);} Pt operator-(const Pt&a)const{return Pt(x-a.x,y-a.y);} Pt operator*(const Pt&a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);} Pt operator-()const{return Pt(-x,-y);} Pt operator*(const double &k)const{return Pt(x*k,y*k);} Pt operator/(const double &k)const{return Pt(x/k,y/k);} bool operator==(const Pt &a)const{return x==a.x&&y==a.y;} bool operator<(const Pt &a)const{return (a.x!=x)?(a.x<x):(a.y<y);} double Abs()const{return sqrt(x*x+y*y);} double Abs2()const{return x*x+y*y;} double arg()const{return atan2(y,x);} double dot(const Pt&a)const{return x*a.x+y*a.y;} double det(const Pt&a)const{return x*a.y-y*a.x;} }; double tri(const Pt&a,const Pt &b,const Pt&c){return (b-a).det(c-a);} int iSP(Pt a,Pt b,Pt c){ int s=sig((b-a).det(c-a)); if(s)return s; if(sig((b-a).dot(c-a))<0)return -2; if(sig((a-b).dot(c-b))<0)return +2; return 0; } int iLL(Pt a,Pt b, Pt c,Pt d){ if(sig((b-a).det(d-c)))return 1; if(sig((b-a).det(c-a)))return 0; return -1; } bool iLS(Pt a,Pt b,Pt c,Pt d){ return(sig(tri(a,b,c))*sig(tri(a,b,d))<=0); } Pt pLL(Pt a,Pt b,Pt c,Pt d){ b=b-a;d=d-c;return a+b*(c-a).det(d)/b.det(d); } int sGP(int n,Pt p[],Pt a){ int side=-1,i; p[n]=p[0]; for(i=0;i<n;i++){ Pt p0=p[i]-a,p1=p[i+1]-a; if(sig(p0.det(p1))==0&&sig(p0.dot(p1))<=0)return 0; if(p0.y>p1.y)swap(p0,p1); if(sig(p0.y)<=0&&0<sig(p1.y)&&sig(p0.det(p1))>0)side=-side; } return side; } int sAP(Pt a,Pt b,Pt c){ return sig(a.det(c))-sig(b.det(c))-sig(a.det(b)); } int s_a[500],s_b[500],s_ab[500]; bool iGSstrict(int n,Pt p[],Pt a,Pt b){ int i; p[n]=p[0]; p[n+1]=p[1]; if(sGP(n,p,a)>0||sGP(n,p,b)>0)return 1; for(i=0;i<=n;i++){ s_a[i]=sig(tri(p[i],p[i+1],a)); s_b[i]=sig(tri(p[i],p[i+1],b)); s_ab[i]=sig(tri(a,b,p[i])); } for(i=0;i<n;i++){ if(s_a[i]*s_b[i]<0&&s_ab[i]*s_ab[i+1]<0)return 1; } for(i=0;i<n;i++){ if(s_a[i]==0&&s_b[i]>0&&sig((a-p[i]).dot(a-p[i+1]))<0)return 1; if(s_b[i]==0&&s_a[i]>0&&sig((b-p[i]).dot(b-p[i+1]))<0)return 1; } for(i=0;i<n;i++)if(s_ab[i+1]==0&&sig((p[i+1]-a).dot(p[i+1]-b))<=0){ if(!(p[i+1]==a)&&sAP(p[i+2]-p[i+1],p[i]-p[i+1],a-p[i+1])>0)return 1; if(!(p[i+1]==b)&&sAP(p[i+2]-p[i+1],p[i]-p[i+1],b-p[i+1])>0)return 1; } return 0; } Pt point[20]; Pt val[10000]; Pt val2[10000]; bool ka[10000][300]; Pt poly[300]; int main(){ int a; while(scanf("%d",&a),a){ int S=0; for(int i=0;i<a;i++){ scanf("%lf%lf",x+i,y+i); if(x[S]<x[i]||(x[S]==x[i]&&y[S]<y[i]))S=i; point[i]=Pt(x[i],y[i]); } int ret=9999; int N=5+a; poly[0]=Pt(INF,INF); poly[1]=Pt(-INF,INF); poly[2]=Pt(-INF,-INF); poly[3]=Pt(INF,-INF); poly[4]=Pt(INF,INF-EPS); for(int i=0;i<a;i++)poly[5+i]=point[(S-i+a)%a]; int Sz=0; for(int i=0;i<a;i++){ for(int j=i+1;j<a;j++){ for(int k=0;k<a;k++){ if(iLL(point[i],point[j],point[k],point[(k+1)%a])==1&&iLS(point[i],point[j],point[k],point[(k+1)%a])){ val2[Sz++]=point[k]+(pLL(point[i],point[j],point[k],point[(k+1)%a])-point[k])*(1.0-EPS); val2[Sz++]=point[(k+1)%a]+(pLL(point[i],point[j],point[k],point[(k+1)%a])-point[(k+1)%a])*(1.0-EPS);&#160;} } } } std::sort(val2,val2+Sz); int sz=0; for(int i=0;i<Sz;i++){ if(i==0||(val2[i]-val2[i-1]).Abs2()>EPS){ val[sz++]=val2[i]; } } // for(int i=0;i<sz;i++)printf("%f %f\n",val[i].x,val[i].y); for(int i=0;i<sz;i++){ for(int j=0;j<a;j++){ ka[i][j]=iGSstrict(N,poly,point[j],val[i]); } } for(int i=0;i<(1<<a);i++){ bool ok=true; for(int j=0;j<sz;j++){ bool OK=false; for(int k=0;k<a;k++){ if(!(i&(1<<k)))continue; if(!ka[j][k]){OK=true;break;} } if(!OK){ok=false;break;} } if(ok){ // if(__builtin_popcount(i)==1)printf("%d\n",i); ret=min(ret,__builtin_popcount(i)); } } printf("%d\n",ret); } }
a.cc:117:102: error: stray '#' in program 117 | val2[Sz++]=point[(k+1)%a]+(pLL(point[i],point[j],point[k],point[(k+1)%a])-point[(k+1)%a])*(1.0-EPS);&#160;} | ^ a.cc: In function 'int main()': a.cc:117:103: error: lvalue required as unary '&' operand 117 | val2[Sz++]=point[(k+1)%a]+(pLL(point[i],point[j],point[k],point[(k+1)%a])-point[(k+1)%a])*(1.0-EPS);&#160;} | ^~~
s196625564
p00260
C++
g#include <iostream> #include <complex> #include <vector> #include <algorithm> using namespace std; const double EPS = 1e-9; typedef complex<double> P; inline double dot(const P &a, const P &b) { return a.real()*b.real() + a.imag()*b.imag(); } inline double cross(const P &a, const P &b) { return a.real()*b.imag() - a.imag()*b.real(); } inline int cmp(double a, double b) { const double diff = a-b; if(fabs(diff) < EPS) return 0; return diff < 0 ? -1 : 1; } bool intersect(const P &pa, const P &pb, const P &qa, const P &qb) { if(cross(pb-pa, qa-pa) * cross(pb-pa, qb-pa) >= 0) return false; if(cross(qb-qa, pa-qa) * cross(qb-qa, pb-qa) >= 0) return false; return true; } bool in_polygon(const P &p, const vector<P> &polygon) { const int N = polygon.size(); int cnt = 0; for(int i = 0; i < N; ++i) { const int ni = (i+1) % N; //cout << polygon[i] << polygon[ni] << p << cross(polygon[ni]-polygon[i], p-polygon[i]) << endl; if(cmp(cross(polygon[ni]-polygon[i], p-polygon[i]), 0) == 0 && cmp(dot(polygon[ni]-p, polygon[i]-p), 0) <= 0) return true; if((cmp(polygon[i].imag(), p.imag()) <= 0 && cmp(polygon[ni].imag(), p.imag()) > 0) || (cmp(polygon[ni].imag(), p.imag()) <= 0 && cmp(polygon[i].imag(), p.imag()) > 0)) { double vt = (p.imag() - polygon[i].imag()) / (polygon[ni].imag() - polygon[i].imag()); if(p.real() < (polygon[i].real() + (vt * (polygon[ni].real() - polygon[i].real())))) { //cout << "intersect " << p << polygon[i] << polygon[ni] << endl; ++cnt; } } } //cout << p << cnt << endl; return cnt % 2 == 1; } bool can_see(int a, int b, const vector<P> &polygon) { const int N = polygon.size(); const P pa = polygon[a]; const P pb = polygon[b]; const P delta = (pb - pa) / abs(pb - pa) * 0.5; for(int i = 0; i < N; ++i) { const int ni = (i+1) % N; if(abs(polygon[i]-pb) < EPS) continue; if(abs(polygon[ni]-pb) < EPS) continue; if(cmp(cross(pb-pa, polygon[i]-pa), 0) == 0 && dot(pa-polygon[i], pb-polygon[i]) <= 0) { const P cp = polygon[i] + delta; if(!in_polygon(cp, polygon)) return false; } else if(intersect(pa, pb, polygon[i], polygon[ni])) return false; } return true; } bool solve() { int N; cin >> N; if(!N) return false; vector<P> polygon(N); for(int i = 0; i < N; ++i) { double x, y; cin >> x >> y; polygon[i] = P(x, y); } vector<bool> visible(N); int ans = N; for(int pat = 0; pat < (1<<N); ++pat) { //for(int pat = 0; pat < 2; ++pat) { fill(visible.begin(), visible.end(), false); int popcnt = 0; for(int i = 0; i < N; ++i) { if(!(pat & (1<<i))) continue; ++popcnt; visible[i] = true; for(int j = 0; j < N; ++j) { if(can_see(i, j, polygon)) { //cout << i << ' ' << j << endl; visible[j] = true; } } } bool ok = true; for(int i = 0; i < N; ++i) { if(!visible[i]) ok = false; } if(ok) { //if(popcnt == 1) cout << "pat " << pat << endl; ans = min(ans, popcnt); } } cout << ans << endl; return true; } int main() { cin.tie(0); ios::sync_with_stdio(0); while(solve()) ; return 0; }
a.cc:1:2: error: stray '#' in program 1 | g#include <iostream> | ^ a.cc:1:1: error: 'g' does not name a type 1 | g#include <iostream> | ^ In file included from /usr/include/c++/14/complex:43, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from /usr/include/c++/14/complex:44: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdlib.h:32, from /usr/include/c++/14/bits/std_abs.h:38, from /usr/include/c++/14/cmath:49: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type 214 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type 225 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_algobase.h:66: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type 112 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 65 | #include <debug/assertions.h> +++ |+#include <cstddef> 66 | #include <bits/stl_iterator_base_types.h> /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type 118 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/incl
s403981806
p00261
C
#include<iostream> #include<cstring> using namespace std; string removedFirst(string str) { string ans; if(str.length() == 1) { return ans; } else { for(int i=1; i<str.length(); i++) { ans += str[i]; } return ans; } } int main() { string str; getline(cin, str); while(str != "#") { char where = 'A'; while(str.length() != 0) { char oldWhere = where; switch(where) { case 'A': if(str[0] == '0') { where = 'X'; } else { where = 'Y'; } break; case 'B': if(str[0] == '0') { where = 'Y'; } else { where = 'X'; } break; case 'X': if(str[0] == '1') { where = 'Z'; } break; case 'Y': if(str[0] == '0') { where = 'X'; } break; case 'Z': if(str[0] == '0') { where = 'W'; } else { where = 'B'; } break; case 'W': if(str[0] == '0') { where = 'B'; } else { where = 'Y'; } } str = removedFirst(str); if(where == oldWhere) { where = 'N'; str.clear(); } } //char tmp = 'B'; if(where == 'B') { cout<<"YES"<<endl; } else { cout<<"NO"<<endl; } getline(cin, str); } }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s379823326
p00261
C++
#include<iostream> #include<cstring> using namespace std; string removedFirst(string str) { string ans; if(str.length() == 1) { return ans; } else { for(int i=1; i<str.length(); i++) { ans += str[i]; } return ans; } } int main() { string str; getline(cin, str); while(str != '#') { char where = 'A'; while(str.length() != 0) { char oldWhere = where; switch(where) { case 'A': if(str[0] == '0') { where = 'X'; } else { where = 'Y'; } break; case 'B': if(str[0] == '0') { where = 'Y'; } else { where = 'X'; } break; case 'X': if(str[0] == '1') { where = 'Z'; } break; case 'Y': if(str[0] == '0') { where = 'X'; } break; case 'Z': if(str[0] == '0') { where = 'W'; } else { where = 'B'; } break; case 'W': if(str[0] == '0') { where = 'B'; } else { where = 'Y'; } } str = removedFirst(str); if(where == oldWhere) { where = 'N'; str.clear(); } } if(where == 'B') { cout<<"Yes"<<endl; } else { cout<<"No"<<endl; } getline(cin, str); } }
a.cc: In function 'int main()': a.cc:24:13: error: no match for 'operator!=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char') 24 | while(str != '#') { | ~~~ ^~ ~~~ | | | | | char | std::string {aka std::__cxx11::basic_string<char>} In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)' 197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>' 24 | while(str != '#') { | ^~~ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)' 243 | operator!=(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>' 24 | while(str != '#') { | ^~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 24 | while(str != '#') { | ^~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 24 | while(str != '#') { | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 24 | while(str != '#') { | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 24 | while(str != '#') { | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>' 24 | while(str != '#') { | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 651 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 24 | while(str != '#') { | ^~~ /usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 658 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 24 | while(str != '#') { | ^~~ /usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed: a.cc:24:16: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'char' 24 | while(str != '#') { | ^~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3833 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: template argument deduction/substitution failed: a.cc:24:16: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'char' 24 | while(str != '#') { | ^~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3847 | operator!=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: template argument deduction/substitution failed: a.cc:24:16: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>' 24 | while(str != '#') { | ^~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3860 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: template argument deduction/substitution failed: a.cc:24:16: note: mismatched types 'const _CharT*' and 'char' 24 | while(str != '#') { | ^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2613:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator!=(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2613 | operator!=(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2613:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::tuple<_UTypes ...>' 24 | while(str != '#') { | ^~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46: /usr/include/c++/14/bits/streambuf_iterator.h:242:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator!=(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)' 242 | operator!=(const istreambuf_iterator<_CharT, _Traits>& __a, | ^~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:242:5: note: template argument deduction/substitution failed: a.cc:24:16: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>' 24 | while(str != '#') { | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33, from /usr/include/c++/14/bits/allocator.h:46: /usr/include/c++/14/bits/new_allocator.h:222:9: note: candidate: 'template<class _Up> bool std::operator!=(const __new_allocator<char>&, const __new_allocator<_Tp>&)' 222 |
s613671504
p00261
C++
#include<cstdio> #include<vector> #include<algorithm> using namespace std; int main(){ int g[6][2]={{1,2},{0,3},{1,0},{4,5},{5,2},{2,1}}; char str[128]; while(scanf("%s",str),str[0]!='#'){ int pos=0; for(int i=0;str[i];i++){ pos=g[pos][str[i]-'0']; } puts(pos==5?"YES":"NO"); } return 0; } #include<cstdio> #include<vector> #include<algorithm> using namespace std; int main(){ int g[6][2]={{1,2},{0,3},{1,0},{4,5},{5,2},{2,1}}; char str[128]; while(scanf("%s",str),str[0]!='#'){ int pos=0; for(int i=0;str[i];i++){ pos=g[pos][str[i]-'0']; } puts(pos==5?"YES":"NO"); } return 0; }
a.cc:21:5: error: redefinition of 'int main()' 21 | int main(){ | ^~~~ a.cc:5:5: note: 'int main()' previously defined here 5 | int main(){ | ^~~~
s050067329
p00261
C++
#include <bits/stdc++.h> using namespace std; const signed int t[2][6] = {{1, -1, 1, 4, 5, 2}, {2, 3, -1, 5, 2, 1}, }; int main(void){ string str; while(cin >> str, str != "#"){ int now_pos = 0; for(int p=0; p < str.size(); p++){ if([str[p] - '0'][now_pos] == -1){ cout << "No" << endl; break; }else{ now_pos = t[str[p] - '0'][now_pos]; } } if(now_pos == 5){ cout << "Yes" << endl; }else{ cout << "No" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:13:14: error: expected ',' before '[' token 13 | if([str[p] - '0'][now_pos] == -1){ | ^ | , a.cc:13:14: error: expected identifier before '[' token a.cc: In lambda function: a.cc:13:24: error: expected '{' before '[' token 13 | if([str[p] - '0'][now_pos] == -1){ | ^ a.cc: In function 'int main()': a.cc:13:24: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
s423713050
p00261
C++
#include <iostream> using namespace std; #define F(i,n) for( int i = 0; i < n; i++ ) char graph[6][2] = { // fで失敗 { 'x', 'y' }, // a { 'f', 'z' }, // x { 'x', 'f' }, // y { 'w', 'b' }, // z { 'b', 'y' }, // w { 'y', 'x' } // b }; bool simulate( string s ){ char now = 'a'; F( i, s.size() ){ int next = s[i] == '0' ? 0 : 1; int nowIndex; if( now == 'a' ){ nowIndex = 0; } else if( now == 'x' ){ nowIndex = 1; } else if( now == 'y' ){ nowIndex = 2; } else if( now == 'z' ){ nowIndex = 3; } else if( now == 'w' ){ nowIndex = 4; } else if( now == 'b' ){ nowIndex = 5; } now = graph[ nowIndex ][ next ]; if( now == 'f'){ return false; } } if( now == 'b' ){ return true; } else return false; } main(){ string s; while( cin >> s && s != "#" ){ if( simulate( s ) ){ cout << "Yes" << endl; } else { cout << "No" << endl; } }
a.cc:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 33 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:41:4: error: expected '}' at end of input 41 | } | ^ a.cc:33:7: note: to match this '{' 33 | main(){ | ^
s500239099
p00262
C++
#include <iostream> using namespace std; int b[1000000]; int main(){ int n; while(cin >>n , n){ for (int i = 0; i < n; ++i){ cin >> b[i]; } int i = 0; for (; i <= 10000; ++i){ bool f = true; for (int k = 0; k < 1000000 && b[k]; ++k){ if (b[k] != k+1){ f = false; break; } } if ( f){ break; } int t = 0; int j = 0; for (; j < 1000000 && b[j]; ++j){ --b[j]; ++t; } b[j] = t; for (int k = 0; k <= j; ++k){ if (!b[k]){ for ( int l = k+1; l <= j; ++l){ if ( b[l] ){ b[k]=b[l]; b[l] = 0; break; } } } } } if (i<=10000){ cout << i << endl; } else {0 cout << -1 << endl; } } }
a.cc: In function 'int main()': a.cc:51:14: error: expected ';' before 'cout' 51 | } else {0 | ^ | ; 52 | cout << -1 << endl; | ~~~~
s268810443
p00262
C++
6 1 4 1 3 2 4 5 1 2 3 4 5 10 1 1 1 1 1 1 1 1 1 1 9 1 1 1 1 1 1 1 1 1 12 1 4 1 3 2 4 3 3 2 1 2 2 1 5050 3 10000 10000 100 0
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 6 | ^
s184958794
p00262
C++
#include <bits/stdc++.h> using namespace std; #define SMIN 3 #define SMAX 1000000 #define NMIN 1 #define NMAX 100 #define BMIN 1 #define BMAX 10000 #define LIM 10000 #define TCASE 20 bool valid[SMAX+1]; bool check(vector<int> v){ if ( v[0] != 1 ) return false; for ( int i = 1; i < v.size(); i++ ){ if ( v[i-1]+1 != v[i] ) return false; } return true; } int simulate(vector<int> v, int sum){ int cnt = 0; while(1){ if ( check(v) ) return cnt; int r = v.size(); for ( int i = 0; i < v.size(); i++ ) v[i]--; vector<int> nv; for ( int i = 0; i < v.size(); i++ ) { if ( v[i] ) nv.push_back(v[i]); } v = nv; v.push_back(r); cnt++; if ( cnt > LIM ) return cnt; } } void main(){ for ( int i = 0; i <= SMAX; i++ ) valid[i] = false; int cur = 3, d = 3; while( cur <= SMAX ){ valid[cur] = true; cur += d; d++; } int n; int tcase = 0; while(1){ cin >> n; if ( n == 0 ) break; tcase++; assert( NMIN <= n && n <= NMAX); vector<int> v; int x; int sum = 0; for ( int i = 0; i < n ;i++) { cin >> x; v.push_back(x); sum += x; } int ans = simulate(v, sum); if ( ans > 10000 ) cout << -1 << endl; else cout << ans << endl; } return 0; }
a.cc:39:1: error: '::main' must return 'int' 39 | void main(){ | ^~~~
s425918817
p00263
C
#include <iostream> #include <cstdio> using namespace std; int main(){ int Q; cin >> Q; while(Q--){ unsigned int s; scanf("%x" ,&s); if(s >> 31) cout << '-'; int integer = (s & 0x7fffffff) >> 7; int decimal = (s & 0x0000007f); double c[7],d = 0.0; c[0] = 0.5; for(int i = 1 ; i < 7 ; i++) c[i] = 0.5*c[i-1]; double e = 64; for(int i = 0 ; i < 7 ; i++){ if(e <= decimal){ d += c[i]; decimal -= e; } e /= 2; } while(true){ if(((int)(d*10))%10 == 0) break; d *= 10; } cout << integer << '.'; printf("%d\n" ,(int)d); } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s092627399
p00263
C++
#include <iostream> #include <algorithm> using namespace std; int n, x, t; int main() { scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%x", &x); t = x >= 0 ? 1 : -1; x = x >= 0 ? x : x - 2147483648; cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; } }
a.cc: In function 'int main()': a.cc:11:50: error: no match for 'operator==' (operand types are 'std::basic_ostream<char>' and 'int') 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~ | | | | | int | std::basic_ostream<char> a.cc:11:50: note: candidate: 'operator==(int, int)' (built-in) 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ a.cc:11:50: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'int' In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::fpos<_StateT>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::allocator<_CharT>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 629 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ /usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 637 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ /usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed: a.cc:11:53: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ /usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ /usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed: a.cc:11:53: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ /usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3819 | operator==(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed: a.cc:11:53: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>' 11 | cout << x / 128.0 * t << x % 128 == 0 ? "0" : "" << endl; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2558 | operator==(const tuple<_TElements...>
s344785345
p00263
C++
#include<iostream> #include<map> #include<cmath> #include<cstdlib> #include<iomanip> #include<sstream> using namespace std; string toBinary(string c) { if(c == "0") return "0000"; int val = (atoi)(c.c_str()); string ret,ret2; while(true) { if(val == 1) { ret += "1"; break; } val%2 == 0?ret += "0":ret += "1"; val /= 2; } reverse(ret.begin(),ret.end()); ret2 = string(4-ret.size(),'0')+ret; return ret2; } string dtos(double d) { stringstream ss; ss << d; return ss.str(); } int main() { int N; cin >> N; while(N-- > 0) { string s; cin >> s; string bin; for(int i=0;i<s.length();i++) { string c; if(s[i] == 'a') c = "10"; else if(s[i] == 'b') c = "11"; else if(s[i] == 'c') c = "12"; else if(s[i] == 'd') c = "13"; else if(s[i] == 'e') c = "14"; else if(s[i] == 'f') c = "15"; else c = s[i]; bin += toBinary(c); } double ans = 0.0; for(int i=1;i<=24;i++) if(bin[i] == '1')ans += pow(2.0,24-i); for(int i=25;i<32;i++) if(bin[i] == '1')ans += pow(0.5,i-24); if(bin[0] == '1') cout << "-"; string sol = dtos(ans); cout << sol; sol.find(".") == string::npos?cout << ".0" << endl:cout << endl; } return 0; }
a.cc: In function 'std::string toBinary(std::string)': a.cc:25:3: error: 'reverse' was not declared in this scope 25 | reverse(ret.begin(),ret.end()); | ^~~~~~~
s507130319
p00263
C++
#include<iostream> #include<map> #include<string> #include<cstring> #include<cstdlib> #include<cstdio> using namespace std; char pat[16][5] = {"0000" , "0001" , "0010" , "0011" , "0100" , "0101" , "0110" , "0111" , "1000" , "1001" , "1010" , "1011" , "1100" , "1101" , "1110" , "1111" }; //連想配列を利用する map<char , int> str_data; void f_set(); int main(void) { //入力数 int n = 0; //関数で連想配列をセット f_set(); cin >> n; for (int i = 0; i < n; i++) { //入力変数 char str_input[9] = {NULL}; cin >> str_input; //文字列を結合する string str_output; for (int j = 1; j < 8; j++) { str_output += pat[str_data[str_input[j]]]; } //文字列を1次的に格納する変数 char str_copy[100] = {NULL}; //カウント変数 int count = 0; //stringの4番目(先頭は符号) for (int j = 4; j < 32 - 7; j++) { str_copy[count++] = str_output[j]; } //ina型に変換 unsigned long long int change = 0; //掛け算変数 int kakeru = 1; //文字列をチェンジにコピー for (int j = 32 - 7 - 1 - 4; j >= 0; j--) { change += (str_copy[j] - '0') * kakeru; kakeru *= 2; } //double部分の計算 int output_double = 0; //文字列をコピー count = 0; for (int j = 32 - 7 - 4; j < 32 - 4; j++) { str_copy[count++] = str_output[j]; } //一応ナル文字を代入 str_copy[count] = '\0'; //文字列から変換 //割る数 int waru = 2; for (int j = 0; j < count; j++) { output_double += (double)(str_copy[j] - '0') / waru * 1000000; waru *= 2; } //文字列に変換 itoa(output_double , str_copy , 10); //文字列の長さを求める int length = strlen(str_copy); for (int j = length - 1; j >= 1; j--) { if (str_copy[j] == '0') { str_copy[j] = '\0'; } else { break; } } output_double = atoi(str_copy); if (str_input[0] == '8') { cout << "-"; } //(double)output_double += change; cout << change << "." << output_double << endl; } return 0; } void f_set() { str_data['0'] = 0; str_data['1'] = 1; str_data['2'] = 2; str_data['3'] = 3; str_data['4'] = 4; str_data['5'] = 5; str_data['6'] = 6; str_data['7'] = 7; str_data['8'] = 8; str_data['9'] = 9; str_data['a'] = 10; str_data['b'] = 11; str_data['c'] = 12; str_data['d'] = 13; str_data['e'] = 14; str_data['f'] = 15; }
a.cc: In function 'int main()': a.cc:51:42: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null] 51 | char str_input[9] = {NULL}; | ^ a.cc:63:43: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null] 63 | char str_copy[100] = {NULL}; | ^ a.cc:105:17: error: 'itoa' was not declared in this scope 105 | itoa(output_double , str_copy , 10); | ^~~~
s735769508
p00263
C++
#include<iostream> #include<map> #include<string> #include<cstring> #include<cstdlib> #include<cstdio> using namespace std; char pat[16][5] = {"0000" , "0001" , "0010" , "0011" , "0100" , "0101" , "0110" , "0111" , "1000" , "1001" , "1010" , "1011" , "1100" , "1101" , "1110" , "1111" }; //連想配列を利用する map<char , int> str_data; void f_set(); int main(void) { //入力数 int n = 0; //関数で連想配列をセット f_set(); cin >> n; for (int i = 0; i < n; i++) { //入力変数 char str_input[9] = {NULL}; cin >> str_input; //文字列を結合する string str_output; for (int j = 1; j < 8; j++) { str_output += pat[str_data[str_input[j]]]; } //文字列を1次的に格納する変数 char str_copy[100] = {NULL}; //カウント変数 int count = 0; //stringの4番目(先頭は符号) for (int j = 4; j < 32 - 7; j++) { str_copy[count++] = str_output[j]; } //ina型に変換 unsigned long long int change = 0; //掛け算変数 int kakeru = 1; //文字列をチェンジにコピー for (int j = 32 - 7 - 1 - 4; j >= 0; j--) { change += (str_copy[j] - '0') * kakeru; kakeru *= 2; } //double部分の計算 int output_double = 0; //文字列をコピー count = 0; for (int j = 32 - 7 - 4; j < 32 - 4; j++) { str_copy[count++] = str_output[j]; } //一応ナル文字を代入 str_copy[count] = '\0'; //文字列から変換 //割る数 int waru = 2; for (int j = 0; j < count; j++) { output_double += (double)(str_copy[j] - '0') / waru * 1000000; waru *= 2; } //文字列に変換 itoa(output_double , str_copy , 10); //文字列の長さを求める int length = strlen(str_copy); for (int j = length - 1; j >= 1; j--) { if (str_copy[j] == '0') { str_copy[j] = '\0'; } else { break; } } output_double = atoi(str_copy); if (str_input[0] == '8') { cout << "-"; } //(double)output_double += change; cout << change << "." << output_double << endl; } return 0; } void f_set() { str_data['0'] = 0; str_data['1'] = 1; str_data['2'] = 2; str_data['3'] = 3; str_data['4'] = 4; str_data['5'] = 5; str_data['6'] = 6; str_data['7'] = 7; str_data['8'] = 8; str_data['9'] = 9; str_data['a'] = 10; str_data['b'] = 11; str_data['c'] = 12; str_data['d'] = 13; str_data['e'] = 14; str_data['f'] = 15; }
a.cc: In function 'int main()': a.cc:60:42: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null] 60 | char str_input[9] = {NULL}; | ^ a.cc:72:43: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null] 72 | char str_copy[100] = {NULL}; | ^ a.cc:114:17: error: 'itoa' was not declared in this scope 114 | itoa(output_double , str_copy , 10); | ^~~~
s577091265
p00264
C
#include <stdio.h> #include <string.h> #include <math.h> #define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164 struct point{ int x,y; }; struct wind{ int w,a; }; double getlen(int x1,int y1,int x2,int y2){ return sqrt(pow((x1-x2)*1.0,2)+pow((y1-y2)*1.0,2)); } int check(int N,point *tree,point house,wind wind,int dtree){ int i; double rad,dig; for(i = 0;i < N;i++){ if(wind.a*1.0 < getlen(house.x,house.y,tree[i].x,tree[i].y)){ return 1; } rad = atan2((house.y-tree[i].y)*1.0,(house.x-tree[i].x)*1.0); dig = fmod((rad * 180.0 / PI)+360.0,360.0); if(wind.w*1.0-dtree/2.0+90.0 <= dig+90.0 && wind.w*1.0+dtree/2.0+90.0 >= dig+90.0){ return 0; } } return 1; } int check2(point house,wind wind,int dtree){ double rad,dig; if(wind.a*1.0 < getlen(house.x,house.y,0,0)){ return 0; } rad = atan2(house.y*1.0,house.x*1.0); dig = fmod((rad * 180.0 / PI)+360.0,360.0); if(!(wind.w*1.0-dtree/2.0+90.0 <= dig+90.0 && wind.w*1.0+dtree/2.0+90.0 >= dig+90.0)){ return 0; } return 1; } void max(int H,int *ok){ int i,p,dmax; int tmp[100]; p = 0; dmax = 0; for(i = 0;i < H;i++){ if(dmax < ok[i]){ dmax = ok[i]; tmp[0] = i+1; p = 1; }else if(dmax != 0 && dmax == ok[i]){ tmp[p++] = i+1; } } if(dmax == 0){ printf("NA\n"); }else{ for(i = 0;i < p;i++){ printf("%d%c",tmp[i],(i == p-1) ? '\n' : ' '); } } } int main(){ int i,j,H,R,U,M,S,du,dm,ds; int ok[100]; point h[100],u[10],m[10],s[10]; wind wind[100]; while(1){ memset(ok,0,sizeof(ok)); scanf("%d %d",&H,&R); if(H == 0 && R == 0){ break; } for(i = 0;i < H;i++){ scanf("%d %d",&h[i].x,&h[i].y); } scanf("%d %d %d %d %d %d",&U,&M,&S,&du,&dm,&ds); for(i = 0;i < U;i++){ scanf("%d %d",&u[i].x,&u[i].y); } for(i = 0;i < M;i++){ scanf("%d %d",&m[i].x,&m[i].y); } for(i = 0;i < S;i++){ scanf("%d %d",&s[i].x,&s[i].y); } for(i = 0;i < R;i++){ scanf("%d %d",&wind[i].w,&wind[i].a); } for(i = 0;i < R;i++){ for(j = 0;j < H;j++){ if(!check2(h[j],wind[i],du)){ continue; } if(!check(U,u,h[j],wind[i],du)){ continue; } if(!check(M,m,h[j],wind[i],dm)){ continue; } if(!check(S,s,h[j],wind[i],ds)){ continue; } ok[j]++; } } max(H,ok); } return 0; }
main.c:18:17: error: unknown type name 'point'; did you mean 'int'? 18 | int check(int N,point *tree,point house,wind wind,int dtree){ | ^~~~~ | int main.c:18:29: error: unknown type name 'point'; did you mean 'int'? 18 | int check(int N,point *tree,point house,wind wind,int dtree){ | ^~~~~ | int main.c:18:41: error: unknown type name 'wind' 18 | int check(int N,point *tree,point house,wind wind,int dtree){ | ^~~~ main.c:37:12: error: unknown type name 'point'; did you mean 'int'? 37 | int check2(point house,wind wind,int dtree){ | ^~~~~ | int main.c:37:24: error: unknown type name 'wind' 37 | int check2(point house,wind wind,int dtree){ | ^~~~ main.c: In function 'main': main.c:83:9: error: unknown type name 'point'; use 'struct' keyword to refer to the type 83 | point h[100],u[10],m[10],s[10]; | ^~~~~ | struct main.c:84:9: error: unknown type name 'wind'; use 'struct' keyword to refer to the type 84 | wind wind[100]; | ^~~~ | struct main.c:93:44: error: request for member 'x' in something not a structure or union 93 | scanf("%d %d",&h[i].x,&h[i].y); | ^ main.c:93:52: error: request for member 'y' in something not a structure or union 93 | scanf("%d %d",&h[i].x,&h[i].y); | ^ main.c:97:44: error: request for member 'x' in something not a structure or union 97 | scanf("%d %d",&u[i].x,&u[i].y); | ^ main.c:97:52: error: request for member 'y' in something not a structure or union 97 | scanf("%d %d",&u[i].x,&u[i].y); | ^ main.c:100:44: error: request for member 'x' in something not a structure or union 100 | scanf("%d %d",&m[i].x,&m[i].y); | ^ main.c:100:52: error: request for member 'y' in something not a structure or union 100 | scanf("%d %d",&m[i].x,&m[i].y); | ^ main.c:103:44: error: request for member 'x' in something not a structure or union 103 | scanf("%d %d",&s[i].x,&s[i].y); | ^ main.c:103:52: error: request for member 'y' in something not a structure or union 103 | scanf("%d %d",&s[i].x,&s[i].y); | ^ main.c:106:47: error: request for member 'w' in something not a structure or union 106 | scanf("%d %d",&wind[i].w,&wind[i].a); | ^ main.c:106:58: error: request for member 'a' in something not a structure or union 106 | scanf("%d %d",&wind[i].w,&wind[i].a); | ^ main.c:111:37: error: implicit declaration of function 'check2' [-Wimplicit-function-declaration] 111 | if(!check2(h[j],wind[i],du)){ | ^~~~~~ main.c:114:37: error: implicit declaration of function 'check' [-Wimplicit-function-declaration] 114 | if(!check(U,u,h[j],wind[i],du)){ | ^~~~~
s582851142
p00264
C++
#include<iostream> #include<vector> #include<cmath> #include<algorithm> #include<numeric> using namespace std; const double PI = 3.14159265358979; class Point { public: double x, y; Point(double x = 0.0, double y = 0.0) :x(x), y(y) {} }; class Wind { public: double w, a; }; bool include(double angle, double low, double high) { if(low < 0.0) { double l = low + 2.0 * PI; if(l <= angle) return true; } if(high > 2.0 * PI) { double h = high - 2.0 * PI; if(angle <= h) return true; } return low <= angle && angle <= high; } bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) { d /= 2.0; for(const auto &b: blossom) { Point dif(home.x - b.x, home.y - b.y); double angle = atan2(dif.y, dif.x); double dist = hypot(dif.y, dif.x); if(angle < 0.0) angle = angle + 2.0 * PI; if(dist <= wind.a + EPS && include(angle, wind.w - d, wind.w + d)) return true; } return false; } double toRadian(double d) { return d * PI / 180.0; } int main() { int H, R; while(cin >> H >> R, H | R) { vector<Point> home(H); for(auto &i: home) cin >> i.x >> i.y; int U, M, S; double du, dm, ds; cin >> U >> M >> S >> du >> dm >> ds; du = toRadian(du); dm = toRadian(dm); ds = toRadian(ds); vector<Point> plum(U), peach(M), cherry(S); for(auto &i: plum) cin >> i.x >> i.y; for(auto &i: peach) cin >> i.x >> i.y; for(auto &i: cherry) cin >> i.x >> i.y; vector<Wind> wind(R); for(auto &i: wind) cin >> i.w >> i.a; for(auto &i: wind) i.w = toRadian(i.w); // solve vector<int> number(H, 0); int maxNumber = 0; for(int i = 0; i < H; ++i) { for(int day = 0; day < R; ++day) { bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du); bool ng = false; ng |= savor(home[i], wind[day], plum, du); ng |= savor(home[i], wind[day], peach, dm); ng |= savor(home[i], wind[day], cherry, ds); if(!ok || ng) continue; ++number[i]; maxNumber = max(maxNumber, number[i]); } } if(maxNumber) { bool first = true; for(int i = 0; i < H; ++i) if(number[i] == maxNumber) { if(!first) cout << " "; first = false; cout << i + 1; } cout << endl; } else { cout << "NA" << endl; } } }
a.cc: In function 'bool savor(const Point&, const Wind&, const std::vector<Point>&, double)': a.cc:40:29: error: 'EPS' was not declared in this scope 40 | if(dist <= wind.a + EPS && include(angle, wind.w - d, wind.w + d)) return true; | ^~~
s534281777
p00264
C++
#include<bits/stdc++.h> using namespace std; typedef pair<int,int>pint; typedef vector<int>vint; #define pb push_back #define mp make_pair #define rep(i,n) for(int i=0;i<(n);i++) template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;} template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;} typedef complex<double>P; const double EPS=1e-9; const double PI=acos(-1); const int COUNTER_CLOCKWISE=1; const int CLOCKWISE=-1; const int ONLINE_BACK=2; const int ONLINE_FRONT=-2; const int ON_SEGMENT=0; inline double dot(const P &a, const P &b){return (conj(a) * b).real();} inline double cross(const P &a, const P &b){return (conj(a) * b).imag();} double toRad(double a){return a/180.0*PI;} double toDeg(double a){return a*180.0/PI;} P rotate(P p,double d){ return P(p.real()*cos(d)-p.imag()*sin(d),p.real()*sin(d)+p.imag()*cos(d)); } P getP(){ double x,y; scanf("%lf%lf",&x,&y); return P(x,y); } int ccw(P p0,P p1,P p2){ P a=p1-p0; P b=p2-p0; if(cross(a,b)>EPS)return COUNTER_CLOCKWISE; if(cross(a,b)<-EPS)return CLOCKWISE; if(dot(a,b)<-EPS)return ONLINE_BACK; if(norm(a)<norm(b))return ONLINE_FRONT; return ON_SEGMENT; } bool ok(P from,P to,double w,double a,double d){ if(abs(to-from)>a)return false; w=toRad(w); d=toRad(d); P p0=from+P(cos(w),sin(w))*a; P p1=rotate(p0,-d/2); P p2=rotate(p0,d/2); return (cross(from,p1,to)>EPS)&&(cross(from,p2,to)<EPS); } int H,R; vector<P>h; int U,M,S; double du,dm,ds; vector<P>u,m,s; void solve(){ h.resize(H); rep(i,H)h[i]=getP(); scanf("%d%d%d",&U,&M,&S); scanf("%lf%lf%lf",&du,&dm,&ds); u.resize(U); m.resize(M); s.resize(S); rep(i,U)u[i]=getP(); rep(i,M)m[i]=getP(); rep(i,S)s[i]=getP(); int cnt[100]={0}; while(R--){ double w,a; scanf("%lf%lf",&w,&a); rep(i,H){ bool f=false; if(ok(P(0,0),h[i],w,a,du))f=true; rep(j,U)if(ok(u[j],h[i],w,a,du))f=false; rep(j,M)if(ok(m[j],h[i],w,a,dm))f=false; rep(j,S)if(ok(s[j],h[i],w,a,ds))f=false; if(f)cnt[i]++; } } int ma=*max_element(cnt,cnt+H); if(ma==0){ puts("NA"); return; } bool f=false; rep(i,H){ if(cnt[i]!=ma)continue; if(f)printf(" "); else f=true; printf("%d",i+1); } puts(""); } int main(){ while(scanf("%d%d",&H,&R),H||R)solve(); return 0; }
a.cc: In function 'bool ok(P, P, double, double, double)': a.cc:58:18: error: too many arguments to function 'double cross(const P&, const P&)' 58 | return (cross(from,p1,to)>EPS)&&(cross(from,p2,to)<EPS); | ~~~~~^~~~~~~~~~~~ a.cc:24:15: note: declared here 24 | inline double cross(const P &a, const P &b){return (conj(a) * b).imag();} | ^~~~~ a.cc:58:43: error: too many arguments to function 'double cross(const P&, const P&)' 58 | return (cross(from,p1,to)>EPS)&&(cross(from,p2,to)<EPS); | ~~~~~^~~~~~~~~~~~ a.cc:24:15: note: declared here 24 | inline double cross(const P &a, const P &b){return (conj(a) * b).imag();} | ^~~~~
s765206702
p00264
C++
#include <bits/stdc++.h> using namespace std; #define EPS (1e-8) #define equals(a, b) (fabs((a) - (b)) < EPS ) #define dle(a, b) (equals(a, b) || a < b ) #define LIM 0.001 static const double PI = acos(-1); class Point{ public: double x, y; Point ( double x = 0, double y = 0): x(x), y(y){} Point operator + ( Point p ){ return Point(x + p.x, y + p.y); } Point operator - ( Point p ){ return Point(x - p.x, y - p.y); } Point operator * ( double a ){ return Point(x*a, y*a); } Point operator / ( double a ){ return Point(x/a, y/a); } double abs() { return sqrt(norm());} double norm() { return x*x + y*y; } bool operator < ( const Point &p ) const { return x != p.x ? x < p.x : y < p.y; } bool operator == ( const Point &p ) const { return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; } }; typedef Point Vector; class Segment{ public: Point p1, p2; Segment(Point s = Point(), Point t = Point()): p1(s), p2(t){} }; typedef Segment Line; double norm( Vector a ){ return a.x*a.x + a.y*a.y; } double abs( Vector a ){ return sqrt(norm(a)); } Point polar( double a, double r ){ return Point(cos(r)*a, sin(r)*a);} double getDistance( Vector a, Vector b ){ return abs(a - b); } double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; } double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; } static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; // EPS can be 0 // need to check for 920, 833, 866 int ccw( Point p0, Point p1, Point p2 ){ Vector a = p1 - p0; Vector b = p2 - p0; if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE; if ( cross(a, b) < -EPS ) return CLOCKWISE; if ( dot(a, b) < -EPS ) return ONLINE_BACK; if ( norm(a) < norm(b) ) return ONLINE_FRONT; return ON_SEGMENT; } double getDistance(Segment s, Point p){ if ( dot(s.p2 - s.p1, p - s.p1) < 0.0 ) return abs(p - s.p1); if ( dot(s.p1 - s.p2, p - s.p2) < 0.0 ) return abs(p - s.p2); return abs(cross(s.p2 - s.p1, p - s.p1)/abs(s.p2 - s.p1)); } double getDistance(Segment s1, Segment s2){ if ( isIntersect(s1, s2) ) return 0.0; return min( min(getDistance(s1, s2.p1), getDistance(s1, s2.p2)), min(getDistance(s2, s1.p1), getDistance(s2, s1.p2))); } double arg(Vector p){ return atan2(p.y, p.x); } bool isInSector(Point c, double a, double d, double r, Point p ){ double dist = abs(c - p); if ( dist <= 0.001 ){ cout << p.x << ", " << p.y << endl; } if ( dist > a ) return false; Vector v1 = Vector(a*cos((r + d/2)*PI/180), a*sin((r + d/2)*PI/180)); Vector v2 = Vector(a*cos((r - d/2)*PI/180), a*sin((r - d/2)*PI/180)); double ldist1 = getDistance(Segment(c, c+v1), p); double ldist2 = getDistance(Segment(c, c+v2), p); if ( ccw(c, c+v1, p) == CLOCKWISE && ccw(c, c+v2, p) == COUNTER_CLOCKWISE ) return true; return false; } int main(){ int h, r, C[3]; double D[3], x, y, w, a; Point O[3][100]; Point H[100]; int P[100]; while(1){ cin >> h >> r; if ( h == 0 && r == 0 ) break; for ( int i = 0; i < h; i++ ) P[i] = 0; for ( int i = 0; i < h; i++ ) cin >> H[i].x >> H[i].y; cin >> C[0] >> C[1] >> C[2] >> D[0] >> D[1] >> D[2]; for ( int i = 0; i < 3; i++ ){ for ( int j = 0; j < C[i]; j++ ){ cin >> O[i][j].x >> O[i][j].y ; } } for ( int i = 0; i < r; i++ ){ cin >> w >> a; for ( int b = 0; b < h; b++ ){ Point target = H[b]; bool coveredByOther = false; bool coveredByMe = isInSector(Point(0, 0), a, D[0], w, target); for ( int k = 0; k < 3; k++ ){ for ( int l = 0; l < C[k]; l++ ){ if ( isInSector(O[k][l], a, D[k], w, target)) coveredByOther = true; } } if (!coveredByOther && coveredByMe ) P[b]++; } } int maxv = 0; for ( int i = 0; i < h; i++ ) { maxv = max(maxv, P[i]); } if ( maxv == 0 ) cout << "NA" << endl; else { bool f = true; for ( int i = 0; i < h; i++ ){ if ( maxv == P[i] ) { if ( !f) cout << " "; cout << i+1; f = false; } } cout << endl; } } }
a.cc: In function 'double getDistance(Segment, Segment)': a.cc:75:10: error: 'isIntersect' was not declared in this scope 75 | if ( isIntersect(s1, s2) ) return 0.0; | ^~~~~~~~~~~
s676988207
p00264
C++
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <climits> #include <cfloat> using namespace std; const double PI = acos(-1.0); class Point { public: double y, x; Point(){ y = x = 0.0; } Point(double y0, double x0){ y = y0; x = x0; } Point operator+(const Point& p) const{ return Point(y + p.y, x + p.x); } Point operator-(const Point& p) const{ return Point(y - p.y, x - p.x); } Point operator*(double a) const{ return Point(y * a, x * a); } Point operator/(double a) const{ return Point(y / a, x / a); } double length() const{ return sqrt(y * y + x * x); } double dist(const Point& p) const{ return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2)); } double dot(const Point& p) const{ return y * p.y + x * p.x; // |a|*|b|*cos慮 } double cross(const Point& p) const{ return x * p.y - y * p.x; // |a|*|b|*sin慮 } }; bool check(Point& h, vector<Point>& t, double angle, double dir, double len) { int m = t.size(); for(int i=0; i<m; ++i){ if(h.dist(t[i]) > len) continue; double theta = atan2(h.y - t[i].y, h.x - t[i].x); for(int j=-1; j<=1; ++j){ if(dir - angle/2 + 2*PI*j < theta && theta < dir + angle/2 + 2*PI*j) return true; } } return false; } int main() { for(;;){ int n, r; cin >> n >> r; if(n == 0) return 0; vector<Point> h(n); for(int i=0; i<n; ++i) cin >> h[i].x >> h[i].y; vector<int> m(3); vector<double> angle(3); for(int i=0; i<3; ++i) cin >> m[i]; for(int i=0; i<3; ++i){ cin >> angle[i]; angle[i] *= PI / 180; } vector<vector<Point> > t(3); for(int i=0; i<3; ++i){ t[i].resize(m[i]); for(int j=0; j<m[i]; ++j) cin >> t[i][j].x >> t[i][j].y; } vector<double> dir(r), len(r); for(int i=0; i<r; ++i){ cin >> dir[i] >> len[i]; dir[i] *= PI / 180; } vector<int> ret; int maxDay = 1; for(int i=0; i<n; ++i){ int day = 0; for(int j=0; j<r; ++j){ bool ok = true; for(int k=0; k<3; ++k){ if(check(h[i], t[k], angle[k], dir[j], len[j])) ok = false; } if(ok && check(h[i], vector<Point>(1, Point(0, 0)), angle[0], dir[j], len[j])) ++ day; } if(day > maxDay){ ret.assign(1, i+1); maxDay = day; }else if(day == maxDay){ ret.push_back(i+1); } } if(ret.empty()){ cout << "NA" << endl; }else{ cout << ret[0]; for(unsigned i=1; i<ret.size(); ++i) cout << ' ' << ret[i]; cout << endl; } } }
a.cc: In function 'int main()': a.cc:123:38: error: cannot bind non-const lvalue reference of type 'std::vector<Point>&' to an rvalue of type 'std::vector<Point>' 123 | if(ok && check(h[i], vector<Point>(1, Point(0, 0)), angle[0], dir[j], len[j])) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:60:37: note: initializing argument 2 of 'bool check(Point&, std::vector<Point>&, double, double, double)' 60 | bool check(Point& h, vector<Point>& t, double angle, double dir, double len) | ~~~~~~~~~~~~~~~^
s828086912
p00264
C++
#include <iostream> #include <algorithm> #include <complex> #include <vector> #include <cmath> using namespace std; typedef complex<double> P; const double PI = acos(-1); const double EPS = 1e-9; bool hit(P p,double a,double b,double r){ if( abs(p) > r + EPS ) return false; double deg = atan2(p.imag(),p.real()); if( a <= deg && deg <= b ) return true; if( a <= deg+2*PI && deg+2*PI <= b ) return true; if( a <= deg-2*PI && deg-2*PI <= b ) return true; return false; } int main(){ int H,R; while(cin >> H >> R && H){ P home[100]; for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); int U,M,S; double du,dm,ds; cin >> U >> M >> S >> du >> dm >> ds; du = du / 180.*PI; dm = dm / 180.*PI; ds = ds / 180.*PI; du /= 2; dm /= 2; ds /= 2; vector< pair<P,double> > flower; for(int i = 0 ; i < U+M+S ; i++){ P p; cin >> p.real() >> p.imag(); flower.push_back(make_pair(p,(i<U?du:i<U+M?dm:ds))); } int answer[110] = {}; for(int i = 0 ; i < R ; i++){ double w,r; cin >> w >> r; w = w / 180. * PI; for(int j = 0 ; j < H ; j++){ int ok = hit(home[j],w-du,w+du,r); //cout << w-du << " " << w+du << endl; for(int k = 0 ; k < U+M+S ; k++){ ok &= !hit(home[j]-flower[k].first,w-flower[k].second,w+flower[k].second,r); } answer[j] += ok; } } int maximum = *max_element(answer,answer+H); int fst = 1; if( maximum == 0 ){ cout << "NA" << endl; goto exit; } for(int i = 0 ; i < H ; i++) if( maximum == answer[i] ){ if( fst == 0 ) cout << " "; cout << i+1; fst = 0; } cout << endl; exit:; } }
a.cc: In function 'int main()': a.cc:23:50: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double') 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~ ^~ ~~~~~~~~~~~~~~ | | | | | double | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: a.cc:23:65: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double' 23 | for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag(); | ~~~~~~~~~~~~^~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'double' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type&
s363902184
p00265
Java
import java.util.*; import java.io.*; import static java.lang.Math.*; class Main { public static void main( final String[] args ) { final Scanner stdin = new Scanner( System.in ); final String[] param = stdin.nextLine().split( " " ); final int N = Integer.parseInt( param[ 0 ] ); final int Q = Integer.parseInt( param[ 1 ] ); final String[] input = stdin.nextLine().split( " " ); final int[] cs = new int[ input.length ]; int maxValue = Integer.MIN_VALUE; for ( int i = 0; i < cs.length; i++ ) { cs[ i ] = Integer.parseInt( input[ i ] ); maxValue = max( maxValue, cs[ i ] ); } if ( N * Q < 10000000 ) { for ( int i = 0; i < Q; i++ ) { final int q = stdin.nextInt(); int maxMod = 0; for ( int i : cs ) { maxMod = max( maxMod, i % q ); } Systme.out.println( maxMod ); } } else { boolean[] ns = new boolean[ maxValue + 1 ]; for ( final int c : cs ) { ns[ c ] = true; } for ( int i = 0; i < Q; i++ ) { final int q = stdin.nextInt(); int stepIndex = 0; int maxMod = 0; while ( stepIndex <= maxValue ) { for ( int j = maxMod; stepIndex + j <= maxValue && j < q; j++ ) { if ( ns[ stepIndex + j ] ) { maxMod = j; } } stepIndex += q; if ( maxMod == q - 1 ) { break; } } System.out.println( maxMod ); } } } }
Main.java:27: error: variable i is already defined in method main(String[]) for ( int i : cs ) { ^ Main.java:30: error: package Systme does not exist Systme.out.println( maxMod ); ^ 2 errors
s839549182
p00265
Java
import java.io.*; public class ModuloQuery { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String input = in.readLine(); String[] tmp = input.split(" ",0); int n = Integer.parseInt(tmp[0]); int Q = Integer.parseInt(tmp[1]); int[] c = new int[n]; input = in.readLine(); tmp = input.split(" ",0); for (int i = 0; i < n; i++) c[i] = Integer.parseInt(tmp[i]); for (int i = 0; i < Q; i++) { int r, max = 0, q = Integer.parseInt(in.readLine()); for (int j = 0; j < n; j++) { r = c[j] % q; if (r > max) max = r; } System.out.println(max); } } }
Main.java:3: error: class ModuloQuery is public, should be declared in a file named ModuloQuery.java public class ModuloQuery { ^ 1 error
s398247879
p00265
C++
#include <iostream> #include <vector> using namespace std; vector<int> card; int main(void){ int N, Q, c, q; cin >> N >> Q; for(int i = 0; i < N; i++){ cin >> c; card.push_back(c); } sort(card.begin(), card.end()); int me = card[N - 1]; for(int i = 0; i < Q; i++){ cin >> q; int M = -1; int u = int(1.0 * me / q + 0.9); for(int i = 1; i <= u; i++){ vector<int>::iterator it = lower_bound(card.begin(), card.end(), q * i); if(it != card.begin()) M = max(M, *(it - 1) % q); } cout << M << endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:3: error: 'sort' was not declared in this scope; did you mean 'short'? 14 | sort(card.begin(), card.end()); | ^~~~ | short
s305779547
p00265
C++
#include<stdio.h> int main(){ int N,Q,c[300000],q[100000],i,j; innt j=-1 scanf("%d",&N); scanf("%d",&Q); for(i=0;i<N;i++){ scanf("%d",&c[i]); } for(i=0;i<Q;i++){ scanf("%d",&q[i]); } for(i=0;i<Q;i++){ for(j=0;j<N;j++){ if(c[j]%q[i]>g){ g=c[j]%q[i]; } } printf("%d\n",g); g=0; } return 0; }
a.cc: In function 'int main()': a.cc:5:1: error: 'innt' was not declared in this scope; did you mean 'int'? 5 | innt j=-1 | ^~~~ | int a.cc:16:14: error: 'g' was not declared in this scope 16 | if(c[j]%q[i]>g){ | ^ a.cc:20:15: error: 'g' was not declared in this scope 20 | printf("%d\n",g); | ^
s478024152
p00265
C++
#include<stdio.h> int main(){ int N,Q,c[300000],q[100000],i,j; int j=-1 scanf("%d",&N); scanf("%d",&Q); for(i=0;i<N;i++){ scanf("%d",&c[i]); } for(i=0;i<Q;i++){ scanf("%d",&q[i]); } for(i=0;i<Q;i++){ for(j=0;j<N;j++){ if(c[j]%q[i]>g){ g=c[j]%q[i]; } } printf("%d\n",g); g=0; } return 0; }
a.cc: In function 'int main()': a.cc:5:5: error: redeclaration of 'int j' 5 | int j=-1 | ^ a.cc:4:31: note: 'int j' previously declared here 4 | int N,Q,c[300000],q[100000],i,j; | ^ a.cc:16:14: error: 'g' was not declared in this scope 16 | if(c[j]%q[i]>g){ | ^ a.cc:20:15: error: 'g' was not declared in this scope 20 | printf("%d\n",g); | ^
s774836197
p00265
C++
#include<stdio.h> int main(){ int N,Q,c[300000],q[100000],i,j; int j=-1; scanf("%d",&N); scanf("%d",&Q); for(i=0;i<N;i++){ scanf("%d",&c[i]); } for(i=0;i<Q;i++){ scanf("%d",&q[i]); } for(i=0;i<Q;i++){ for(j=0;j<N;j++){ if(c[j]%q[i]>g){ g=c[j]%q[i]; } } printf("%d\n",g); g=0; } return 0; }
a.cc: In function 'int main()': a.cc:5:5: error: redeclaration of 'int j' 5 | int j=-1; | ^ a.cc:4:31: note: 'int j' previously declared here 4 | int N,Q,c[300000],q[100000],i,j; | ^ a.cc:16:14: error: 'g' was not declared in this scope 16 | if(c[j]%q[i]>g){ | ^ a.cc:20:15: error: 'g' was not declared in this scope 20 | printf("%d\n",g); | ^
s882517466
p00265
C++
int main(){ int N,Q,c[300000],q[100000],i,j,g=-1; scanf("%d",&N); scanf("%d",&Q); for(i=0;i<N;i++){ scanf("%d",&c[i]); } for(i=0;i<Q;i++){ scanf("%d",&q[i]); } for(i=0;i<Q;i++){ for(j=0;j<N;j++){ if(c[j]%q[i]>g){ g=c[j]%q[i]; } } printf("%d\n",g); g=0; } return 0; }
a.cc: In function 'int main()': a.cc:3:1: error: 'scanf' was not declared in this scope 3 | scanf("%d",&N); | ^~~~~ a.cc:17:1: error: 'printf' was not declared in this scope 17 | printf("%d\n",g); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main(){
s418973112
p00265
C++
#include <cstdio> #define MAX_N 300000 #define MAX_C 300000 int main(){ int N, Q; scanf("%d %d\n", &N, &Q); int card[MAX_N]; bool has_card[MAX_C+1]; for(int i = 0; i < N; i++){ scanf("%d", &card[i]); // printf("card %d ", card[i]); } for(int i = 0; i <= MAX_C; i++){ has_card[i] = false; } for(int i = 0; i < N; i++){ has_card[card[i]] = true; } // printf("\n"); for(int i = 0; i < Q; i++){ int q; scanf(" %d", &q); // printf("q = %d\n", q); bool found = false; for(int init = q-1; init => 0; init--){ for(int j = init; j < MAX_C ; j += q){ if(has_card[j]){ printf("%d\n", init); found = true; break; } } if(found){ break; } } } return 0; }
a.cc: In function 'int main()': a.cc:27:31: error: expected primary-expression before '>' token 27 | for(int init = q-1; init => 0; init--){ | ^
s899280983
p00265
C++
#include<iostream> int p[1<<20],n,q,a,i,j,c;main(){cin>>n>>q;for(i=0;i<n;i++){std::cin>>a;p[a]=1;}for(i=0;i<q;i++){cin>>a;for(j=a-1;j>=0;j--){c=j;while(1){if(p[c]){std::cout<<j<<"\n";goto E;}c+=a;if(c>300000)break;}}E:;}}
a.cc:2:26: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | int p[1<<20],n,q,a,i,j,c;main(){cin>>n>>q;for(i=0;i<n;i++){std::cin>>a;p[a]=1;}for(i=0;i<q;i++){cin>>a;for(j=a-1;j>=0;j--){c=j;while(1){if(p[c]){std::cout<<j<<"\n";goto E;}c+=a;if(c>300000)break;}}E:;}} | ^~~~ a.cc: In function 'int main()': a.cc:2:33: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 2 | int p[1<<20],n,q,a,i,j,c;main(){cin>>n>>q;for(i=0;i<n;i++){std::cin>>a;p[a]=1;}for(i=0;i<q;i++){cin>>a;for(j=a-1;j>=0;j--){c=j;while(1){if(p[c]){std::cout<<j<<"\n";goto E;}c+=a;if(c>300000)break;}}E:;}} | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~
s744007052
p00265
C++
#include<iostream> int p[1<<20],n,q,a,i,j,c;main(){std::cin>>n>>q;for(i=0;i<n;i++){std::cin>>a;p[a]=1;}for(i=0;i<q;i++){cin>>a;for(j=a-1;j>=0;j--){c=j;while(1){if(p[c]){std::cout<<j<<"\n";goto E;}c+=a;if(c>300000)break;}}E:;}}
a.cc:2:26: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | int p[1<<20],n,q,a,i,j,c;main(){std::cin>>n>>q;for(i=0;i<n;i++){std::cin>>a;p[a]=1;}for(i=0;i<q;i++){cin>>a;for(j=a-1;j>=0;j--){c=j;while(1){if(p[c]){std::cout<<j<<"\n";goto E;}c+=a;if(c>300000)break;}}E:;}} | ^~~~ a.cc: In function 'int main()': a.cc:2:102: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 2 | int p[1<<20],n,q,a,i,j,c;main(){std::cin>>n>>q;for(i=0;i<n;i++){std::cin>>a;p[a]=1;}for(i=0;i<q;i++){cin>>a;for(j=a-1;j>=0;j--){c=j;while(1){if(p[c]){std::cout<<j<<"\n";goto E;}c+=a;if(c>300000)break;}}E:;}} | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~
s836033119
p00265
C++
#include<iostream> using namespace std; int main(){ int c[300001] = { 0 },N,Q,max=1,num,q; cin >> N >> Q; for(int i=0;i<N;i++){ cin >> num; c[num]=1; if(max < num)max=num; } for(int i=0; i<Q ; i++){ cin >> q; for(int j=q-1;j>=0;j--){ for(int k = j;k <= max;k+=q){ if(c[k]){??? cout << j << endl; goto SKIP; } } } SKIP:; } return 0; }
a.cc: In function 'int main()': a.cc:16:15: error: expected primary-expression before '?' token 16 | if(c[k]){??? | ^ a.cc:16:16: error: expected primary-expression before '?' token 16 | if(c[k]){??? | ^ a.cc:16:17: error: expected primary-expression before '?' token 16 | if(c[k]){??? | ^ a.cc:17:24: error: expected ':' before ';' token 17 | cout << j << endl; | ^ | : a.cc:17:24: error: expected primary-expression before ';' token a.cc:17:24: error: expected ':' before ';' token 17 | cout << j << endl; | ^ | : a.cc:17:24: error: expected primary-expression before ';' token a.cc:17:24: error: expected ':' before ';' token 17 | cout << j << endl; | ^ | : a.cc:17:24: error: expected primary-expression before ';' token
s636912344
p00265
C++
#include<bits/stdc++.h> #define int long long #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3f #define EPS (1e-10) #define rep(i,n)for(int i=0;i<n;i++) using namespace std; typedef long long ll; typedef pair<int, int>P; bool b[10000001]; int main() { int n, q; scanf("%lld%lld", &n, &q); int s = INT_MAX, g = 0; rep(i, n) { int c; scanf("%d", &c); b[c] = true; s = min(s, c); g = max(g, c); } rep(i, q) { int p; scanf("%lld", &p); int Max = 0; int t = s; while (t <= g) { if (b[t]) { Max = t%p; t++; if (Max == p - 1)break; } else t += p; } printf("%lld\n", Max); } }
cc1plus: error: '::main' must return 'int'
s606772394
p00265
C++
# include <iostream> # include <algorithm> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <utility> # include <stack> # include <queue> # include <list> # include <bitset> # include <complex> #include<limits.h> #include<unordered_map> #include<unordered_set> #include<deque> #include<cstdio> typedef long long int ll; #define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i) #define TFOR(i,n)FOR(i,0,n) #define ALL(x) x.begin(),x.end(); const int INF = 1LL << 30; const ll LLINF = 1LL << 60; int main() { int n, q; std::cin >> n >> q; int max = 0; std::bitset<???00000> bit; TFOR(i, n) { int nn; std::cin >> nn; bit[nn-1] = 1; if (max < nn)max = nn; } TFOR(i, q) { int nn; std::cin >> nn; bool fl = 0; for (int j = nn-1; j>=0; --j) { for (int k =max/nn*nn+j; k > 0; k -= nn) { if (bit[k - 1] == 1) { std::cout << j << std::endl; fl = 1; } if (fl == 1)break; } if (fl == 1) { fl = 0; break; } } } return 0; }
a.cc: In function 'int main()': a.cc:31:29: error: template argument 1 is invalid 31 | std::bitset<???00000> bit; | ^ a.cc:35:20: error: invalid types 'int[int]' for array subscript 35 | bit[nn-1] = 1; | ^ a.cc:44:40: error: invalid types 'int[int]' for array subscript 44 | if (bit[k - 1] == 1) { std::cout << j << std::endl; fl = 1; } | ^
s612130536
p00265
C++
#include <stdio.h> #include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { long n,qq; scanf ("%ld %ld",&n,&qq); vector<long> c; int k; for(k=0;k<n;k++){ c.push_back(0); scanf ("%ld",&c[k]); } long q; long ans=0; for(int t=0;t<qq;t++){ ans=0 scanf ("%ld",&q); for(int s=0;s<k;s++){ if(ans<(c[s]%q)){ ans=c[s]%q; } if(ans==(q-1)) break; } printf("%ld\n",ans); } }
a.cc: In function 'int main()': a.cc:21:12: error: expected ';' before 'scanf' 21 | ans=0 | ^ | ; 22 | scanf ("%ld",&q); | ~~~~~
s167144935
p00265
C++
#include<iostream> #include<algorithm> using namespace std; int main(void){ int n,q; cin>>n>>q; int m=n; int a[300010]; while(m--)cin>>a[i]; int ans=0; for(int i=0;i<q;i++){ int x; cin>>x; for(int j=x;j<300000;j+=x)ans=max(ans,a[lower_bound(a,a+n,j)-a-1]%x); cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:9:22: error: 'i' was not declared in this scope 9 | while(m--)cin>>a[i]; | ^
s553525072
p00266
C
#include <iostream> #include <algorithm> #include <vector> int main(void){ clock_t startTime, endTime; using namespace std; int i,j; //階乗の計算 long long int fact[100000]={0}; for(i=0; i<100000; i++){ if(i==0) fact[i] = 1; else fact[i] = (fact[i-1]*i)%1000000007; } long int N,K; cin >> N; while(N!=0){ cin >> K; long int a,b; long int k=0, value=0, index = -1; vector <long int> data; vector <long int> data2; vector <long int>::iterator itr; //入れ替え前 for(i=0; i<N; i++){ data.push_back(i); data2.push_back(i); } //入れ替え for(i=0; i<K; i++){ cin >> a >> b; swap(data[a-1],data[b-1]); } //探索 for(i=0; i<N; i++){ //data[i]のインデックス取得 itr = find(data2.begin(), data2.end(), data[i]); index = itr - data2.begin(); k = data[i] - index; value += (data[i]-k)*fact[N-1-i]; value = value % 1000000007; data2.erase(itr); } cout << value <<endl; cin >> N; } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s083203370
p00266
C++
#include<iostream> #include<algorithm> using namespace std; const long long B = 1000000007; bool countOne(){ int N, R; cin >> N; if(N==0) return false; cin >> R; int *counter = new int[N](); for(int r=0; r<R; r++){ int s, t; *fin >> s >> t; for(int i=t-1; i>=s; i--){ int a = counter[i-1]; int b = counter[i]; if(a <= b){ counter[i] = a; counter[i-1] = b+1; } else{ counter[i] = a-1; counter[i-1] = b; } } for(int i=s+1; i<=t-1; i++){ int a = counter[i-1]; int b = counter[i]; if(a <= b){ counter[i] = a; counter[i-1] = b+1; } else{ counter[i] = a-1; counter[i-1] = b; } } } long long fact = 1, index=0; for(int n=1; n<N; n++){ index += counter[N-n-1]*fact; fact = ((n+1)*fact)%B; index = index%B; } cout << index << endl; delete[] counter; return true; } int main(){ while(countOne()){} return 0; }
a.cc: In function 'bool countOne()': a.cc:15:18: error: 'fin' was not declared in this scope 15 | *fin >> s >> t; | ^~~
s739410953
p00266
C++
#include<iostream> #include<algorithm> #include<vector> #include<map> using namespace std; const int N_MAX = 100000; const int R_MAX = 50; const int BigNumber = 1000000007; struct squaence{ int start,length, counter; squaence(){} squaence(int _start, int _end){ start = _start; length = _end - _start + 1; counter = 0; } }; int main(){ int s[R_MAX], t[R_MAX], N, R; long long SigmaFactrial[N_MAX+1]; SigmaFactrial[0] = 0; long long factrial = 1; for(int i=1; i<N_MAX+1; i++){ SigmaFactrial[i] = (SigmaFactrial[i-1]+factrial)%BigNumber; factrial = (factrial*i)%BigNumber; } while(true){ cin >> N; if(N==0) break; cin >> R; vector<int> st_vector(2*R); for(int r=0; r<R; r++){ int tmp_s, tmp_t; fin >> tmp_s >> tmp_t; s[r] = tmp_s-1; t[r] = tmp_t-1; st_vector[2*r ] = s[r]; st_vector[2*r+1] = t[r]; } sort(st_vector.begin(), st_vector.end()); st_vector.erase(unique(st_vector.begin(), st_vector.end()), st_vector.end()); const int st_vector_size = st_vector.size(); vector<squaence> number; int n=0; for(int j=0; j<st_vector_size; j++){ if(n <st_vector[j])number.push_back(squaence(n, st_vector[j]-1)); n = st_vector[j]; number.push_back(squaence(n, n)); n++; } if(n<N)number.push_back(squaence(n, N-1)); map<int,int> index_map; for(int i=0; i<st_vector_size; i++){ int v = st_vector[i]; auto it = find_if(number.begin(), number.end(), [v](squaence s){return s.start==v;}); index_map[v] = distance(number.begin(), it) ; } for(int r=0; r<R; r++){ int rs = index_map[s[r]]; int rt = index_map[t[r]]; int ns = number[rs].start; int nt = number[rt].start; int cs = number[rs].counter; int ct = number[rt].counter; if(ns<nt) ct++; else cs--; for(int i=rs+1; i<rt; i++){ int ni = number[i].start; if(ni < nt){ ct+=number[i].length; if(ns<ni) number[i].counter++; } if(ni < ns){ cs-=number[i].length; if(nt<ni) number[i].counter--; } } number[rs].counter = cs; number[rt].counter = ct; swap(number[rs], number[rt]); } n=0; long long index = 0; const int number_size = number.size(); for(int i=0; i<number_size; i++){ const squaence* s = &number[number_size-1-i]; if(s->counter != 0)index += s->counter * (SigmaFactrial[n+s->length] - SigmaFactrial[n]) % BigNumber; n += s->length; } while(index<0) index+=BigNumber; cout << index%BigNumber << endl; } return 0; }
a.cc: In function 'int main()': a.cc:43:25: error: 'fin' was not declared in this scope 43 | fin >> tmp_s >> tmp_t; | ^~~
s429306671
p00266
C++
#include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) using namespace std; typedef long long ll; const ll MOD = 1000000007LL; int N; ll fact[200000]; ll compute(vector<int> vec){ ll ret = fact[vec.size()]; set<int> S; rep(i,vec.size()) { int tp = -1; for(int j=N;j>=1;j--) if( !S.count(j) ) { tp = j; break; } assert( tp != -1 ); ll coef = tp - vec[i]; assert( ceof >= 0LL ); ret = ( ret - coef * fact[N-i-1] + MOD ) % MOD; S.insert(vec[i]); } return (ret-1LL+MOD)%MOD; } int main(){ fact[0] = fact[1] = 1LL; REP(i,2,200000) fact[i] = ( fact[i-1] * ll(i) ) % MOD; while( cin >> N, N ){ vector<int> vec(N); rep(i,N) vec[i] = i+1; int R; cin >> R; rep(_,R){ int s,t; cin >> s >> t; --s, --t; swap(vec[s],vec[t]); } cout << compute(vec) << endl; } return 0; }
In file included from /usr/include/c++/14/cassert:44, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106, from a.cc:1: a.cc: In function 'll compute(std::vector<int>)': a.cc:21:13: error: 'ceof' was not declared in this scope; did you mean 'coef'? 21 | assert( ceof >= 0LL ); | ^~~~
s808753994
p00266
C++
include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) using namespace std; typedef long long ll; const ll MOD = 1000000007LL; int N; ll fact[200000]; ll compute(vector<int> vec){ ll ret = fact[vec.size()]; set<int> S; rep(i,vec.size()) { int tp = -1; for(int j=N;j>=1;j--) if( !S.count(j) ) { tp = j; break; } assert( tp != -1 ); ll coef = tp - vec[i]; assert( coef >= 0LL ); ret = ( ret - ( coef * fact[N-i-1] ) % MOD + MOD ) % MOD; S.insert(vec[i]); } return (ret-1LL+MOD)%MOD; } int main(){ fact[0] = fact[1] = 1LL; REP(i,2,200000) fact[i] = ( fact[i-1] * ll(i) ) % MOD; while( cin >> N, N ){ vector<int> vec(N); rep(i,N) vec[i] = i+1; int R; cin >> R; rep(_,R){ int s,t; cin >> s >> t; --s, --t; swap(vec[s],vec[t]); } cout << compute(vec) << endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<bits/stdc++.h> | ^~~~~~~ a.cc:13:12: error: 'vector' was not declared in this scope 13 | ll compute(vector<int> vec){ | ^~~~~~ a.cc:13:19: error: expected primary-expression before 'int' 13 | ll compute(vector<int> vec){ | ^~~ a.cc: In function 'int main()': a.cc:31:10: error: 'cin' was not declared in this scope 31 | while( cin >> N, N ){ | ^~~ a.cc:32:5: error: 'vector' was not declared in this scope 32 | vector<int> vec(N); | ^~~~~~ a.cc:32:12: error: expected primary-expression before 'int' 32 | vector<int> vec(N); | ^~~ a.cc:33:14: error: 'vec' was not declared in this scope 33 | rep(i,N) vec[i] = i+1; | ^~~ a.cc:40:12: error: 'vec' was not declared in this scope 40 | swap(vec[s],vec[t]); | ^~~ a.cc:40:7: error: 'swap' was not declared in this scope 40 | swap(vec[s],vec[t]); | ^~~~ a.cc:42:5: error: 'cout' was not declared in this scope 42 | cout << compute(vec) << endl; | ^~~~ a.cc:42:21: error: 'vec' was not declared in this scope 42 | cout << compute(vec) << endl; | ^~~ a.cc:42:24: error: 'compute' cannot be used as a function 42 | cout << compute(vec) << endl; | ^ a.cc:42:29: error: 'endl' was not declared in this scope 42 | cout << compute(vec) << endl; | ^~~~
s665943316
p00266
C++
#include <iostream> #include <set> #include <vector> using namespace std; typedef long long ll; #define MOD 1000000007LL int n, m; int a[52], b[52]; int t[100002]; ll f[100002]; vector<int> cg; void mkFact(){ f[0] = 1; for(ll i = 1; i <= 100000; i++){ f[i] = f[i - 1] * i; f[i] %= MOD; } } void show(int nn, int mm){ string s; for(int i = 0; i < nn; i++){ s += (char)('a' + i); } for(int i = 0; i < mm; i++){ next_permutation(s.begin(), s.end()); } cout << s << endl; } void show2(){ for(int i = 0; i < n; i++){ cout << (char)(t[i] + 'a'); } cout << endl; } void solve(){ ll res = 0; for(int i = 0; i < n - 1; i++){ int x = t[i]; int low = min(i, x); for(int j = 0; j < cg.size(); j++){ if(cg[j] >= i) break; int y = t[cg[j]]; if(cg[j] < x && y > x){ low--; } else if(x <= cg[j] && y < x){ low++; } } x -= low; res += (ll)x * f[n - i - 1]; res %= MOD; } cout << res << endl; } int main(){ mkFact(); while(cin >> n, n){ for(int i = 0; i < n; i++){ t[i] = i; } set<int> st; cin >> m; for(int i = 0; i < m; i++){ cin >> a[i] >> b[i]; a[i]--; b[i]--; swap(t[a[i]], t[b[i]]); st.insert(a[i]); st.insert(b[i]); } cg.clear(); for(set<int>::iterator iter = st.begin(); iter != st.end(); iter++){ cg.push_back(*iter); } solve(); } }
a.cc: In function 'void show(int, int)': a.cc:30:5: error: 'next_permutation' was not declared in this scope 30 | next_permutation(s.begin(), s.end()); | ^~~~~~~~~~~~~~~~
s548250469
p00268
C++
#include <cmath> #include <queue> #include <cstdio> #include <cassert> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const double EPS=1e-8; const double PI=acos(-1); struct point{ double x,y; point():x(0),y(0){} point(double x,double y):x(x),y(y){} point &operator+=(const point &a){ x+=a.x; y+=a.y; return *this; } point &operator-=(const point &a){ x-=a.x; y-=a.y; return *this; } point &operator*=(double c){ x*=c; y*=c; return *this; } point &operator/=(double c){ x/=c; y/=c; return *this; } point operator+(const point &a)const{ return point(x+a.x,y+a.y); } point operator-(const point &a)const{ return point(x-a.x,y-a.y); } point operator/(double c)const{ return point(x/c,y/c); } point operator-()const{ return point(-x,-y); } bool operator< (const point &a)const{ return x+EPS<a.x || (abs(x-a.x)<EPS && y+EPS<a.y); } bool operator==(const point &a)const{ return abs(x-a.x)<EPS && abs(y-a.y)<EPS; } bool operator!=(const point &a)const{ return abs(x-a.x)>EPS || abs(y-a.y)>EPS; } }; double cross(const point &a,const point &b){ return a.x*b.y-a.y*b.x; } double arg(const point &a){ double t=atan2(a.y,a.x); return t<0?t+2*PI:t; } typedef vector<point> polygon; bool is_ccw(const polygon &F){ int n=F.size(); double A=0; rep(i,n) A+=cross(F[i],F[(i+1)%n]); return A>-EPS; } // trace the frame of a polygon vector<int> trace(int n,const vector<int> *G,int u0,int i0){ vector<int> F; int u=u0,i=i0; do{ F.push_back(u); int v=G[u][i]; int k=G[v].size(); rep(j,k) if(G[v][j]==u) i=(j-1+k)%k; u=v; }while(u!=u0); return F; } // normalize the list of vertices vector<int> reg(vector<int> a){ int k=min_element(a.begin(),a.end())-a.begin(); rep(i,k){ a.push_back(a[0]); a.erase(a.begin()); } return a; } int main(){ for(int n,m;scanf("%d%d",&n,&m),n;){ point P[100]; rep(u,n) scanf("%lf%lf",&P[u].x,&P[u].y); vector<int> G[100]; rep(i,m){ int u,v; scanf("%d%d",&u,&v); u--; v--; G[u].push_back(v); G[v].push_back(u); } // angle sort rep(u,n){ int k=G[u].size(); pair<double,int> A[100]; rep(i,k){ int v=G[u][i]; A[i]=make_pair(arg(P[v]-P[u]),v); } sort(A,A+k); rep(i,k) G[u][i]=A[i].second; } // decompose to polygons vector< vector<int> > F; // set of polygons rep(u,n) rep(i,G[u].size()) F.push_back(reg(trace(n,G,u,i))); sort(F.begin(),F.end()); F.erase(unique(F.begin(),F.end()),F.end()); // find the outside boundary int n2=F.size(),u0=-1; rep(u,n2){ int k=F[u].size(); polygon H(k); rep(i,k) H[i]=P[F[u][i]]; if(!is_ccw(H)){ assert(u0==-1); u0=u; } } assert(u0!=-1); // build the dual graph vector<int> G2[100]; rep(u,n2) rep(v,u) { bool ok=false; int nu=F[u].size(),nv=F[v].size(); rep(i,nu) rep(j,nv) if(F[u][i]==F[v][(j+1)%nv] && F[u][(i+1)%nu]==F[v][j]) ok=true; if(ok){ G2[u].push_back(v); G2[v].push_back(u); } } // BFS int d[100]; rep(u,n2) d[u]=(u==u0?0:-1); queue<int> Q; Q.push(u0); while(!Q.empty()){ int u=Q.front(); Q.pop(); rep(i,G2[u].size()){ int v=G2[u][i]; if(d[v]==-1) d[v]=d[u]+1, Q.push(v); } } printf("%d\n",*max_element(d,d+n2)); } return 0; }
a.cc: In function 'std::vector<int> reg(std::vector<int>)': a.cc:59:15: error: 'min_element' was not declared in this scope 59 | int k=min_element(a.begin(),a.end())-a.begin(); | ^~~~~~~~~~~ a.cc: In function 'int main()': a.cc:87:25: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 87 | sort(A,A+k); | ^~~~ | sqrt a.cc:94:17: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 94 | sort(F.begin(),F.end()); | ^~~~ | sqrt a.cc:95:25: error: 'unique' was not declared in this scope 95 | F.erase(unique(F.begin(),F.end()),F.end()); | ^~~~~~ a.cc:135:32: error: 'max_element' was not declared in this scope 135 | printf("%d\n",*max_element(d,d+n2)); | ^~~~~~~~~~~
s924946478
p00268
C++
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<map> #include<set> #include<string> #include<stack> #include<cstdio> #include<cmath> using namespace std; typedef long long LL; typedef long double LD; typedef pair<int,int> P; typedef pair<int,P> P1; typedef pair<int,pair<bool,double> > P2; #define fr first #define sc second #define mp make_pair #define pb push_back #define rep(i,x) for(int i=0;i<x;i++) #define rep1(i,x) for(int i=1;i<=x;i++) #define rrep(i,x) for(int i=x-1;i>=0;i--) #define rrep1(i,x) for(int i=x;i>0;i--) #define sor(v) sort(v.begin(),v.end()) #define rev(s) reverse(s.begin(),s.end()) #define lb(vec,a) lower_bound(vec.begin(),vec.end(),a) #define ub(vec,a) upper_bound(vec.begin(),vec.end(),a) #define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end()) #define min_3(a,b,c) min(a,min(b,c)) #define max_3(a,b,c) max(a,max(b,c)) #define mp1(a,b,c) P1(a,P(b,c)) #define mp2(a,b,c) P2(a,pair<bool,double>(b,c)) #define pque(a) priority_queue<a> #define rpque(a) priority_queue<a,vector<a>,greater<a>> const int INF=1000000000; const int dre_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; const int dre_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}}; const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880}; bool com(P2 x,P2 y){ if(x.sc.fr!=y.sc.fr)return x.sc.fr; return x.sc.sc>=y.sc.sc; } int main(){ int ppp=0; while(1){ ppp++; if(ppp>=6)Sleep(100000); static int v,w; static int x[110],y[110]; static int s,t; scanf("%d%d",&v,&w); if(v==0&&w==0)break; rep1(i,v)scanf("%d%d",&x[i],&y[i]); static vector<P1> V_; V_.clear(); rep1(i,v){ V_.pb(mp1(x[i],y[i],i)); } sor(V_); static vector<P2> vec_[110]; rep1(i,v){ vec_[i].clear(); vec_[i].pb(mp2(0,false,-INF)); rep1(j,v){ if(i==j)continue; if(x[i]<x[j]){ vec_[i].pb(mp2(j,true,(double)(y[j]-y[i])/(x[j]-x[i]))); } else if(x[i]>x[j]){ vec_[i].pb(mp2(j,false,(double)(y[j]-y[i])/(x[j]-x[i]))); } else { if(y[j]>y[i])vec_[i].pb(mp2(j,true,(double)INF)); else vec_[i].pb(mp2(j,true,(double)-INF)); } } sort(vec_[i].begin(),vec_[i].end(),com); } static int e; static vector<int> V; V.clear(); static bool edge[110][110]; static vector<int> vec[110]; e=w; rep(i,v)V.pb(V_[i].sc.sc); rep(i,110)rep(j,110)edge[i][j]=false; rep(i,e){ scanf("%d%d",&s,&t); edge[s][t]=true; edge[t][s]=true; } rep1(i,v){ vec[i].clear(); rep(j,vec_[i].size()){ vec[i].pb(vec_[i][j].fr); } } int ret=0; while(e>0){ ret++; int a=-1; rep(i,V.size()){ rep(j,105){ if(edge[V[i]][j]){a=V[i]; break;} } if(a!=-1)break; } int b=0,c=a; while(1){ if(c==-1||vec[c].size()==0)break; rep(i,vec[c].size()){ if(vec[c][i]==b){ i++; i%=vec[c].size(); while(!edge[c][vec[c][i]]){ i++; i%=vec[c].size(); } edge[c][vec[c][i]]=false; edge[vec[c][i]][c]=false; e--; b=c; c=vec[c][i]; break; } } if(c==a)break; } bool updata=true; while(updata){ updata=false; rep1(i,v){ int cnt=0; int t=105; rep1(j,v){ if(edge[i][j]){cnt++; t=j;} } if(cnt==1){ updata=true; edge[i][t]=false; edge[t][i]=false; e--; } } } } printf("%d\n",ret); } }
a.cc: In function 'int main()': a.cc:52:34: error: 'Sleep' was not declared in this scope 52 | ppp++; if(ppp>=6)Sleep(100000); | ^~~~~
s789091142
p00268
C++
#include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<complex> #include<deque> #include<vector> using namespace std; double eps=1e-6; double x[110]; double y[110]; double px[700]; double py[700]; int ijk[700]; int v[700]; const double EPS = 1e-8; const double INF = 1e12; double PI=3.14159265358; struct P{ double x;double y; P(){} P(double X,double Y){ x=X;y=Y; } P operator+ (const P &a)const{ return P(x+a.x,y+a.y); } P operator- (const P &a)const{ return P(x-a.x,y-a.y); } P operator* (const double &a)const{ return P(x*a,y*a); } /*operator+ (P a){ return P(x+a.x,y+a.y); } operator+ (P a){ return P(x+a.x,y+a.y); }*/ }; inline bool operator < (const P& a, const P& b) { return a.x<b.x||(a.x==b.x&&a.y<b.y); } inline double cross(const P& a, const P& b) { return a.x*b.y-a.y*b.x; } inline double dot(const P& a, const P& b) { return a.x*b.x+a.y*b.y; } inline int ccw(const P &a, const P &b, const P &c) { b=b-a;c=c-a; if (cross(b, c) > 0) return +1; // counter clockwise if (cross(b, c) < 0) return -1; // clockwise if (dot(b, c) < 0) return +2; // c--a--b on line if (b.x*b.x+b.y*b.y<c.x*c.x+c.y*c.y) return -2; // a--b--c on line return 0; } #define se second #define fi first bool intersectSS(const pair<P,P> &s, const pair<P,P> &t) { return ccw(s.fi,s.se,t.fi)*ccw(s.fi,s.se,t.se) <= 0 && ccw(t.fi,t.se,s.fi)*ccw(t.fi,t.se,s.se) <= 0; } P pt[700]; P ps[300]; int s[400]; int t[400]; double left[400]; double right[400]; vector<pair<int,int> >g[700]; int UF[700]; int FIND(int a){ if(UF[a]<0)return a; return UF[a]=FIND(UF[a]); } void UNION(int a,int b){ a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a; } int main(){ int a,b; while(scanf("%d%d",&a,&b),a){ for(int i=0;i<700;i++)UF[i]=-1; for(int i=0;i<700;i++)g[i].clear(); for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i); for(int i=0;i<a;i++){ double X=cos(1)*x[i]-sin(1)*y[i]; double Y=sin(1)*x[i]+cos(1)*y[i]; x[i]=X; y[i]=Y; ps[i]=P(x[i],y[i]); } for(int i=0;i<b;i++){ int p,q;scanf("%d%d",&p,&q); p--;q--; s[i]=p;t[i]=q; px[i*2]=(x[p]+x[q])/2+eps; py[i*2]=(y[p]+y[q])/2; px[i*2+1]=(x[p]+x[q])/2-eps; py[i*2+1]=(y[p]+y[q])/2; pt[i*2]=P(px[i*2],py[i*2]); pt[i*2+1]=P(px[i*2+1],py[i*2+1]); } deque<pair<int,int> >Q; for(int i=0;i<a;i++){ vector<pair<double,pair<int,int> > >vec; for(int j=0;j<b;j++){ if(s[j]==i){ vec.push_back(make_pair(atan2(y[t[j]]-y[i],x[t[j]]-x[i]),make_pair(j,t[j]))); } if(t[j]==i){ vec.push_back(make_pair(atan2(y[s[j]]-y[i],x[s[j]]-x[i]),make_pair(j,s[j]))); } } std::sort(vec.begin(),vec.end()); int sz=vec.size(); for(int j=0;j<vec.size();j++){ double th=vec[j].first; double th2=vec[(j+1)%sz].first; if(th>th2)th2+=2*PI; if(th2-th<=PI+EPS)continue; for(int k=0;k<2;k++)for(int l=0;l<2;l++){ if(intersectSS(make_pair(pt[vec[j].second.first*2+k],pt[vec[(j+1)%sz].second.first*2+l]), make_pair(ps[i],ps[vec[j].second.second]))&&intersectSS(make_pair(pt[vec[j].second.first*2+k],pt[vec[(j+1)%sz].second.first*2+l]), make_pair(ps[i],ps[vec[(j+1)%sz].second.second]))){ g[vec[j].second.first*2+k].push_back(make_pair(vec[(j+1)%sz].second.first*2+l,0)); g[vec[(j+1)%sz].second.first*2+l].push_back(make_pair(vec[j].second.first*2+k,0)); UNION(vec[j].second.first*2+k,vec[(j+1)%sz].second.first*2+l); } } } } for(int i=0;i<b*2;i++){ ijk[i]=999999999; v[i]=0; bool OK=true; int tt=s[i/2]; for(int j=0;j<b;j++){ if(tt==s[j]||tt==t[j])continue; if(intersectSS(make_pair(ps[tt],ps[tt]+(pt[i]-ps[tt])*10000.0),make_pair(ps[s[j]],ps[t[j]]))){ OK=false;break; } } tt=t[i/2]; for(int j=0;j<b;j++){ if(tt==s[j]||tt==t[j])continue; if(intersectSS(make_pair(ps[tt],ps[tt]+(pt[i]-ps[tt])*10000.0),make_pair(ps[s[j]],ps[t[j]]))){ OK=false;break; } } if(OK){ ijk[i]=0; Q.push_back(make_pair(0,i)); } for(int j=i+1;j<b*2;j++){ int cnt=0; if(FIND(i)==FIND(j))continue; for(int k=0;k<b;k++){ if(intersectSS(make_pair(ps[s[k]],ps[t[k]]),make_pair(pt[i],pt[j]))){ cnt++; if(cnt>1)break; } } if(cnt<2){ if(cnt==0){ UNION(i,j); } g[i].push_back(make_pair(j,cnt)); g[j].push_back(make_pair(i,cnt)); } } } while(Q.size()){ int cost=-Q.front().first; int at=Q.front().second;Q.pop_front(); if(v[at])continue; v[at]=1; for(int i=0;i<g[at].size();i++){ if(!v[g[at][i].first]&&ijk[g[at][i].first]>cost+g[at][i].second){ ijk[g[at][i].first]=cost+g[at][i].second; if(g[at][i].second==1)Q.push_back(make_pair(-ijk[g[at][i].first],g[at][i].first)); else Q.push_front(make_pair(-ijk[g[at][i].first],g[at][i].first)); } } } int ret=0; for(int i=0;i<b*2;i++)ret=max(ret,ijk[i]); printf("%d\n",ret); } }
a.cc: In function 'int ccw(const P&, const P&, const P&)': a.cc:53:13: error: passing 'const P' as 'this' argument discards qualifiers [-fpermissive] 53 | b=b-a;c=c-a; | ^ a.cc:19:8: note: in call to 'constexpr P& P::operator=(P&&)' 19 | struct P{ | ^ a.cc:53:19: error: passing 'const P' as 'this' argument discards qualifiers [-fpermissive] 53 | b=b-a;c=c-a; | ^ a.cc:19:8: note: in call to 'constexpr P& P::operator=(P&&)' 19 | struct P{ | ^
s022392472
p00268
C++
#include <bits/stdc++.h> #ifdef LOCAL #include "dump.hpp" #else #define dump(...) #endif using namespace std; struct point { int x, y; explicit point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {} point(const point &p):x(p.x), y(p.y) {} point operator+(const point &p) const { return point(x + p.x, y + p.y); } point operator-(const point &p) const { return point(x - p.x, y - p.y); } point operator*(double s) const { return point(x * s, y * s); } point operator*(const point &p) const { return point(x * p.x - y * p.y, x * p.y + y * p.x); } point operator/(double s) const { return point(x / s, y / s); } bool operator<(const point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const point &p) const { return x == p.x && y == p.y; } }; inline double angle(const point &p) { return atan2(p.y, p.x); } inline int cross(const point &a, const point &b) { return a.x * b.y - a.y * b.x; } struct segment { point a, b; segment(const point &a_, const point &b_):a(a_), b(b_){} }; struct edge { int to; double theta; bool used; edge(int to_, double theta_):to(to_), theta(theta_), used(false) {} inline bool operator<(const edge &e) const { return theta < e.theta; } }; inline istream &operator>>(istream &is, point &p){ return is >> p.x >> p.y; } inline ostream &operator<<(ostream &os, const point &p){ return os << make_pair(p.x, p.y); } inline bool outside(const vector<int> &P, const vector<point> &points) { const int n = P.size(); for(int i = 0; i < n; ++i) { const point &a = points[P[i]]; const point &b = points[P[(i + 1) % n]]; const point &c = points[P[(i + 2) % n]]; const int tmp = cross(b - a, c - a); if(tmp != 0) return tmp > 0; } assert(false); } inline bool neighbor(const vector<int> &a, const vector<int> &b) { int pa = a.back(); for(const auto &ca : a) { int pb = b.back(); for(const auto &cb : b) { if((pa == pb && ca == cb) || (pa == cb && ca == pb)) return true; pb = cb; } pa = ca; } return false; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); for(int n, m; cin >> n >> m && n;) { vector<point> points(n); for(auto &e : points) cin >> e; vector<vector<edge>> G(n); for(int i = 0; i < m; ++i) { int s, t; cin >> s >> t; --s; --t; G[s].emplace_back(t, angle(points[t] - points[s])); G[t].emplace_back(s, angle(points[s] - points[t])); } for(auto &edges : G) sort(begin(edges), end(edges)); int s = -1; const int V = 2 + m - n; vector<vector<int>> faces; faces.reserve(V); for(int i = 0; i < n; ++i) { for(int j = 0; j < static_cast<int>(G[i].size()); ++j) { int v = i; int e_idx = j; vector<int> P; while(true) { edge &e = G[v][e_idx]; if(e.used) break; e.used = true; P.emplace_back(v); for(int k = 0; k < static_cast<int>(G[e.to].size()); ++k) { if(G[e.to][k].to == v) { v = e.to; e_idx = k + 1; if(e_idx >= static_cast<int>(G[e.to].size())) e_idx = 0; break; } } } if(P.size() >= 3) { if(s == -1 && outside(P, points)) s = faces.size(); faces.emplace_back(P); } } } vector<vector<int>> Gf(V); for(int i = 0; i < V; ++i) { for(int j = i + 1; j < V; ++j) { if(neighbor(faces[i], faces[j])) { Gf[i].emplace_back(j); Gf[j].emplace_back(i); } } } vector<int> dist(V, INT_MAX); queue<int> que; dist[s] = 0; que.push(s); while(!que.empty()) { const int v = que.front(); que.pop(); for(const auto &to : Gf[v]) { if(dist[to] == INT_MAX) { dist[to] = dist[v] + 1; que.push(to); } } } cout << *max_element(begin(dist), end(dist)) << endl; } return EXIT_SUCCESS; }
a.cc: In function 'std::ostream& operator<<(std::ostream&, const point&)': a.cc:74:19: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::pair<int, int>') 74 | return os << make_pair(p.x, p.y); | ~~ ^~ ~~~~~~~~~~~~~~~~~~~ | | | | | std::pair<int, int> | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]' 306 | operator<<(nullptr_t) | ^~~
s244460381
p00268
C++
#include <bits/stdc++.h> #define M_PI (3.141592653589793) using namespace std; const double EPS = 1e-10; class Point{ public: double x, y; int id; Point(double x = 0, double y = 0): x(x), y(y){} Point operator + (Point p){return Point(x + p.x, y + p.y);} Point operator - (Point p){return Point(x - p.x, y - p.y);} Point operator * (double a){return Point(x * a, y * a);} Point operator / (double a){return Point(x / a, y / a);} Point operator * (const Point &a){ return Point(x * a.x - y * a.y, x * a.y + y * a.x); } bool operator < (const Point &p) const { return (x != p.x ? x < p.x : y < p.y); } bool operator == (const Point &p) const { return (fabs(x - p.x) < EPS && fabs(y - p.y) < EPS); } }; typedef Point Vector; typedef vector<Point> Polygon; double dot(Vector a, Vector b){return (a.x * b.x + a.y * b.y);} double abs(Vector a){return (sqrt(dot(a, a)));} double cross(Vector a, Vector b){return (a.x * b.y - a.y * b.x);} int ccw(Point p0, Point p1, Point p2) { Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > EPS) return (+1); //p0, p1, p2 が反時計周り if (cross(a, b) < -EPS) return (-1);//p0, p1, p2 が時計回り if (dot(a, b) < -EPS) return (+2); //p2--p0--p1 の順で一直線上 if (norm(a) < norm(b)) return (-2); //p0--p1--p2 の順で一直線上 return (0); //p0--p2--p1 の順で一直線上 } Polygon conhel(Polygon& ps) { sort(ps.begin(), ps.end()); int k = 0, n = (int)ps.size(); Polygon qs(n * 2); for (int i = 0; i < n; i++){ while (k > 1 && cross(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < -EPS) k--; qs[k++] = ps[i]; } for (int i = n - 2, t = k; i >= 0; i--){ while (k > t && cross(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < -EPS) k--; qs[k++] = ps[i]; } qs.resize(k - 1); return (qs); } double getCos(Vector a, Vector b) { return (dot(a, b) / (abs(a) * abs(b))); } double getArg(Vector v) { return (atan2(v.y, v.x)); } Point rotate(Point t, Point p, double r) { double ta = cos(r) * (t.x - p.x) - sin(r) * (t.y - p.y) + p.x; double tb = sin(r) * (t.x - p.x) + cos(r) * (t.y - p.y) + p.y; return (Point(ta, tb)); } int main() { int N, M; while (scanf("%d %d", &N, &M) && N){ vector<Point> P(N); vector<int> to[128]; bool exist[128][128] = {0}; for (int i = 0; i < N; i++){ scanf("%lf %lf", &P[i].x, &P[i].y); P[i].id = i; } for (int i = 0; i < M; i++){ int x, y; scanf("%d %d", &x, &y); to[--x].push_back(--y); to[y].push_back(x); exist[x][y] = exist[y][x] = 1; } Polygon Q = P; Q = conhel(Q); vector<int> belong[128][128]; for (int i = 0; i < Q.size(); i++){ int u = Q[i].id, v = Q[(i + 1) % Q.size()].id; belong[u][v].push_back(0); belong[v][u].push_back(0); } int k = 1; set<vector<int> > s; for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ if (P[j] < P[i] && exist[i][j] && belong[i][j].size() < 2){ vector<int> v; v.push_back(i); v.push_back(j); while (1){ int nextP = -1; int vv = v[v.size() - 1], uu = v[v.size() - 2]; for (int l = 0; l < to[vv].size(); l++){ if (to[vv][l] == vv || to[vv][l] == uu) continue; double thetaT, thetaC; thetaT = acos(getCos(P[uu] - P[vv], P[to[vv][l]] - P[vv])); if (ccw(P[uu], P[vv], P[to[vv][l]]) > 0) thetaT = 2 * M_PI - thetaT; if (nextP != -1){ thetaC = acos(getCos(P[uu] - P[vv], P[nextP] - P[vv])); if (ccw(P[uu], P[vv], P[nextP]) > 0) thetaC = 2 * M_PI - thetaC; } if (nextP == -1 || thetaT < thetaC) nextP = to[vv][l]; } if (nextP == i) break; v.push_back(nextP); } vector<int> ss = v; sort(ss.begin(), ss.end()); ss.erase(unique(ss.begin(), ss.end()), ss.end()); if (s.find(ss) != s.end()) continue; else s.insert(ss); for (int it = 0; it < v.size(); it++){ int uu = v[it], vv = v[(it + 1) % v.size()]; belong[uu][vv].push_back(k); belong[vv][uu].push_back(k); } k++; } } } vector<int> G[1024]; for (int i = 0; i < N; i++){ for (int j = i + 1; j < N; j++){ if (belong[i][j].size()){ assert(belong[i][j].size() == 2); int u = belong[i][j][0], v = belong[i][j][1]; G[u].push_back(v); G[v].push_back(u); } } } int ans = 0; int done[1024]; fill(done, done + 1024, -1); queue<pair<int, int> > q; for(q.push(make_pair(0, 0)); q.size(); q.pop()){ pair<int, int> x = q.front(); if (~done[x.first]) continue; done[x.first] = x.second; ans = max(ans, x.second); for (int i = 0; i < G[x.first].size(); i++){ q.push(make_pair(G[x.first][i], x.second + 1)); } } printf("%d\n", ans); } return (0); }
a.cc:3:9: warning: "M_PI" redefined 3 | #define M_PI (3.141592653589793) | ^~~~ In file included from /usr/include/c++/14/cmath:47, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:114, from a.cc:1: /usr/include/math.h:1121:10: note: this is the location of the previous definition 1121 | # define M_PI 3.14159265358979323846 /* pi */ | ^~~~ a.cc: In function 'int ccw(Point, Point, Point)': a.cc:43:13: error: no matching function for call to 'norm(Vector&)' 43 | if (norm(a) < norm(b)) return (-2); //p0--p1--p2 の順で一直線上 | ~~~~^~~ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:959:5: note: candidate: 'template<class _Tp> _Tp std::norm(const complex<_Tp>&)' 959 | norm(const complex<_Tp>& __z) | ^~~~ /usr/include/c++/14/complex:959:5: note: template argument deduction/substitution failed: a.cc:43:13: note: 'Vector' {aka 'Point'} is not derived from 'const std::complex<_Tp>' 43 | if (norm(a) < norm(b)) return (-2); //p0--p1--p2 の順で一直線上 | ~~~~^~~ /usr/include/c++/14/complex:2453:5: note: candidate: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::norm(_Tp)' 2453 | norm(_Tp __x) | ^~~~ /usr/include/c++/14/complex:2453:5: note: template argument deduction/substitution failed: /usr/include/c++/14/complex: In substitution of 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::norm(_Tp) [with _Tp = Point]': a.cc:43:13: required from here 43 | if (norm(a) < norm(b)) return (-2); //p0--p1--p2 の順で一直線上 | ~~~~^~~ /usr/include/c++/14/complex:2453:5: error: no type named '__type' in 'struct __gnu_cxx::__promote<Point, false>' 2453 | norm(_Tp __x) | ^~~~ a.cc:43:23: error: no matching function for call to 'norm(Vector&)' 43 | if (norm(a) < norm(b)) return (-2); //p0--p1--p2 の順で一直線上 | ~~~~^~~ /usr/include/c++/14/complex:959:5: note: candidate: 'template<class _Tp> _Tp std::norm(const complex<_Tp>&)' 959 | norm(const complex<_Tp>& __z) | ^~~~ /usr/include/c++/14/complex:959:5: note: template argument deduction/substitution failed: a.cc:43:23: note: 'Vector' {aka 'Point'} is not derived from 'const std::complex<_Tp>' 43 | if (norm(a) < norm(b)) return (-2); //p0--p1--p2 の順で一直線上 | ~~~~^~~ /usr/include/c++/14/complex:2453:5: note: candidate: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::norm(_Tp)' 2453 | norm(_Tp __x) | ^~~~ /usr/include/c++/14/complex:2453:5: note: template argument deduction/substitution failed: /usr/include/c++/14/complex: In substitution of 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::norm(_Tp) [with _Tp = Point]': a.cc:43:23: required from here 43 | if (norm(a) < norm(b)) return (-2); //p0--p1--p2 の順で一直線上 | ~~~~^~~ /usr/include/c++/14/complex:2453:5: error: no type named '__type' in 'struct __gnu_cxx::__promote<Point, false>' 2453 | norm(_Tp __x) | ^~~~
s861850638
p00268
C++
// Library. #include<cassert> #include<map> #include<vector> #include<cmath> #include<queue> #include<algorithm> // Type. typedef int Label; typedef double Weight; // Class. template<typename Vertex, typename Edge> class PlaneGraph { public: void insert(const Vertex& v); void insert(Edge e); const PlaneGraph<Vertex, Edge> dualgraph() const; const std::map<Label, Weight> Dijkstra(const Label& start) const; private: void dualgraph_color(std::map<Label, std::map<Label, int>>& color, int c, const Edge& e, const std::map<Label, std::vector<Edge>>& edge) const; std::map<Label, Vertex> V; std::map<Label, std::vector<Edge>> E; }; // Implement. template<typename Vertex, typename Edge> void PlaneGraph<Vertex, Edge>::insert(const Vertex& v) { V[v.label] = v; } template<typename Vertex, typename Edge> void PlaneGraph<Vertex, Edge>::insert(Edge e) { assert(V.find(e.from) != std::end(V)); assert(V.find(e.to) != std::end(V)); E[e.from].push_back(e); std::swap(e.from, e.to); E[e.from].push_back(e); } template<typename Vertex, typename Edge> const PlaneGraph<Vertex, Edge> PlaneGraph<Vertex, Edge>::dualgraph() const { // Sort edges counterclockwise. auto edge = E; for(auto& list: edge) if(!list.second.empty()) { std::sort(std::begin(list.second), std::end(list.second), [&](const Edge& lhs, const Edge& rhs) { double l = std::atan2(V.at(lhs.to).y - V.at(lhs.from).y, V.at(lhs.to).x - V.at(lhs.from).x); double r = std::atan2(V.at(rhs.to).y - V.at(rhs.from).y, V.at(rhs.to).x - V.at(rhs.from).x); return l < r; }); list.second.push_back(list.second.front()); } // Color edges. std::map<Label, std::map<Label, int>> color; int c = 1; for(const auto& list: edge) { for(const auto& e: list.second) if(!color[e.from].count(e.to)) dualgraph_color(color, c++, e, edge); if(list.first == bottom) outside_color = color[list.second.front().from][list.second.front().to]; } // Construct the dualgraph. PlaneGraph<Vertex, Edge> result; std::vector<std::vector<bool>> used(c, std::vector<bool>(c, false)); for(int i = 1; i < c; ++i) result.insert(Vertex({i})); for(const auto& list: E) for(const auto& e: list.second) if(!used[color[e.from][e.to]][color[e.to][e.from]]) { used[color[e.from][e.to]][color[e.to][e.from]] = true; used[color[e.to][e.from]][color[e.from][e.to]] = true; result.insert(Edge({color[e.from][e.to], color[e.to][e.from], 1})); } return result; } template<typename Vertex, typename Edge> void PlaneGraph<Vertex, Edge>::dualgraph_color(std::map<Label, std::map<Label, int>>& color, int c, const Edge& e, const std::map<Label, std::vector<Edge>>& edge) const { color[e.from][e.to] = c; for(auto it = edge.at(e.to).rbegin(); it != edge.at(e.to).rend(); ++it) if(it->to == e.from) { ++it; if(!color[it->from].count(it->to)) dualgraph_color(color, c, *it, edge); break; } } template<typename Vertex, typename Edge> const std::map<Label, Weight> PlaneGraph<Vertex, Edge>::Dijkstra(const Label& start) const { std::map<Label, Weight> result; std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge, Edge)>> q([](Edge lhs, Edge rhs) { return lhs.weight > rhs.weight; }); q.push(Edge({start, start, 0})); while(!q.empty()) { auto cur = q.top(); q.pop(); if(result.count(cur.to)) continue; result[cur.to] = cur.weight; for(const auto& nex: E.at(cur.to)) if(!result.count(nex.to)) q.push(Edge({nex.from, nex.to, cur.weight + nex.weight})); } return result; } //////////////////////////////////////// // Configuration. struct Vertex {Label label; double x, y;}; struct Edge {Label from, to; Weight weight;}; //////////////////////////////////////// #include<bits/stdc++.h> using namespace std; int main() { int C, W; while(cin >> C >> W, C | W) { vector<Vertex> pillar; int bottom_x = 1001, bottom_y = 1001; for(int i = 0; i < C; ++i) { double x, y; cin >> x >> y; pillar.push_back({i, x, y}); if(bottom_x < x) continue; if(bottom_x == x && bottom_y < y) continue; bottom_x = x; bottom_y = y; bottom = i; } PlaneGraph<Vertex, Edge> G; for(const auto& p: pillar) G.insert(p); for(int i = 0; i < W; ++i) { int s, t; cin >> s >> t; --s; --t; G.insert(Edge({s, t, 1})); } auto D = G.dualgraph(); auto distance = D.Dijkstra(outside_color); double answer = 0; for(const auto& d: distance) answer = max(answer, d.second); cout << answer << endl; } }
a.cc: In member function 'const PlaneGraph<Vertex, Edge> PlaneGraph<Vertex, Edge>::dualgraph() const': a.cc:54:22: error: 'bottom' was not declared in this scope 54 | if(list.first == bottom) outside_color = color[list.second.front().from][list.second.front().to]; | ^~~~~~ a.cc:54:30: error: 'outside_color' was not declared in this scope 54 | if(list.first == bottom) outside_color = color[list.second.front().from][list.second.front().to]; | ^~~~~~~~~~~~~ a.cc: In member function 'const std::map<int, double> PlaneGraph<Vertex, Edge>::Dijkstra(const Label&) const': a.cc:79:53: error: 'function' is not a member of 'std' 79 | std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge, Edge)>> q([](Edge lhs, Edge rhs) { | ^~~~~~~~ a.cc:8:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>' 7 | #include<algorithm> +++ |+#include <functional> 8 | // Type. a.cc:79:78: error: template argument 3 is invalid 79 | std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge, Edge)>> q([](Edge lhs, Edge rhs) { | ^~ a.cc:82:5: error: request for member 'push' in 'q', which is of non-class type 'int' 82 | q.push(Edge({start, start, 0})); | ^~~~ a.cc:83:12: error: request for member 'empty' in 'q', which is of non-class type 'int' 83 | while(!q.empty()) { | ^~~~~ a.cc:84:18: error: request for member 'top' in 'q', which is of non-class type 'int' 84 | auto cur = q.top(); | ^~~ a.cc:85:7: error: request for member 'pop' in 'q', which is of non-class type 'int' 85 | q.pop(); | ^~~ a.cc:88:68: error: request for member 'push' in 'q', which is of non-class type 'int' 88 | for(const auto& nex: E.at(cur.to)) if(!result.count(nex.to)) q.push(Edge({nex.from, nex.to, cur.weight + nex.weight})); | ^~~~ a.cc: In function 'int main()': a.cc:112:7: error: 'bottom' was not declared in this scope; did you mean 'bottom_y'? 112 | bottom = i; | ^~~~~~ | bottom_y a.cc:123:32: error: 'outside_color' was not declared in this scope 123 | auto distance = D.Dijkstra(outside_color); | ^~~~~~~~~~~~~
s748388198
p00268
C++
int bottom; int outside_color; // Library. #include<cassert> #include<map> #include<vector> #include<cmath> #include<queue> #include<algorithm> // Type. typedef int Label; typedef int Weight; // Class. template<typename Vertex, typename Edge> class PlaneGraph { public: void insert(const Vertex& v); void insert(Edge e); const PlaneGraph<Vertex, Edge> dualgraph() const; const std::map<Label, Weight> Dijkstra(const Label& start) const; private: void dualgraph_color(std::map<Label, std::map<Label, int>>& color, int c, const Edge& e, const std::map<Label, std::vector<Edge>>& edge) const; std::map<Label, Vertex> V; std::map<Label, std::vector<Edge>> E; }; // Implement. template<typename Vertex, typename Edge> void PlaneGraph<Vertex, Edge>::insert(const Vertex& v) { V[v.label] = v; } template<typename Vertex, typename Edge> void PlaneGraph<Vertex, Edge>::insert(Edge e) { assert(V.find(e.from) != std::end(V)); assert(V.find(e.to) != std::end(V)); E[e.from].push_back(e); std::swap(e.from, e.to); E[e.from].push_back(e); } template<typename Vertex, typename Edge> const PlaneGraph<Vertex, Edge> PlaneGraph<Vertex, Edge>::dualgraph() const { // Sort edges counterclockwise. auto edge = E; for(auto& list: edge) if(!list.second.empty()) { std::sort(std::begin(list.second), std::end(list.second), [&](const Edge& lhs, const Edge& rhs) { double l = std::atan2(V.at(lhs.to).y - V.at(lhs.from).y, V.at(lhs.to).x - V.at(lhs.from).x); double r = std::atan2(V.at(rhs.to).y - V.at(rhs.from).y, V.at(rhs.to).x - V.at(rhs.from).x); return l < r; }); list.second.push_back(list.second.front()); } // Color edges. std::map<Label, std::map<Label, int>> color; int c = 1; for(const auto& list: edge) { for(const auto& e: list.second) if(!color[e.from].count(e.to)) dualgraph_color(color, c++, e, edge); if(list.first == bottom) outside_color = color[list.second.front().from][list.second.front().to]; } // Construct the dualgraph. PlaneGraph<Vertex, Edge> result; std::vector<std::vector<bool>> used(c, std::vector<bool>(c, false)); for(int i = 1; i < c; ++i) result.insert(Vertex({i})); for(const auto& list: E) for(const auto& e: list.second) if(!used[color[e.from][e.to]][color[e.to][e.from]]) { used[color[e.from][e.to]][color[e.to][e.from]] = true; used[color[e.to][e.from]][color[e.from][e.to]] = true; result.insert(Edge({color[e.from][e.to], color[e.to][e.from], 1})); } return result; } template<typename Vertex, typename Edge> void PlaneGraph<Vertex, Edge>::dualgraph_color(std::map<Label, std::map<Label, int>>& color, int c, const Edge& e, const std::map<Label, std::vector<Edge>>& edge) const { color[e.from][e.to] = c; for(auto it = edge.at(e.to).rbegin(); it != edge.at(e.to).rend(); ++it) if(it->to == e.from) { ++it; if(!color[it->from].count(it->to)) dualgraph_color(color, c, *it, edge); break; } } template<typename Vertex, typename Edge> const std::map<Label, Weight> PlaneGraph<Vertex, Edge>::Dijkstra(const Label& start) const { std::map<Label, Weight> result; std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge, Edge)>> q([](Edge lhs, Edge rhs) { return lhs.weight > rhs.weight; }); q.push(Edge({start, start, 0})); while(!q.empty()) { auto cur = q.top(); q.pop(); if(result.count(cur.to)) continue; result[cur.to] = cur.weight; for(const auto& nex: E.at(cur.to)) if(!result.count(nex.to)) q.push(Edge({nex.from, nex.to, cur.weight + nex.weight})); } return result; } //////////////////////////////////////// // Configuration. struct Vertex {Label label; double x, y;}; struct Edge {Label from, to; Weight weight;}; //////////////////////////////////////// #include<bits/stdc++.h> using namespace std; int main() { int C, W; while(cin >> C >> W, C | W) { vector<Vertex> pillar; int bottom_x = 1001, bottom_y = 1001; for(int i = 0; i < C; ++i) { double x, y; cin >> x >> y; pillar.push_back({i, x, y}); if(bottom_x < x) continue; if(bottom_x == x && bottom_y < y) continue; bottom_x = x; bottom_y = y; bottom = i; } PlaneGraph<Vertex, Edge> G; for(const auto& p: pillar) G.insert(p); for(int i = 0; i < W; ++i) { int s, t; cin >> s >> t; --s; --t; G.insert(Edge({s, t, 1})); } auto D = G.dualgraph(); auto distance = D.Dijkstra(outside_color); double answer = 0; for(const auto& d: distance) answer = max(answer, d.second); cout << answer << endl; } }
a.cc: In member function 'const std::map<int, int> PlaneGraph<Vertex, Edge>::Dijkstra(const Label&) const': a.cc:82:53: error: 'function' is not a member of 'std' 82 | std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge, Edge)>> q([](Edge lhs, Edge rhs) { | ^~~~~~~~ a.cc:11:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>' 10 | #include<algorithm> +++ |+#include <functional> 11 | // Type. a.cc:82:78: error: template argument 3 is invalid 82 | std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge, Edge)>> q([](Edge lhs, Edge rhs) { | ^~ a.cc:85:5: error: request for member 'push' in 'q', which is of non-class type 'int' 85 | q.push(Edge({start, start, 0})); | ^~~~ a.cc:86:12: error: request for member 'empty' in 'q', which is of non-class type 'int' 86 | while(!q.empty()) { | ^~~~~ a.cc:87:18: error: request for member 'top' in 'q', which is of non-class type 'int' 87 | auto cur = q.top(); | ^~~ a.cc:88:7: error: request for member 'pop' in 'q', which is of non-class type 'int' 88 | q.pop(); | ^~~ a.cc:91:68: error: request for member 'push' in 'q', which is of non-class type 'int' 91 | for(const auto& nex: E.at(cur.to)) if(!result.count(nex.to)) q.push(Edge({nex.from, nex.to, cur.weight + nex.weight})); | ^~~~ a.cc: In function 'int main()': a.cc:128:46: error: no matching function for call to 'max(double&, const int&)' 128 | for(const auto& d: distance) answer = max(answer, d.second); | ~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_tree.h:63, from /usr/include/c++/14/map:62, from a.cc:6: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:128:46: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'int') 128 | for(const auto& d: distance) answer = max(answer, d.second); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:10: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:128:46: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 128 | for(const auto& d: distance) answer = max(answer, d.second); | ~~~^~~~~~~~~~~~~~~~~~ a.cc: In instantiation of 'const std::map<int, int> PlaneGraph<Vertex, Edge>::Dijkstra(const Label&) const [with Vertex = Vertex; Edge = Edge; Label = int]': a.cc:126:31: required from here 126 | auto distance = D.Dijkstra(outside_color); | ~~~~~~~~~~^~~~~~~~~~~~~~~ a.cc:82:83: error: invalid user-defined conversion from 'PlaneGraph<Vertex, Edge>::Dijkstra(const Label&) const::<lambda(Edge, Edge)>' to 'int' [-fpermissive] 82 | std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge, Edge)>> q([](Edge lhs, Edge rhs) { | ^~~~~~~~~~~~~~~~~~~~~~~~ 83 | return lhs.weight > rhs.weight; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 84 | }); | ~ a.cc:82:83: note: candidate is: 'constexpr PlaneGraph<Vertex, Edge>::Dijkstra(const Label&) const::<lambda(Edge, Edge)>::operator bool (*)(Edge, Edge)() const' (near match) 82 | std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge, Edge)>> q([](Edge lhs, Edge rhs) { | ^ a.cc:82:83: note: no known conversion from 'bool (*)(Edge, Edge)' to 'int'