submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s682795575
p00638
C++
#include <iostream> #include <cmath> #include <string> #include <vector> #define P pair<int,int> #define rep(i,n) for(int i = 0;i<n;i++) #define pb(n) push_back(n) using namespace std; int n; int main() { while(true){ cin >> n; if(n == 0) break; vector<P> V; rep(i,n){ int d,w; cin >> w >> d; V.push_back(P(d,w)); } sort(V.begin(),V.end()); int sw = 0; bool ans = true; rep(i,n){ sw += V[i].second; if(sw > V[i].first){ ans = false; break; } } cout << (ans ? "Yes" : "No") << endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 20 | sort(V.begin(),V.end()); | ^~~~ | sqrt
s469982546
p00638
C++
#include <iostream> #include <cmath> #include <string> #include <vector> #define P pair<int,int>ツ  #define rep(i,n) for(int i = 0;i<n;i++) #define pb(n) push_back(n)ツ  using namespace std; int main() { while(true){ cin >> n; if(n == 0) break; vector<P> V; rep(i,n){ int d,w; cin >> w >> d; V.push_back(P(d,w)); } sort(V.begin(),V.end()); int sw = 0; bool ans = true; rep(i,n){ sw += V[i].second; if(sw > V[i].first){ ans = false; break; } } cout << (ans ? "Yes" : "No") << endl; } return 0; }
a.cc:5:24: error: extended character   is not valid in an identifier 5 | #define P pair<int,int>ツ  | ^ a.cc:7:27: error: extended character   is not valid in an identifier 7 | #define pb(n) push_back(n)ツ  | ^ a.cc: In function 'int main()': a.cc:11:24: error: 'n' was not declared in this scope; did you mean 'yn'? 11 | cin >> n; | ^ | yn a.cc:13:25: error: template argument 1 is invalid 13 | vector<P> V; | ^ a.cc:13:25: error: template argument 2 is invalid a.cc:17:27: error: request for member 'push_back' in 'V', which is of non-class type 'int' 17 | V.push_back(P(d,w)); | ^~~~~~~~~ a.cc:5:24: error: expected primary-expression before '\U000030c4\U00003000' 5 | #define P pair<int,int>ツ  | ^~~~ a.cc:17:37: note: in expansion of macro 'P' 17 | V.push_back(P(d,w)); | ^ a.cc:19:24: error: request for member 'begin' in 'V', which is of non-class type 'int' 19 | sort(V.begin(),V.end()); | ^~~~~ a.cc:19:34: error: request for member 'end' in 'V', which is of non-class type 'int' 19 | sort(V.begin(),V.end()); | ^~~ a.cc:19:17: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 19 | sort(V.begin(),V.end()); | ^~~~ | sqrt a.cc:23:32: error: invalid types 'int[int]' for array subscript 23 | sw += V[i].second; | ^ a.cc:24:34: error: invalid types 'int[int]' for array subscript 24 | if(sw > V[i].first){ | ^
s093047192
p00638
C++
#include <iostream> #include <cmath> #include <string> #include <vector> #define P pair<int,int> #define rep(i,n) for(int i = 0;i<n;i++) #define pb(n) push_back(n) using namespace std; int main() { while(true){ cin >> n; if(n == 0) break; vector<P> V; rep(i,n){ int d,w; cin >> w >> d; V.push_back(P(d,w)); } sort(V.begin(),V.end()); int sw = 0; bool ans = true; rep(i,n){ sw += V[i].second; if(sw > V[i].first){ ans = false; break; } } cout << (ans ? "Yes" : "No") << endl; } return 0; }
a.cc: In function 'int main()': a.cc:11:24: error: 'n' was not declared in this scope; did you mean 'yn'? 11 | cin >> n; | ^ | yn a.cc:19:17: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 19 | sort(V.begin(),V.end()); | ^~~~ | sqrt
s198335159
p00638
C++
#include <iostream> #include <algorithm> using namespace std; #define MAX 25 class Task { public: int d, lim; Task(int d = 0, int lim = 0) : d(d), lim(lim) {} bool operator < ( const Task &t ) const { if( lim == t.lim ) return d < t.d; return lim < t.lim; } }; int main() { int n; Task T[MAX]; bool success; int cur; while(cin >> n && n) { for(int i = 0; i < n; i++) { cin >> T[i].d >> T[i].lim } sort(T, T+n); success = true; cur = 0; for(int i = 0; i < n && success; i++) { cur += T[i].d; if(T[i].lim < cur) success = false; } } if(success) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
a.cc: In function 'int main()': a.cc:25:32: error: expected ';' before '}' token 25 | cin >> T[i].d >> T[i].lim | ^ | ; 26 | } | ~
s724853075
p00638
C++
#include <iostream> #include <algorithm> using namespace std; #define MAX 25 int jewelry[MAX], lim[MAX]; int n; ` void bubbleSort() { for(int i = 0; i < n; i++) { for(int j = n-1; j>i; j--) { if(lim[j-1] > lim[j]) { swap(lim[j-1], lim[j]); swap(jewelry[j-1], jewelry[j]); } } } } int main() { bool success; int cur; while(cin >> n && n) { for(int i = 0; i < n; i++) { cin >> jewelry[i] >> lim[i]; } bubbleSort(); success = true; cur = 0; for(int i = 0; i < n && success; i++) { cur += jewelry[i]; if(lim[i] < cur) success = false; } if(success) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
a.cc:9:1: error: stray '`' in program 9 | ` | ^
s744673727
p00639
C
#include<stdio.h> #include<math.h> int main(void){ double px,py,vx,vy,D; while(1){ scanf("%lf",&D); if(D==0)break; scanf("%lf%lf%lf%lf",&px,&py,&vx,&vy); if(py/px==vy/vx && sqrt(px*px+py*py<D)printf("%.8f\n",sqrt(px*px+py*py)); else printf("impossible\n"); } return 0; }
main.c: In function 'main': main.c:12:43: error: expected ')' before 'printf' 12 | if(py/px==vy/vx && sqrt(px*px+py*py<D)printf("%.8f\n",sqrt(px*px+py*py)); | ~ ^~~~~~ | ) main.c:14:3: error: expected expression before '}' token 14 | } | ^
s705711060
p00639
C
#include <iostream> #include <cmath> using namespace std; const string impossible = "impossible"; double get_dot( double x1, double y1, double x2, double y2 ) { return x1 * x2 + y1 * y2; } double get_abs( double x, double y ) { return sqrt( x * x + y * y ); } bool check( double a, double b ) { return a < b || fabs( a - b ) < 1e-9; } int main() { double D; while ( cin >> D ) { if ( D < 1e-9 ) break; double px, py, vx, vy; cin >> px >> py >> vx >> vy; double a = get_dot( -px, -py, vx, vy ) / get_abs( px, py ) / get_abs( vx, vy ); if ( get_abs( px, py ) > 1.0 ) { cout << impossible << endl; } else if ( fabs( a - (1.0) ) < 1e-9 ) { if ( check( get_abs( px, py ), D ) ) cout << get_abs( px, py ) << endl; else cout << impossible << endl; } else if ( fabs( a - (-1.0) ) < 1e-9 ) { if ( check( 2.0 - get_abs( px, py ), D ) ) cout << 2.0 - get_abs( px, py ) << endl; else cout << impossible << endl; } else { cout << impossible << endl; } } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s277304347
p00639
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(a) (a).begin(),(a).end() using namespace std; typedef long double D; typedef complex<double> P; const D eps = 1e-8; D dot(P a, P b){ return a.real()*b.real() + a.imag()*b.imag(); } D cross(P a, P b){ return a.real()*b.imag() - a.imag()*b.real(); } int on_segment(P a, P b, P c){ b -= a; c -= a; if( abs(cross(b,c)) > EPS) return 0; if( dot(b,c) < EPS ) return -1 return 1; } int main(){ D d; while(cin >> d, abs(d)>EPS){ D px, py, vx, vy; cin >> px >> py >> vx >> vy; P cur = P(px,py), nxt = P(px+vx, py+vy); int flag = on_segment(cur, nxt, P(0,0)); if(flag == 0){ cout << "impossible" << endl; }else{ D ans = 0; if(flag == 1)ans = abs(cur); else ans = 2.0 - abs(cur); if(ans > D)cout << "impossible" << endl; else cout << ans << endl; } } }
a.cc: In function 'int on_segment(P, P, P)': a.cc:14:25: error: 'EPS' was not declared in this scope 14 | if( abs(cross(b,c)) > EPS) return 0; | ^~~ a.cc:15:18: error: 'EPS' was not declared in this scope 15 | if( dot(b,c) < EPS ) return -1 | ^~~ a.cc:15:33: error: expected ';' before 'return' 15 | if( dot(b,c) < EPS ) return -1 | ^ | ; 16 | return 1; | ~~~~~~ a.cc: In function 'int main()': a.cc:21:26: error: 'EPS' was not declared in this scope 21 | while(cin >> d, abs(d)>EPS){ | ^~~ a.cc:33:17: error: expected primary-expression before ')' token 33 | if(ans > D)cout << "impossible" << endl; | ^
s248611824
p00639
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(a) (a).begin(),(a).end() using namespace std; typedef long double D; typedef complex<D> P; const D EPS = 1e-8; D dot(P a, P b){ return a.real()*b.real() + a.imag()*b.imag(); } D cross(P a, P b){ return a.real()*b.imag() - a.imag()*b.real(); } int on_segment(P a, P b, P c){ b -= a; c -= a; if( abs(cross(b,c)) > EPS) return 0; if( dot(b,c) < EPS ) return -1; return 1; } int main(){ D d; while(cin >> d, abs(d)>EPS){ D px, py, vx, vy; cin >> px >> py >> vx >> vy; P cur = P(px,py), nxt = P(px+vx, py+vy); int flag = on_segment(cur, nxt, P(0,0)); if(flag == 0){ cout << "impossible" << endl; }else{ D ans = 0; if(flag == 1)ans = abs(cur); else ans = 2.0 - abs(cur); if(ans > D)cout << "impossible" << endl; else cout << ans << endl; } } }
a.cc: In function 'int main()': a.cc:33:17: error: expected primary-expression before ')' token 33 | if(ans > D)cout << "impossible" << endl; | ^
s938836441
p00639
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(a) (a).begin(),(a).end() using namespace std; typedef long double D; typedef complex<D> P; const D EPS = 1e-8; D dot(P a, P b){ return a.real()*b.real() + a.imag()*b.imag(); } D cross(P a, P b){ return a.real()*b.imag() - a.imag()*b.real(); } int on_segment(P a, P b, P c){ b -= a; c -= a; if( abs(cross(b,c)) > EPS) return 0; if( dot(b,c) < EPS ) return -1; return 1; } int main(){ D d; while(cin >> d, abs(d)>EPS){ D px, py, vx, vy; cin >> px >> py >> vx >> vy; P cur = P(px, py), nxt = P(px+vx, py+vy); int flag = on_segment(cur, nxt, P(0,0)); if(flag == 0){ cout << "impossible" << endl; }else{ D ans = 0; if(flag == 1)ans = abs(cur); else ans = 2.0 - abs(cur); if(ans > D)cout << "impossible" << endl; else cout << ans << endl; } } }
a.cc: In function 'int main()': a.cc:33:17: error: expected primary-expression before ')' token 33 | if(ans > D)cout << "impossible" << endl; | ^
s396174766
p00639
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(a) (a).begin(),(a).end() using namespace std; typedef long double D; typedef complex<D> P; const D EPS = 1e-8; D dot(P a, P b){ return a.real()*b.real() + a.imag()*b.imag(); } D cross(P a, P b){ return a.real()*b.imag() - a.imag()*b.real(); } int on_segment(P a, P b, P c){ b -= a; c -= a; if( abs(cross(b,c)) > EPS ) return 0; if( dot(b,c) < EPS ) return -1; return 1; } int main(){ D d; while(cin >> d, abs(d)>EPS){ D px, py, vx, vy; cin >> px >> py >> vx >> vy; P cur = P(px, py), nxt = P(px+vx, py+vy); int flag = on_segment(cur, nxt, P(0,0)); if(flag == 0){ cout << "impossible" << endl; }else{ D ans = 0; if(flag == 1)ans = abs(cur); else ans = 2.0 - abs(cur); if(ans > D)cout << "impossible" << endl; else cout << ans << endl; } } }
a.cc: In function 'int main()': a.cc:33:17: error: expected primary-expression before ')' token 33 | if(ans > D)cout << "impossible" << endl; | ^
s974137730
p00639
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(a) (a).begin(),(a).end() using namespace std; typedef long double D; typedef complex<D> P; const D EPS = 1e-8; /* D dot(P a, P b){ return a.real()*b.real() + a.imag()*b.imag(); } D cross(P a, P b){ return a.real()*b.imag() - a.imag()*b.real(); } int on_segment(P a, P b, P c){ b -= a; c -= a; if( abs(cross(b,c)) > EPS) return 0; if( dot(b,c) < EPS ) return -1; return 1; } */ int main(){ D d; while(cin >> d, abs(d)>EPS){ D px, py, vx, vy; cin >> px >> py >> vx >> vy; P cur = P(px, py), nxt = P(px+vx, py+vy); int flag = 1;//on_segment(cur, nxt, P(0,0)); if(flag == 0){ cout << "impossible" << endl; }else{ D ans = 0; if(flag == 1)ans = abs(cur); else ans = 2.0 - abs(cur); if(ans > D)cout << "impossible" << endl; else cout << ans << endl; } } }
a.cc: In function 'int main()': a.cc:35:17: error: expected primary-expression before ')' token 35 | if(ans > D)cout << "impossible" << endl; | ^
s877805629
p00639
C++
#include<iostream> #include<stdio> #include<complex> #include<cmath> using namespace std;typedef double elem;typedef complex<elem> point,vec; const elem eps=1.0e-4; #define ERR 0x00 #define FRONT 0x01 #define RIGHT 0x02 #define BACK 0x04 #define LEFT 0x08 #define OVER 0x10 point origin(0,0);bool eq(elem a, elem b){ return abs(a-b) < eps; }bool lt(elem a, elem b){ return !eq(a,b) && a < b; }bool leq(elem a, elem b){ return eq(a,b) || a < b; }bool gt(elem a, elem b){ return !eq(a,b) && a > b; }bool geq(elem a, elem b){ return eq(a,b) || a > b; }bool ltz(elem a){ return lt( a, 0 ); }bool gtz(elem a){ return gt( a, 0 ); }elem cross(vec a, vec b){ return ( a.real() * b.imag() - a.imag() * b.real() ); }elem dist(point a, point b){ return abs(a-b); }int ccw(point a, point b, point x){vec vb = b - a;vec vx = x - a;elem z = cross( vb, vx );if( eq(abs(vb),0) )return ERR;if( eq(z,0) ){elem d_ab = dist(a,b);elem d_bx = dist(b,x);elem d_ax = dist(a,x);if( eq(d_ab,d_ax+d_bx) )return OVER;if( gt( d_ax, d_ab ) && gt( d_ax, d_bx ) )return FRONT;if( gt( d_bx, d_ab ) && gt( d_bx, d_ax ) )return BACK;}else if( gtz( z ) )return LEFT;else if( ltz( z ) )return RIGHT;return ERR;} int main() { while(true){ double D,px,py,vx,vy; scanf("%lf",&D); if(D==0)break; scanf("%lf%lf%lf%lf", &px,&py,&vx,&vy); point p(px,py); vec v(vx,vy); int progress = ccw(p,p+v,origin); double going = -1; if(progress==FRONT&&leq(dist(p,origin),D)) going=dist(p,origin); else if(progress==BACK&&leq(2-dist(p,origin),D)){ going=2-dist(p,origin); } if(gtz(going)) printf("%.6lf\n",going); else puts("impossible"); } return 0; }
a.cc:2:9: fatal error: stdio: No such file or directory 2 | #include<stdio> | ^~~~~~~ compilation terminated.
s725609676
p00639
C++
include<iostream> #include<cstdio> #include<complex> #include<cmath> using namespace std;typedef double elem;typedef complex<elem> point,vec; const elem eps=1.0e-8; #define ERR 0x00 #define FRONT 0x01 #define RIGHT 0x02 #define BACK 0x04 #define LEFT 0x08 #define OVER 0x10 point origin(0,0);bool eq(elem a, elem b){ return abs(a-b) < eps; }bool lt(elem a, elem b){ return !eq(a,b) && a < b; }bool leq(elem a, elem b){ return eq(a,b) || a < b; }bool gt(elem a, elem b){ return !eq(a,b) && a > b; }bool geq(elem a, elem b){ return eq(a,b) || a > b; }bool ltz(elem a){ return lt( a, 0 ); }bool gtz(elem a){ return gt( a, 0 ); }elem cross(vec a, vec b){ return ( a.real() * b.imag() - a.imag() * b.real() ); }elem dist(point a, point b){ return abs(a-b); }int ccw(point a, point b, point x){vec vb = b - a;vec vx = x - a;elem z = cross( vb, vx );if( eq(abs(vb),0) )return ERR;if( eq(z,0) ){elem d_ab = dist(a,b);elem d_bx = dist(b,x);elem d_ax = dist(a,x);if( eq(d_ab,d_ax+d_bx) )return OVER;if( gt( d_ax, d_ab ) && gt( d_ax, d_bx ) )return FRONT;if( gt( d_bx, d_ab ) && gt( d_bx, d_ax ) )return BACK;}else if( gtz( z ) )return LEFT;else if( ltz( z ) )return RIGHT;return ERR;}int main(){while(true){double D,px,py,vx,vy;scanf("%lf",&D);if(D==0)break;scanf("%lf%lf%lf%lf",&px,&py,&vx,&vy);point p(px,py);vec v(vx,vy);int progress = ccw(p,p+v,origin);double going = -1;if(progress&(FRONT|OVER)&&leq(dist(p,origin),D))going=dist(p,origin);else if(progress&BACK&&leq(2-dist(p,origin),D))going=2-dist(p,origin);if(gtz(going))printf("%.6lf\n",going);else puts("impossible");}return 0;}
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ In file included from /usr/include/c++/14/complex:43, from a.cc:3: /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/stdio.h:34, from /usr/include/c++/14/cstdio:42, from a.cc:2: /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/include/c++/14/bits/stl_iterator.h:67, from /usr/include/c++/14/bits/stl_algobase.h:67:
s881082423
p00639
C++
#define EPS (1e-6) using namespace std; int main(){ double d; while(1){ double px,py,vx,vy; cin >> d; if(!(d)) break; cin >> px >> py >> vx >> vy; if(fabs(py * vx - px * vy) < EPS){ if(vx * px < 0 || vy * py < 0){ double x = sqrt(px*px + py*py); if( x < d + EPS) cout << x << endl; else cout << "impossible" << endl; } else if (vx * px > 0 || vy * py > 0){ double x = 2.0 - sqrt(px*px + py*py); if ( x < d + EPS) cout << x << endl; else cout << "impossible" << endl; } else cout << "impossible" << endl; } else cout << "impossible" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:17: error: 'cin' was not declared in this scope 10 | cin >> d; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #define EPS (1e-6) a.cc:14:20: error: 'fabs' was not declared in this scope 14 | if(fabs(py * vx - px * vy) < EPS){ | ^~~~ a.cc:16:44: error: 'sqrt' was not declared in this scope 16 | double x = sqrt(px*px + py*py); | ^~~~ a.cc:17:50: error: 'cout' was not declared in this scope 17 | if( x < d + EPS) cout << x << endl; | ^~~~ a.cc:17:50: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:17:63: error: 'endl' was not declared in this scope 17 | if( x < d + EPS) cout << x << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #define EPS (1e-6) a.cc:18:38: error: 'cout' was not declared in this scope 18 | else cout << "impossible" << endl; | ^~~~ a.cc:18:38: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:18:62: error: 'endl' was not declared in this scope 18 | else cout << "impossible" << endl; | ^~~~ a.cc:18:62: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:21:50: error: 'sqrt' was not declared in this scope 21 | double x = 2.0 - sqrt(px*px + py*py); | ^~~~ a.cc:22:51: error: 'cout' was not declared in this scope 22 | if ( x < d + EPS) cout << x << endl; | ^~~~ a.cc:22:51: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:22:64: error: 'endl' was not declared in this scope 22 | if ( x < d + EPS) cout << x << endl; | ^~~~ a.cc:22:64: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:23:38: error: 'cout' was not declared in this scope 23 | else cout << "impossible" << endl; | ^~~~ a.cc:23:38: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:23:62: error: 'endl' was not declared in this scope 23 | else cout << "impossible" << endl; | ^~~~ a.cc:23:62: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:24:32: error: 'cout' was not declared in this scope 24 | } else cout << "impossible" << endl; | ^~~~ a.cc:24:32: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:24:56: error: 'endl' was not declared in this scope 24 | } else cout << "impossible" << endl; | ^~~~ a.cc:24:56: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:25:24: error: 'cout' was not declared in this scope 25 | } else cout << "impossible" << endl; | ^~~~ a.cc:25:24: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:25:48: error: 'endl' was not declared in this scope 25 | } else cout << "impossible" << endl; | ^~~~ a.cc:25:48: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s234639767
p00639
C++
#include<iostream> #include<cstdio> using namespace std; int main(){ double d,x,y,vy,vx; while(cin>>d,d){ cin>>x>>y>>vx>>vy; if(x*x+y*y>=1){ if(x*vy-y*vx==0&&x*x+y*y<=d*d&&(x*vx<=0&&y*vy<=0)) printf("%.8lf\n",sqrt(x*x+y*y)); else cout<<"impossible"<<endl; }else{ if(x*vy-y*vx==0&&x*x+y*y<=d*d&&(x*vx<=0&&y*vy<=0)) printf("%.8lf\n",sqrt(x*x+y*y)); else if(x*vy+y*vx==0&&2-sqrt(x*x+y*y)<=d&&(x*vx<=0||y*vy<=0)) printf("%.8lf\n",2-sqrt(x*x+y*y)); else cout<<"impossible"<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:10:42: error: 'sqrt' was not declared in this scope 10 | printf("%.8lf\n",sqrt(x*x+y*y)); | ^~~~ a.cc:14:42: error: 'sqrt' was not declared in this scope 14 | printf("%.8lf\n",sqrt(x*x+y*y)); | ^~~~ a.cc:15:49: error: 'sqrt' was not declared in this scope 15 | else if(x*vy+y*vx==0&&2-sqrt(x*x+y*y)<=d&&(x*vx<=0||y*vy<=0)) | ^~~~
s316309501
p00639
C++
#include <iostream> #include <complex> #define EPS 0.00001 using namespace std; int main() { double d, px, py, vx, vy; complex<double> p,v; while(cin >> d, d >= EPS ) { cin >> px >> py >> vx >> vy; p = complex<double>(px, py); v = complex<double>(vx, vy); double cos = ( p.real()*v.real() + p.imag()*v.imag() ) / ( abs(p)*abs(v) ); cout << cos << endl; cout << abs(p) <<endl; if( -1.0 -EPS < cos && cos < -1.0 +EPS && abs(p) =< d ) cout << abs(p) <<endl; else if( 1.0 -EPS < cos && cos < 1.0 +EPS && 2 - abs(p) =< d ) cout << 2*(1-abs(p)) + abs(p) <<endl; else cout << "impossible" <<endl; } return 0; }
a.cc: In function 'int main()': a.cc:27:67: error: expected primary-expression before '<' token 27 | if( -1.0 -EPS < cos && cos < -1.0 +EPS && abs(p) =< d ) | ^ a.cc:29:76: error: expected primary-expression before '<' token 29 | else if( 1.0 -EPS < cos && cos < 1.0 +EPS && 2 - abs(p) =< d ) | ^
s364573253
p00639
C++
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> #include <vector> using namespace std; const double eps = 1e-8; const double pi = acos(-1.0); const double inf = 1e200; inline int sgn(double x) { return x < -eps ? -1 : x > eps; } inline double sqr(double x) { return x * x; } inline double a2r(double a) { //隗貞コヲ蛻ー蠑ァ蠎ヲ return a * pi / 180; } inline double r2a(double r) { //蠑ァ蠎ヲ蛻ー隗貞コヲ return r / pi * 180; } struct P { double x,y; P(double x = 0,double y = 0):x(x), y(y) {}; friend bool operator ==(const P& p1, const P& p2) { return sgn(p1.x - p2.x) == 0 && sgn(p1.y - p2.y) == 0; } friend bool operator <(const P& p1, const P& p2) { return sgn(p1.x - p2.x) == 0 ? sgn(p1.y - p2.y) < 0 : p1.x < p2.x; } friend bool operator >(const P& p1, const P& p2) { return sgn(p1.x - p2.x) == 0 ? sgn(p1.y - p2.y) > 0 : p1.x > p2.x; } friend P operator +(const P& p1, const P& p2) { return P(p1.x + p2.x, p1.y + p2.y); } friend P operator -(const P& p1, const P& p2) { return P(p1.x - p2.x, p1.y - p2.y); } friend P operator *(const P& p, double a) { return P(p.x * a,p.y * a); } friend P operator /(const P& p, double a) { return P(p.x / a,p.y / a); } friend inline double operator ^(const P& p1, const P& p2) { //轤ケ荵? return p1.x * p2.x + p1.y * p2.y; } friend inline double operator *(const P& p1, const P& p2) { //蜿我ケ? return p1.x * p2.y - p1.y * p2.x; } friend inline double dot(const P& o, const P& a, const P& b) { return (a - o) ^ (b - o); } friend inline double cross(const P& o, const P& a, const P& b) { //2蛟堺ク芽ァ貞ス「oab譛牙髄髱「遘ッ return (a - o) * (b - o); } friend double dist(const P& p1, const P& p2) { return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); } friend double dist2(const P& p1, const P& p2) { return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y); } double len() const { return sqrt(x * x + y * y); } double len2() const { return x * x + y * y; } //豎ょ髄驥竣逧?栫隗抵シ瑚ァ貞コヲ闌?峩荳コ [0,2*pi) double angle() const { double t = atan2(y,x); return sgn(t) >= 0 ? t : t + 2 * pi; } P trunc(double l) const { l /= len(); return P(x * l, y * l); } P turn_left() const { //豕募髄驥? return P(-y, x); } P turn_right() const { //豕募髄驥? return P(y, -x); } P rotate(double th, const P& p) const { //扈慕せp騾?慮髓郁スャth蠑ァ蠎ヲ double c = cos(th), s = sin(th); return P(c * (x - p.x) - s * (y - p.y) + p.x, s * (x - p.x) + c * (y - p.y) + p.y); } bool in() { return scanf("%lf %lf", &x, &y) == 2; } void out() const { printf("%lf %lf\n", x, y); } }; int main() { double d; P p,v; while(cin>>d>>p.x>>p.y>>v.x>>v.y) { double vx=v.x,vy=v.y,x=p.x,y=p.y; double b1=x*vy-y*vx; //cout<<(p*v)<<" "<<b1<<endl; if(sgn(p*v-b1)!=0))while(1); if(sgn((p*v))) { puts("impossible"); continue; } if (sgn(vx*x)<0||sgn(vy*y)<0) { double dis=sqrt(x*x+y*y); if (sgn(dis-d)>0) printf("impossible\n"); else printf("%.6lf\n",dis); } else { double dis=sqrt(x*x+y*y); dis=2.0-dis; if (sgn(dis-d)>0) printf("impossible\n"); else printf("%.6lf\n",dis); } } }
a.cc: In function 'double operator^(const P&, const P&)': a.cc:48:5: warning: no return statement in function returning non-void [-Wreturn-type] 48 | } | ^ a.cc: In function 'double operator*(const P&, const P&)': a.cc:50:5: warning: no return statement in function returning non-void [-Wreturn-type] 50 | } | ^ a.cc: In member function 'P P::turn_left() const': a.cc:79:5: warning: no return statement in function returning non-void [-Wreturn-type] 79 | } | ^ a.cc: In member function 'P P::turn_right() const': a.cc:81:5: warning: no return statement in function returning non-void [-Wreturn-type] 81 | } | ^ a.cc: In function 'int main()': a.cc:103:35: error: expected primary-expression before ')' token 103 | if(sgn(p*v-b1)!=0))while(1); | ^
s401030252
p00640
Java
import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Map; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); scan.next(); scan.next(); String link = scan.next(); D d = new D(link); for (int b = scan.nextInt(); b-- > 0;) { d.setA(link, scan.nextInt(), scan.nextInt(), scan.nextInt(), scan .nextInt(), scan.next()); } for (; n-- > 1;) { link = scan.next(); for (int b = scan.nextInt(); b-- > 0;) { d.setA(link, scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.next()); } } for (int m = scan.nextInt(); m-- > 0;) { String command = scan.next(); if (command.equals("click")) { d.click(scan.nextInt(), scan.nextInt()); } else if (command.equals("show")) { System.out.println(d.show()); } else if (command.equals("back")) { d.back(); } else if (command.equals("forward")) { d.forward(); } } } public D(String link) { history.add(link); } LinkedList<String> history = new LinkedList<String>(); int i = 0; Map<String, Set<A>> pages = new HashMap<String, Set<A>>(); void setA(String page, int left, int top, int right, int bottom, String link) { if (!pages.containsKey(page)) { pages.put(page, new HashSet<A>()); } pages.get(page).add(new A(left, right, top, bottom, link)); } String show() { return history.get(i); } void click(int x, int y) { for (A a : pages.get(history.get(i))) { if (a.contains(x, y)) { i++; while (history.size() > i) { history.pollLast(); } history.add(a.toString()); return; } } } void back() { if (i > 0) { i--; } } void forward() { if (i + 1 < history.size()) { i++; } } class A { int left, right, top, bottom; String link; public A(int left, int right, int top, int bottom, String link) { this.left = left; this.right = right; this.top = top; this.bottom = bottom; this.link = link; } boolean contains(int x, int y) { return (left <= x && x <= right) && (top <= y && y <= bottom); } @Override public String toString() { return link; } } }
Main.java:41: error: invalid method declaration; return type required public D(String link) { ^ 1 error
s154901954
p00640
C
#include <iostream> #include <string> #include <map> #include <sstream> #include <algorithm> #include <vector> using namespace std; class B{ public: int x1, y1, x2, y2; string to; B(){} B(int x1, int y1, int x2, int y2, string to) : x1(x1), y1(y1), x2(x2), y2(y2), to(to) {} }; int n, h, w, b[100], m; vector<B> buttons[100]; string name[100]; map<string, int> stoi; int clicked(int x, int y, int p){ for(int i=0;i<b[p];i++){ B but = buttons[p][i]; if(but.x1 <= x && x <= but.x2 && but.y1 <= y && y <= but.y2) return stoi[but.to]; } return -1; } main(){ while(cin >> n && n){ stoi.clear(); for(int i=0;i<n;i++) buttons[i].clear(); cin >> w >> h; for(int i=0;i<n;i++){ cin >> name[i]; cin >> b[i]; stoi[name[i]] = i; for(int j=0;j<b[i];j++){ B in; cin >> in.x1 >> in.y1 >> in.x2 >> in.y2 >> in.to; buttons[i].push_back(in); } } cin >> m; int p = 0; vector<int> buf; buf.push_back(0); for(int i=0;i<m;i++){ string str; cin >> str; if(str == "forward"){ if(p+1 < buf.size()) p++; }else if(str == "back"){ if(p != 0) p--; }else if(str == "show"){ cout << name[buf[p]] << endl; }else{ int x, y; cin >> x >> y; int next = clicked(x, y, buf[p]); if(next == -1) continue; if(p+1 != buf.size()) buf.erase(buf.begin() + p+1); buf.push_back(next); p++; } } } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s450498208
p00640
C++
#include<bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; int b[100], x1[100][100], Y1[100][100], x2[100][100], y2[100][100]; string link[100][100]; map<string, int>mp; int main() { int n; while (scanf("%d", &n), n) { mp.clear(); int w, h; scanf("%d%d", &w, &h); vector<string>v; rep(i, n) { string s; cin >> s >> b[i]; mp[s] = i; if (i == 0)v.push_back(s); rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; } int pos = 0; int m; scanf("%d", &m); rep(i, m) { string s; cin >> s; if (s == "click") { int x, y; cin >> x >> y; int a = mp[pos]; rep(i, b[a]) { if (x1[a][i] <= x&&x <= x2[a][i] && Y1[a][i] <= y&&y <= y2[a][i]) { v.erase(v.begin() + pos + 1, v.end()); v.push_back(link[a][i]); pos = v.size() - 1; break; } } } if (s == "back") { if (pos)pos--; } if (s == "forward") { if (pos < v.size() - 1)pos++; } if (s == "show")cout << v[pos] << endl; } } }
a.cc:6:21: error: 'std::string link [100][100]' redeclared as different kind of entity 6 | string link[100][100]; | ^ In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24, from /usr/include/signal.h:328, from /usr/include/c++/14/csignal:42, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116, from a.cc:1: /usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)' 819 | extern int link (const char *__from, const char *__to) | ^~~~ a.cc: In function 'int main()': a.cc:17:98: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ^ a.cc:17:101: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ^ a.cc:17:89: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int(const char*, const char*) noexcept') 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~~~~~~~ | | | | | int(const char*, const char*) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included 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: /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:17:101: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'int (*)(const char*, const char*) noexcept' 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ~~~~~~~~~^ /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:17:101: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'short int' [-fpermissive] 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ~~~~~~~~~^ | | | int (*)(const char*, const char*) noexcept a.cc:17:101: error: cannot bind rvalue '(short int)(link + (((sizetype)i) + ((sizetype)j)))' to 'short int&' /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:17:101: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'short unsigned int' [-fpermissive] 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ~~~~~~~~~^ | | | int (*)(const char*, const char*) noexcept a.cc:17:101: error: cannot bind rvalue '(short unsigned int)(link + (((sizetype)i) + ((sizetype)j)))' to 'short unsigned int&' /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:17:101: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'int' [-fpermissive] 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ~~~~~~~~~^ | | | int (*)(const char*, const char*) noexcept a.cc:17:101: error: cannot bind rvalue '(int)(link + (((sizetype)i) + ((sizetype)j)))' to 'int&' /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:17:101: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'unsigned int' [-fpermissive] 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ~~~~~~~~~^ | | | int (*)(const char*, const char*) noexcept a.cc:17:101: error: cannot bind rvalue '(unsigned int)(link + (((sizetype)i) + ((sizetype)j)))' to 'unsigned int&' /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:17:101: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'long int' [-fpermissive] 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ~~~~~~~~~^ | | | int (*)(const char*, const char*) noexcept a.cc:17:101: error: cannot bind rvalue '(long int)(link + (((sizetype)i) + ((sizetype)j)))' to 'long int&' /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:17:101: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'long unsigned int' [-fpermissive] 17 | rep(j, b[i])cin >> x1[i][j] >> Y1[i][j] >> x2[i][j] >> y2[i][j] >> link[i][j]; | ~~~~~~~~~^ | | | int (*)(const char*, const char*) noexcept a.cc:17:101: error: cannot bind rvalue '(long unsigned int)(link + (((sizetype)i) + ((sizetype)j)))' to 'long unsigned int&' /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:19
s112462796
p00640
C++
#include <iostream> #include <string> #include <deque> #include <map> using namespace std; typedef struct{int sx, sy, ex, ey; string to;} LINK; //ボタンの左上・右下座標、リンク先のページ名 typedef struct{string name; int n; LINK btn[100];} PAGE; //ページ名、ページ上にあるボタンの数・その一覧 int main() { int n, o, W, H; //ページの数、命令の数、ページの幅・高さ int i, j, x, y, cur, t, m; //ループ用変数、"click x y"のx,y、、一時的な、履歴の長さ string op; //命令の名前 PAGE pg[100]; LINK tmp; map<string, int> tbl; while (cin >> n, n) { deque<string> his; //ページの履歴(pg[i]のiを代入) deque<string>::iterator itr; cin >> W >> H; for (i = 0; i < n; i++) { cin >> pg[i].name >> pg[i].n; tbl.insert( map<string, int>::value_type(pg[i].name, i) ); for (j = 0; j < pg[i].n; j++) { cin >> tmp.sx >> tmp.sy >> tmp.ex >> tmp.ey >> tmp.to; pg[i].btn[j] = tmp; } } cin >> o; his.push_back(pg[0].name); cur = 0; m = 1; for (i = 0; i < o; i++) { cin >> op; if (op == "click") { cin >> x >> y; t = tbl[his.at(cur)]; for (j = 0; j < pg[t].n; j++) { if (pg[t].btn[j].sx <= x && x <= pg[t].btn[j].ex && pg[t].btn[j].sy <= y && y <= pg[t].btn[j].ey) { his.push_back(pg[t].btn[j].to); cur++; m++; break; } } itr = his.end(); for (j = cur+1; j < m; j++) { his.erase(*itr); m--; *itr--; } } else if (op == "back") { if (cur > 0) cur--; } else if (op == "forward") { if (cur < m) cur++; } else if (op == "show") { cout << his.at(cur) << endl; } } } return 0; }
a.cc: In function 'int main()': a.cc:55:50: error: no matching function for call to 'std::deque<std::__cxx11::basic_string<char> >::erase(std::__cxx11::basic_string<char>&)' 55 | his.erase(*itr); | ~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/deque:66, from a.cc:3: /usr/include/c++/14/bits/stl_deque.h:1775:7: note: candidate: 'std::deque<_Tp, _Alloc>::iterator std::deque<_Tp, _Alloc>::erase(const_iterator) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; iterator = std::_Deque_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >::iterator; const_iterator = std::_Deque_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >::const_iterator]' 1775 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/14/bits/stl_deque.h:1775:28: note: no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'std::deque<std::__cxx11::basic_string<char> >::const_iterator' {aka 'std::_Deque_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >::const_iterator'} 1775 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_deque.h:1799:7: note: candidate: 'std::deque<_Tp, _Alloc>::iterator std::deque<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; iterator = std::_Deque_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >::iterator; const_iterator = std::_Deque_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >::const_iterator]' 1799 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/14/bits/stl_deque.h:1799:7: note: candidate expects 2 arguments, 1 provided a.cc:57:45: warning: ignoring return value of 'std::_Deque_iterator<_Tp, _Ref, _Ptr>::reference std::_Deque_iterator<_Tp, _Ref, _Ptr>::operator*() const [with _Tp = std::__cxx11::basic_string<char>; _Ref = std::__cxx11::basic_string<char>&; _Ptr = std::__cxx11::basic_string<char>*; reference = std::__cxx11::basic_string<char>&]', declared with attribute 'nodiscard' [-Wunused-result] 57 | *itr--; | ^~ /usr/include/c++/14/bits/stl_deque.h:181:7: note: declared here 181 | operator*() const _GLIBCXX_NOEXCEPT | ^~~~~~~~
s432006351
p00640
C++
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <map> #include <set> using namespace std; #define f first #define s second typedef pair<int, int> P; typedef pair<P, P> P2; typedef pair<P2, string> P3; int main(){ int n; int W, H; while(cin >> n, n){ cin >> W >> H; map<string, vector<P3> > page; vector<P3> link; string page_name; string now; int n_button, x1, x2, y1, y2; for(int i = 0 ; i < n ; i++){ cin >> page_name >> n_button; if(i == 0) now = page_name; for(int j = 0 ; j < n_button ; j++){ P3 tmp; cin >> tmp.f.f.f >> tmp.f.f.s >> tmp.f.s.f >> tmp.f.s.s >> tmp.s; link.push_back(tmp); } page.insert(make_pair(page_name, link)); } int n_op, x, y; string op; vector<string> history; history.push_back(now); int n_now = 0; cin >> n_op; cin.ignore(); while(n_op--){ getline(cin, op); if(op[0] == 'c'){ // click string tmp1="", tmp2=""; int i; for(i = 6 ; op[i] != ' ' ; i++) tmp1 += op[i]; for( ; i < op.size() ; i++) tmp2 += op[i]; x = atoi(tmp1.c_str()); y = atoi(tmp2.c_str()); for(i = 0 ; i < page[now].size() ; i++){ if((page[now][i].f.f.f <= x && x <= page[now][i].f.s.f) && (page[now][i].f.f.s <= y && y <= page[now][i].f.s.s)){ now = page[now][i].s; history.push_back(now); n_now++; } } } // click end if(op == "show") cout << history[n_now] << endl; if(op == "back") n_now--; if(op == "forward") n_now++; } } return 0; } #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <map> #include <set> using namespace std; #define f first #define s second typedef pair<int, int> P; typedef pair<P, P> P2; typedef pair<P2, string> P3; int main(){ int n; int W, H; while(cin >> n, n){ cin >> W >> H; map<string, vector<P3> > page; vector<P3> link; string page_name; string now; int n_button, x1, x2, y1, y2; for(int i = 0 ; i < n ; i++){ cin >> page_name >> n_button; if(i == 0) now = page_name; for(int j = 0 ; j < n_button ; j++){ P3 tmp; cin >> tmp.f.f.f >> tmp.f.f.s >> tmp.f.s.f >> tmp.f.s.s >> tmp.s; link.push_back(tmp); } page.insert(make_pair(page_name, link)); } int n_op, x, y; string op; vector<string> history; history.push_back(now); int n_now = 0; cin >> n_op; cin.ignore(); while(n_op--){ getline(cin, op); if(op[0] == 'c'){ // click string tmp1="", tmp2=""; int i; for(i = 6 ; op[i] != ' ' ; i++) tmp1 += op[i]; for( ; i < op.size() ; i++) tmp2 += op[i]; x = atoi(tmp1.c_str()); y = atoi(tmp2.c_str()); for(i = 0 ; i < page[now].size() ; i++){ if((page[now][i].f.f.f <= x && x <= page[now][i].f.s.f) && (page[now][i].f.f.s <= y && y <= page[now][i].f.s.s)){ now = page[now][i].s; history.push_back(now); n_now++; } } } // click end if(op == "show") cout << history[n_now] << endl; if(op == "back") n_now--; if(op == "forward") n_now++; } } return 0; }
a.cc:95:5: error: redefinition of 'int main()' 95 | int main(){ | ^~~~ a.cc:18:5: note: 'int main()' previously defined here 18 | int main(){ | ^~~~
s428949015
p00640
C++
#include <iostream> #include <string> #include <algorithm> using namespace std; struct pp{ int t; int x1[105],y1[105],x2[105],y2[105]; string s[105]; string now; }p[105]; int main() { int n; int h,w; string o; while(cin>>n) { if(n==0) break; cin>>h>>w; for(int i=0;i<n;i++) { cin>>p[i].now>>p[i].t; for(int j=0;j<p[i].t;j++) { cin>>p[i].x1[j]>>p[i].y1[j]>>p[i].x2[j] >>p[i].y2[j]>>p[i].s[j]; } } int m,x,y; cin>>m; int num=0; int sum=0; string t[10005]; t[0]=p[0].now; for(int i=0;i<m;i++) { cin>>o; if(o=="click") { cin>>x>>y; for(int j=0;j<p[num].t;j++) { if(x>=p[num].x1[j] && x<=p[num].x2[j] && y>=p[num].y1[j] && y<=p[num].y2[j]) { bool f=false; for(int k=0;k<n;k++) if(p[k].now==p[num].s[j]) { t[num+1]=p[k].now; num++; sum=num; f=true; break; } } if(f) break; } } else if(o=="show") cout<<p[num].now<<endl; else if(o=="back") { if(num>0) num--; } else if(o=="forward") { if(num<sum) num++; } } } return 0; }
a.cc: In function 'int main()': a.cc:56:44: error: 'f' was not declared in this scope 56 | if(f) break; | ^
s019287874
p00640
C++
#include <cstdio> #include <cstdlib> #include <string> #include <list> #include <map> using namespace std; struct C { string s; int x1; int y1; int x2; int y2; C ( int x1, int y1, int x2, int y2, const char *s ) { this->x1 = x1; this->y1 = y1; this->x2 = x2; this->y2 = y2; this->s = s; } }; int main ( int argc, char *argv[ ] ) { list<C>::iterator it; int i; for ( ; ; ) { map<string,list<C> > lis; list<string> buf; list<string> cont; int w, h; int n; scanf ( " %d", &n ); if ( n == 0 ) break ; scanf ( " %d %d", &w, &h ); while ( n-- ) { list<C> r; char s[ 32 ]; int c; scanf ( " %s %d", s, &c ); if ( buf.empty ( ) ) buf.push_back ( s ); for ( i = 0; i < c; ++i ) { int x1, y1, x2, y2; char t[ 32 ]; scanf ( " %d %d %d %d %s", &x1, &y1, &x2, &y2, t ); r.push_back ( C ( x1, y1, x2, y2, t ) ); } lis[ s ] = r; } scanf ( " %d", &n ); while ( n-- ) { char cmd[ 32 ]; scanf ( " %s", cmd ); if ( strcmp ( "show", cmd ) == 0 ) { puts ( buf.back ( ).c_str ( ) ); continue ; } if ( strcmp ( "click", cmd ) == 0 ) { list<C> *p; int x, y; scanf ( " %d %d", &x, &y ); p = &lis[ buf.back ( ) ]; for ( it = p->begin ( ); it != p->end ( ); ++it ) { if ( x >= it->x1 && x <= it->x2 && y >= it->y1 && y <= it->y2 ) { buf.push_back ( it->s ); cont.clear ( ); break ; } } continue ; } if ( strcmp ( "back", cmd ) == 0 ) { if ( buf.size ( ) >= 2 ) { cont.push_front ( buf.back ( ) ); buf.pop_back ( ); } continue ; } if ( strcmp ( "forward", cmd ) == 0 ) { if ( cont.size ( ) >= 1 ) { buf.push_back ( cont.front ( ) ); cont.pop_front ( ); } continue ; } } } return ( EXIT_SUCCESS ); }
a.cc: In function 'int main(int, char**)': a.cc:73:12: error: 'strcmp' was not declared in this scope 73 | if ( strcmp ( "show", cmd ) == 0 ) | ^~~~~~ a.cc:6:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <map> +++ |+#include <cstring> 6 | using namespace std; a.cc:78:12: error: 'strcmp' was not declared in this scope 78 | if ( strcmp ( "click", cmd ) == 0 ) | ^~~~~~ a.cc:78:12: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:99:12: error: 'strcmp' was not declared in this scope 99 | if ( strcmp ( "back", cmd ) == 0 ) | ^~~~~~ a.cc:99:12: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:108:12: error: 'strcmp' was not declared in this scope 108 | if ( strcmp ( "forward", cmd ) == 0 ) | ^~~~~~ a.cc:108:12: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s520847757
p00641
C++
#include<bits/stdc++.h> using namespace std; class UnionFind{ int n; vector<int> p; public: UnionFind(int a){ n = a; p.resize(n, -1); } int find(int a){ if(p[a] < 0)return a; return p[a] = find(p[a]); } int unite(int a, int b){ a = find(a); b = find(b); p[a] = b; } }; int main(){ int n; while(cin >> n, n){ UnionFind uf(n); vector<int> a(n),b(n); for(int i=0;i<n;i++){ int u,v; cin >> u >> a[i] >> v >> b[i]; uf.unite(i,u); uf.unite(i,v); } vector<int> w(n,0), num(n,0); for(int i=0;i<n;i++){ int v = find(i); if(w[v] < a[i]){ w[v] = a[i]; num[v] = 1; }else if(w[v] == a[i]) num[v]++; if(w[v] < b[i]){ w[v] = b[i]; num[v] = 1; }else if(w[v] == b[i]) num[v]++; } int ans = 1, mod = 10007; for(int i=0;i<n;i++){ if(num[i]) (ans *= num[i]) %= mod; } cout << ans << endl; } }
a.cc: In member function 'int UnionFind::unite(int, int)': a.cc:16:3: warning: no return statement in function returning non-void [-Wreturn-type] 16 | } | ^ a.cc: In function 'int main()': a.cc:32:19: error: no matching function for call to 'find(int&)' 32 | int v = find(i); | ~~~~^~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided In file included from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided
s191988252
p00641
C++
#include<bits/stdc++.h> using namespace std; class UnionFind{ int n; vector<int> p, s; public: UnionFind(int a){ n = a; p.resize(n, -1); s.resize(n,1); } int find(int a){ if(p[a] < 0)return a; return p[a] = find(p[a]); } int unite(int a, int b){ a = find(a); b = find(b); if(s[a] < a[b]){ p[a] = b; s[b] += s[a]; }else{ p[b] = a; s[a] += s[b]; } } }; int main(){ int n; while(cin >> n, n){ UnionFind uf(n); vector<int> a(n),b(n); for(int i=0;i<n;i++){ int u,v; cin >> u >> a[i] >> v >> b[i]; uf.unite(i,u); uf.unite(i,v); } vector<int> w(n,0), num(n,0); for(int i=0;i<n;i++){ int v = uf.find(i); if(w[v] < a[i]){ w[v] = a[i]; num[v] = 1; }else if(w[v] == a[i]) num[v]++; if(w[v] < b[i]){ w[v] = b[i]; num[v] = 1; }else if(w[v] == b[i]) num[v]++; } int ans = 1, mod = 10007; for(int i=0;i<n;i++){ if(num[i]) (ans *= num[i]/2) %= mod; } cout << ans << endl; } }
a.cc: In member function 'int UnionFind::unite(int, int)': a.cc:15:16: error: invalid types 'int[int]' for array subscript 15 | if(s[a] < a[b]){ | ^ a.cc:20:3: warning: no return statement in function returning non-void [-Wreturn-type] 20 | } | ^
s989733317
p00641
C++
// AOJ1055 Huge Family #include <iostream> #include <vector> #include <queue> using namespace std; int main(){ int n; while(cin >> n, n){ vector< vector< pair<int, int> > > vp(n, vector< pair<int, int> >(2)); for(int i=0;i<n;i++){ for(int j=0;j<2;j++){ int a, b; cin >> a >> b; vp[i][j] = make_pair(a,b); } } int ans = 1; vector<bool> vb(n, false); for(int i=0;i<n;i++){ if(vb[i]) continue; vector<int> vi; queue<int> qu; qu.push(i); vb[i] = true; while(!qu.empty()){ int t = qu.front(); qu.pop(); for(int j=0;j<2;j++){ vi.push_back(vp[t][j].second); int nxt = vp[t][j].first; if(!vb[nxt]){ qu.push(nxt); vb[nxt] = true; } } } int cnt = 0; int m = *max_element(vi.begin(), vi.end()); for(int j=0;j<vi.size();j++) if(vi[j]==m) cnt++; ans = (ans*(cnt/2))%10007; } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:38:34: error: 'max_element' was not declared in this scope 38 | int m = *max_element(vi.begin(), vi.end()); | ^~~~~~~~~~~
s915626360
p00641
C++
#include <iostream> #include <vector> #include <stack> #include <map> using namespace std; typedef vector <int> VI; typedef vector <VI> VVI; typedef pair <int, int> PII; #define REP(i,n) for(int i=0;i<(int)n;++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define ALL(c) (c).begin(), (c).end() typedef int Weight; struct Edge { int src, dst; Weight weight; Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { } }; bool operator < (const Edge &e, const Edge &f) { return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!! e.src != f.src ? e.src < f.src : e.dst < f.dst; } typedef vector<Edge> Edges; typedef vector<Edges> Graph; typedef vector<Weight> Array; typedef vector<Array> Matrix; void visit(const Graph &g, int v, vector< vector<int> >& scc, stack<int> &S, vector<bool> &inS, vector<int> &low, vector<int> &num, int& time) { low[v] = num[v] = ++time; S.push(v); inS[v] = true; FOR(e, g[v]) { int w = e->dst; if (num[w] == 0) { visit(g, w, scc, S, inS, low, num, time); low[v] = min(low[v], low[w]); } else if (inS[w]) low[v] = min(low[v], num[w]); } if (low[v] == num[v]) { scc.push_back(vector<int>()); while (1) { int w = S.top(); S.pop(); inS[w] = false; scc.back().push_back(w); if (v == w) break; } } } void stronglyConnectedComponents(const Graph& g, vector< vector<int> >& scc) { const int n = g.size(); vector<int> num(n), low(n); stack<int> S; vector<bool> inS(n); int time = 0; REP(u, n) if (num[u] == 0) visit(g, u, scc, S, inS, low, num, time); } int main() { int n; while ( cin >> n && n ) { Graph G(n); map <PII, int> F; for ( int i = 0; i < n; ++ i ) { for ( int j = 0; j < 2; ++ j ) { int b, f; cin >> b >> f; G[i].push_back( Edge( i, b, f ) ); F[PII(i, b)] = f; } } VVI scc; int res = 1; stronglyConnectedComponents( G, scc ); for ( auto it = scc.begin(); it != scc.end(); ++ it ) { VI V = *it; int m = V.size(); int maxf = 0; res = ( res * cnt ) % 10007; } cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:85:27: error: 'cnt' was not declared in this scope; did you mean 'int'? 85 | res = ( res * cnt ) % 10007; | ^~~ | int
s256238113
p00641
C++
#include <iostream> #include <queue> #include <vector> using namespace std; int done[100000]; vector< vector<int> > g; vector< vector<int> > g_c; int bfs(int x){ queue<int> Q; vector<int> vec; Q.push(x); while(Q.size()){ int q = Q.front(); Q.pop(); if( done[q] ) continue; else done[q] = true; for(int i = 0 ; i < g[q].size() ; i++){ Q.push(g[q][i]); vec.push_back(g_c[q][i]); } } //cout << x << " " << vec.size() << endl; sort(vec.begin(),vec.end()); int answer = 0; for(int i = 0 ; i < vec.size() ; i++){ if( vec[i] == vec.back() ) answer++; } return answer/2; } int main(){ int n; while(cin >> n && n){ for(int i = 0 ; i < 100000 ; i++) done[i] = 0; g.clear(); g_c.clear(); g.resize(n); g_c.resize(n); for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < 2 ; j++){ int a,b; cin >> a >> b; g[i].push_back(a); g_c[i].push_back(b); } } long long ans = 1; for(int i = 0 ; i < n ; i++){ if( done[i] == 0 ){ ans *= bfs(i); ans %= 10007; } } cout << ans << endl; } }
a.cc: In function 'int bfs(int)': a.cc:23:9: error: 'sort' was not declared in this scope; did you mean 'short'? 23 | sort(vec.begin(),vec.end()); | ^~~~ | short
s479068762
p00642
C
#include<iostream> #include<vector> using namespace std; double c[100001][20]; int main() { int n; double exp[100001]; double pro[20]; pro[0]=1.0; for(int i=1;i<20;i++){ pro[i]=pro[i-1]/2.0; // cout<<pro[i]<<" "; } // cout<<endl<<endl; for(int i=0;i<100001;i++){ for(int j=0;j<20;j++) c[i][j]=0.0; exp[i]=0.0; } c[0][0]=1.0; for(int day=1;day<5;day++){ exp[day]=exp[day-1]; c[day][1]=c[day-1][0]; for(int k=1;k<20;k++){ c[day][k+1]=c[day-1][k]*pro[k]; c[day][0]+=c[day-1][k]*(1-pro[k]); exp[day]+=k*c[day-1][k]*(1-pro[k]); } // for(int k=0;k<20;k++) // printf("%.3f ",c[day][k]); // cout<<" exp "<<exp[day]<<endl; } while(cin>>n && n!=0){ double ans=0.0; ans+=exp[n]; for(int i=0;i<20;i++){ ans+=c[n][i]*i; } cout<<ans<<endl; } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s027279364
p00642
C
#include<iostream> #include<vector> using namespace std; const int MAX=10; int main() { double e[100001]; for(int i=0;i<=100000;i++) e[i]=0.0; e[0]=0.0; e[1]=1.0; e[2]=1.5; double pro[MAX+1],imp[MAX+1]; pro[0]=1.0; for(int i=1;i<=MAX;i++){ double p=1.0/(1<<(i-1)); pro[i]=pro[i-1]*p; imp[i]=pro[i-1]*(1.0-p); // cout<<imp[i]<<endl; } for(int day=3;day<=100000;day++){ for(int k=2;k<=min(day,MAX);k++){ e[day]+=imp[k]*(e[day-k]+k-1); // cout<<imp[k]<<" "<<(e[day-k]+k-1)<<endl; } if(day<MAX) e[day]+=pro[day]*day; // cout<<e[day]<<endl; } int n; while(cin>>n && n!=0) cout<<e[n]<<endl; return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s972620946
p00642
C++
#include<cstdio> using namespace std; double dp[100000+1]; main(){ int n; while( cin >> n ) { if(n == 0)break; double ans = 0; fill(dp, dp +n+1, 0); for(int i=0; i<=n; i++){ double rate = 1, prate=1, base=1 - dp[i]; for(int j=i+1; j<=n; j++){ double nrate = rate * prate; if(nrate < 0.0000000001)break; dp[j] += (nrate * base); prate = nrate; rate *= 0.5; } ans += dp[i]; } printf("%0.8lf\n",ans); } return 0; }
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:8:10: error: 'cin' was not declared in this scope 8 | while( cin >> n ) { | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<cstdio> +++ |+#include <iostream> 2 | a.cc:11:5: error: 'fill' was not declared in this scope 11 | fill(dp, dp +n+1, 0); | ^~~~
s340633199
p00642
C++
#include<cstdio> double dp[100000+1]; main(){ int n; while( cin >> n ) { if(n == 0)break; double ans = 0; fill(dp, dp +n+1, 0); for(int i=0; i<=n; i++){ double rate = 1, prate=1, base=1 - dp[i]; for(int j=i+1; j<=n; j++){ double nrate = rate * prate; if(nrate < 0.0000000001)break; dp[j] += (nrate * base); prate = nrate; rate *= 0.5; } ans += dp[i]; } printf("%0.8lf\n",ans); } return 0; }
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:6:10: error: 'cin' was not declared in this scope 6 | while( cin >> n ) { | ^~~ a.cc:9:5: error: 'fill' was not declared in this scope 9 | fill(dp, dp +n+1, 0); | ^~~~
s015138389
p00642
C++
#include<vector> #include<map> #include<queue> #include<stack> #include<cstdio> using namespace std; double dp[100000+1]; main(){ int n; while( cin >> n ) { if(n == 0)break; double ans = 0; fill(dp, dp +n+1, 0); for(int i=0; i<=n; i++){ double rate = 1, prate=1, base=1 - dp[i]; for(int j=i+1; j<=n; j++){ double nrate = rate * prate; if(nrate < 0.0000000001)break; dp[j] += (nrate * base); prate = nrate; rate *= 0.5; } ans += dp[i]; } printf("%0.8lf\n",ans); } }
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:12:10: error: 'cin' was not declared in this scope 12 | while( cin >> n ) { | ^~~ a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 5 | #include<cstdio> +++ |+#include <iostream> 6 |
s200442183
p00642
C++
#include<vector> #include<map> #include<queue> #include<stack> #include<cstdio> using namespace std; double dp[100000+1]; main(){ int n; while( cin >> n ) { if(n == 0)break; double ans = 0; fill(dp, dp +n+1, 0); for(int i=0; i<=n; i++){ double rate = 1, prate=1, base=1 - dp[i]; for(int j=i+1; j<=n; j++){ double nrate = rate * prate; if(nrate < 0.0000000001)break; dp[j] += (nrate * base); prate = nrate; rate *= 0.5; } ans += dp[i]; } printf("%0.8lf\n",ans); } }
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:12:10: error: 'cin' was not declared in this scope 12 | while( cin >> n ) { | ^~~ a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 5 | #include<cstdio> +++ |+#include <iostream> 6 |
s030268606
p00642
C++
#include<vector> #include<map> #include<queue> #include<stack> #include<cstdio> using namespace std; double dp[100000+1]; int main(){ int n; while( cin >> n ) { if(n == 0)break; double ans = 0; fill(dp, dp +n+1, 0); for(int i=0; i<=n; i++){ double rate = 1, prate=1, base=1 - dp[i]; for(int j=i+1; j<=n; j++){ double nrate = rate * prate; if(nrate < 0.0000000001)break; dp[j] += (nrate * base); prate = nrate; rate *= 0.5; } ans += dp[i]; } printf("%0.8lf\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:12:10: error: 'cin' was not declared in this scope 12 | while( cin >> n ) { | ^~~ a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 5 | #include<cstdio> +++ |+#include <iostream> 6 |
s245315353
p00642
C++
#define MAX 11 //無視しない連続数 #define MAX_N 100002 double dp[MAX_N][MAX]; double per[MAX]; double ans[MAX_N]; int main(void){ int n; double sum = 0; REP(i,1,MAX) per[i] = pow(0.5,i-1); dp[1][1] = 1.0; REP(i,1,MAX_N){ REP(j,1,MAX){ if(dp[i][j] > 0){ sum += dp[i][j] * per[j]; if(j == 1){ dp[i+1][j+1] += dp[i][j]; //最初は必ず取れる } else{ dp[i+1][1] += dp[i][j] * (1 - per[j]); //取れない時の遷移 dp[i+1][j+1] += dp[i][j] * per[j]; //取れる時の遷移 } } } ans[i] = sum; } while(cin>>n,n) printf("%.3lf\n",ans[n]); return 0; }
a.cc: In function 'int main()': a.cc:12:7: error: 'i' was not declared in this scope 12 | REP(i,1,MAX) per[i] = pow(0.5,i-1); | ^ a.cc:12:3: error: 'REP' was not declared in this scope 12 | REP(i,1,MAX) per[i] = pow(0.5,i-1); | ^~~ a.cc:32:9: error: 'cin' was not declared in this scope 32 | while(cin>>n,n) printf("%.3lf\n",ans[n]); | ^~~ a.cc:32:19: error: 'printf' was not declared in this scope 32 | while(cin>>n,n) printf("%.3lf\n",ans[n]); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | #define MAX 11 //無視しない連続数
s445420212
p00642
C++
#include<stdio.h> int main (){ int n; scanf("%d",&n);if(n==0)break; for(int iii=0;iii<n;iii++) { int x;double a=0;int g=0.5; scanf("%d",&x); a+=1; for(int i=1;i<x;i++) { for(int j=i;j<x;j++) a+=g; g=g*0.5; } printf("%d",&a); } return 0; }
a.cc: In function 'int main()': a.cc:7:24: error: break statement not within loop or switch 7 | scanf("%d",&n);if(n==0)break; | ^~~~~
s821025807
p00642
C++
#include<iostream> #include<cmath> using namespace std; #define MAX_N 1000 #define MAX_M 1000 #define MAX_P 1000 double dp[MAX_N][MAX_M][MAX_P]; double ventoh[MAX_N]; int n; int main() { for (int i = 0; i < MAX_N; i++) { for (int j = 0; j < MAX_M; j++) { for (int k = 0; k < MAX_P; k++) { dp[i][j][k] = 0.0; } } } dp[0][0][0] = 1; for (int i = 1; i < MAX_N; i++) { for (int j = 0; j < MAX_M; j++) { for (int k = 0; k < MAX_P - 1; k++) { if (dp[i - 1][j][k] >= 0) { dp[i][j + 1][k + 1] += dp[i - 1][j][k] * 1.0 / pow(2.0, k); dp[i][j][0] += dp[i - 1][j][k] * (1.0 - 1.0 / pow(2.0, k)); } } } } for (int i = 0; i < MAX_N; i++) { for (int j = 0; j < MAX_M; j++) { for (int k = 0; k < MAX_P; k++) { if (dp[i][j][k] >= 0) { ventoh[i] += dp[i][j][k] * j; } } } } while (true) { cin >> n; if (n == 0) { break; } cout << ventoh[n] << endl; } }
/tmp/cc5nCCvN.o: in function `main': a.cc:(.text+0x361): relocation truncated to fit: R_X86_64_PC32 against symbol `ventoh' defined in .bss section in /tmp/cc5nCCvN.o a.cc:(.text+0x3c4): relocation truncated to fit: R_X86_64_PC32 against symbol `ventoh' defined in .bss section in /tmp/cc5nCCvN.o a.cc:(.text+0x403): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc5nCCvN.o a.cc:(.text+0x41b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc5nCCvN.o a.cc:(.text+0x425): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc5nCCvN.o a.cc:(.text+0x436): relocation truncated to fit: R_X86_64_PC32 against symbol `ventoh' defined in .bss section in /tmp/cc5nCCvN.o collect2: error: ld returned 1 exit status
s224168958
p00642
C++
#include <iostream> using namespace std; double fanc(int a,double p) { if (a == 0)return; fanc(a - 1, p / 2); fanc(a - 2, 100); } int main() { cin.tie(false); ios::sync_with_stdio(0); int n; while (cin >> n&&n != 0) { cout << fanc(n, 100) << "\n"; } }
a.cc: In function 'double fanc(int, double)': a.cc:6:20: error: return-statement with no value, in function returning 'double' [-fpermissive] 6 | if (a == 0)return; | ^~~~~~ a.cc: In function 'int main()': a.cc:14:16: error: no matching function for call to 'std::basic_istream<char>::tie(bool)' 14 | cin.tie(false); | ~~~~~~~^~~~~~~ In file included from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]' 299 | tie() const | ^~~ /usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate expects 0 arguments, 1 provided /usr/include/c++/14/bits/basic_ios.h:311:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]' 311 | tie(basic_ostream<_CharT, _Traits>* __tiestr) | ^~~ /usr/include/c++/14/bits/basic_ios.h:311:43: note: no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*' 311 | tie(basic_ostream<_CharT, _Traits>* __tiestr) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ a.cc: In function 'double fanc(int, double)': a.cc:9:13: warning: control reaches end of non-void function [-Wreturn-type] 9 | fanc(a - 2, 100); | ~~~~^~~~~~~~~~~~
s316497332
p00642
C++
// AOJ1056 Ben Toh #include <iostream> using namespace std; int main(){ int n; double dp[100001]; dp[0] = 0.0; dp[1] = 1.0; dp[2] = 1.5; for(int i=3;i<=100000;i++){ dp[i] = 0.0; double cur = 1.0, mul = 0.5; for(int j=2;j<=min(i,20);j++){ dp[i] += cur*(1-mul)*(j-1+dp[i-j]); cur *= mul; mul *= 0.5; } if(i<=20) dp[i] += cur*i; } // printf("double ans[100001] = {"); // for(int i=0;i<100001;i++) printf("%.2lf, ", dp[i]); // printf("};"); while(cin >> n, n){ printf("%.2lf\n", ans[n]); } }
a.cc: In function 'int main()': a.cc:25:35: error: 'ans' was not declared in this scope; did you mean 'abs'? 25 | printf("%.2lf\n", ans[n]); | ^~~ | abs
s820005688
p00642
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MAX_N=100001; int main(){ // iツ嘉アツ姪堋づ泳ツ古つ連ツ堕アツつオツづ偲ヲツづェツづゥツ確ツ猟ヲツづーツ格ツ納 vector<vector<double> > dp; vector<double> v(51,0.0); for(int i = 0; i < MAX_N; i++){ dp.push_back(v); } //double dp[MAX_N][51]; //for(int i = 0; i < MAX_N; i++) // fill(dp[i],dp[i]+51,0.0); dp[1][1]=1.0; for(int i = 2; i < MAX_N; i++){ // iツ嘉アツ姪堋づ泳ツ古つ連ツ堕アツつオツづ偲ヲツづェツづゥツ確ツ猟ヲツづーツ計ツ算 for(int j = 0; j <= min(i,50); j++){ // ツ債。ツ嘉アツミツス if(j==0){ for(int k = 1; k <= min(i-1,50); k++){ dp[i][j]+=dp[i-1][k]*(1-pow(0.5,k)); } } // ツ連ツ堕アツ偲ヲツ督セ else{ dp[i][j]=dp[i-1][j-1]*(pow(0.5,j-1)); } } } int n; while(cin>>n&&n!=0){ double sum=0; for(int j = 1; j <= n; j++){ for(int i = 1; i <= j; i++){ sum+=dp[j][i]; } } cout<<sum<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:28:65: error: 'pow' was not declared in this scope 28 | dp[i][j]+=dp[i-1][k]*(1-pow(0.5,k)); | ^~~ a.cc:33:56: error: 'pow' was not declared in this scope 33 | dp[i][j]=dp[i-1][j-1]*(pow(0.5,j-1)); | ^~~
s021219691
p00642
C++
#include <iostream> #include <math.h> #define TABLE 100 double psb( int n ) { return pow(0.5,n-1); } int main() { int n; double sum; double dp[TABLE][TABLE]; while(std::cin >> n, n) { sum = 0; for( int i = 0; i <= n+3; i++) memset( dp, 0, sizeof(dp)); for( int j = 1; j <= n; j++) dp[1][j] = 1.0f; for( int i = 2; i <= n; i++) for( int j = i; j <= n; j++) { dp[i][j] = /*dp[i-1][j-1]*psb(j) +*/ dp[i][j-1]; for( int k = 1; k < i; k++) { dp[i][j] += dp[k][j-1]*psb(j); } } for( int i = 1; i <= n; i++) sum += dp[i][n]; printf("%lf\n",sum); for( int i = 0; i <= n; i++) { for( int j = 0; j <= n; j++) { std::cout << " " << dp[j][i] << " "; } std::cout << std::endl; } } return 0; }
a.cc: In function 'int main()': a.cc:22:25: error: 'memset' was not declared in this scope 22 | memset( dp, 0, sizeof(dp)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <math.h> +++ |+#include <cstring> 3 |
s372384202
p00642
C++
import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static int N; static double[] exp = new double[100001]; public static void main(String[] args) { precalc(); while (true) { N = sc.nextInt(); if (N == 0) break; System.out.println(solve()); } } static double solve() { return exp[N]; } static void precalc() { int pos = 0; double[][] prob = new double[2][101]; double[][] v = new double[2][101]; prob[pos][0] = 1; double[] success = new double[101]; success[0] = 1; for (int i = 1; i < success.length; ++i) { success[i] = success[i - 1] / 2; } for (int i = 0; i <= 100000; ++i) { double sum = 0; Arrays.fill(prob[1 - pos], 0); Arrays.fill(v[1 - pos], 0); for (int j = 0; j < 100; ++j) { sum += v[pos][j]; prob[1 - pos][j + 1] += prob[pos][j] * success[j]; prob[1 - pos][0] += prob[pos][j] * (1 - success[j]); v[1 - pos][j + 1] += (v[pos][j] + prob[pos][j]) * success[j]; v[1 - pos][0] += v[pos][j] * (1 - success[j]); } exp[i] = sum; pos = 1 - pos; } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Arrays; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Scanner; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main { | ^~~~~~
s984531523
p00642
C++
#include <cstdio> #include <algorithm> using namespace std; #define EPS (1e-13) double dp[100001]; int main() { dp[1]=1; for(int n=2;n<=100000;n++) { double p=1,win=0.5; int k=1; while(EPS<p&&k<n) { double not=p*(1-win); dp[n]+=not*(k+dp[max(n-k-1,0)]); p*=win; win/=2; k++; } dp[n]+=n*p; } int n; while(scanf("%d",&n),n) { printf("%lf\n",dp[n]); } }
a.cc: In function 'int main()': a.cc:12:32: error: expected unqualified-id before 'not' token 12 | double not=p*(1-win); | ^~~ a.cc:13:35: error: invalid type argument of unary '*' (have 'double') 13 | dp[n]+=not*(k+dp[max(n-k-1,0)]); | ^~~~~~~~~~~~~~~~~~~~~
s819355138
p00642
C++
#include <cstdio> #include <cstring> #define EPS (1e-13) #define MAX(A,B)((A)>=(B)?(A):(B)) double dp[1000001]; int main() { int n; while(scanf("%d",&n),n) { for(int i=0;i<=1000000;i++) dp[i]=0; dp[1]=1; for(int i=2;i<=n;i++) { double p=1.0,win=0.5; for(int j=1;j<i && EPS<p;j++) { double not=p*(1-win); dp[i]+=not*(j+dp[MAX(0,n-1-j)]); p*=win; win/=2; } dp[i]+=p*i; } printf("%lf\n",dp[n]); } }
a.cc: In function 'int main()': a.cc:14:40: error: expected unqualified-id before 'not' token 14 | double not=p*(1-win); | ^~~ a.cc:15:43: error: invalid type argument of unary '*' (have 'double') 15 | dp[i]+=not*(j+dp[MAX(0,n-1-j)]); | ^~~~~~~~~~~~~~~~~~~~~
s726757423
p00642
C++
#include <cstdio> using namespace std; &#160; const int MAX_N = 100001; const int MAX_K = 13; &#160; // 連続で x 回半額弁当をゲットしたときに半額弁当を得る確率 double P(int x){ &#160;&#160;&#160;&#160;return 1.0 / (1 << x); } &#160; // dp[i][k] := i 日目で k 回連続ゲットしたときの期待値 double dp[MAX_N+1][MAX_K+1] = {0}; // ans[i] := i 日目の半額弁当を得る個数の期待値 double ans[MAX_N+1] = {0}; &#160; int main(){ &#160;&#160;&#160;&#160;int n; &#160;&#160;&#160;&#160;double sum = 0; &#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;dp[0][0] = 1.0; &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// 半額弁当を得るとき &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dp[i+1][k+1] += dp[i][k] * P(k); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// 半額弁当を得られないとき &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dp[i+1][0] += dp[i][k] * (1.0 - P(k)); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ans[i] = sum; &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;while( scanf("%d", &n ) , n ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;printf("%.8f\n", ans[n-1] ); &#160;&#160;&#160;&#160;} }
a.cc:3:2: error: stray '#' in program 3 | &#160; | ^ a.cc:6:2: error: stray '#' in program 6 | &#160; | ^ a.cc:9:2: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:8: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:14: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:20: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:11:2: error: stray '#' in program 11 | &#160; | ^ a.cc:16:2: error: stray '#' in program 16 | &#160; | ^ a.cc:18:2: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:8: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:14: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:20: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:19:2: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:8: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:14: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:20: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:20:2: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:8: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:14: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:20: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:26: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:21:2: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:8: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:14: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:20: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:22:2: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:8: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:14: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:20: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:23:2: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:8: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:14: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:20: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:26: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:32: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:38: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:44: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:24:2: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:8: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:14: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:20: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:26: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:32: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:38: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:44: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:50: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:56: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:62: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:68: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:25:2: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:8: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:14: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:20: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:26: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:32: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:38: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:44: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:50: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:56: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:62: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:68: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:74: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:80: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:86: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:92: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:26:2: error: stray '#' in program 26 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | ^ a.cc:26:8: error: stray '#' in pro
s379247201
p00642
C++
#include <cstdio> using namespace std; &#160; const int MAX_N = 100001; const int MAX_K = 13; &#160; // 連続で x 回半額弁当をゲットしたときに半額弁当を得る確率 double P(int x){ &#160;&#160;&#160;&#160;return 1.0 / (1 << x); } &#160; // dp[i][k] := i 日目で k 回連続ゲットしたときの期待値 double dp[MAX_N+1][MAX_K+1] = {0}; // ans[i] := i 日目の半額弁当を得る個数の期待値 double ans[MAX_N+1] = {0}; &#160; int main(){ &#160;&#160;&#160;&#160;int n; &#160;&#160;&#160;&#160;double sum = 0; &#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;dp[0][0] = 1.0; &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// 半額弁当を得るとき &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dp[i+1][k+1] += dp[i][k] * P(k); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// 半額弁当を得られないとき &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dp[i+1][0] += dp[i][k] * (1.0 - P(k)); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ans[i] = sum; &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;while( scanf("%d", &n ) , n ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;printf("%.8f\n", ans[n-1] ); &#160;&#160;&#160;&#160;} }
a.cc:3:2: error: stray '#' in program 3 | &#160; | ^ a.cc:6:2: error: stray '#' in program 6 | &#160; | ^ a.cc:9:2: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:8: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:14: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:20: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:11:2: error: stray '#' in program 11 | &#160; | ^ a.cc:16:2: error: stray '#' in program 16 | &#160; | ^ a.cc:18:2: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:8: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:14: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:20: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:19:2: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:8: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:14: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:20: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:20:2: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:8: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:14: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:20: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:26: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:21:2: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:8: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:14: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:20: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:22:2: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:8: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:14: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:20: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:23:2: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:8: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:14: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:20: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:26: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:32: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:38: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:44: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:24:2: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:8: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:14: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:20: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:26: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:32: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:38: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:44: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:50: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:56: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:62: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:68: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:25:2: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:8: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:14: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:20: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:26: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:32: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:38: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:44: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:50: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:56: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:62: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:68: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:74: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:80: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:86: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:92: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:26:2: error: stray '#' in program 26 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | ^ a.cc:26:8: error: stray '#' in pro
s096762135
p00642
C++
#include <cstdio> using namespace std; &#160; const int MAX_N = 100001; const int MAX_K = 8; &#160; // 連続で x 回半額弁当をゲットしたときに半額弁当を得る確率 double P(int x){ &#160;&#160;&#160;&#160;return 1.0 / (1 << x); } &#160; // dp[i][k] := i 日目で k 回連続ゲットしたときの期待値 double dp[MAX_N+1][MAX_K+1] = {0}; // ans[i] := i 日目の半額弁当を得る個数の期待値 double ans[MAX_N+1] = {0}; &#160; int main(){ &#160;&#160;&#160;&#160;int n; &#160;&#160;&#160;&#160;double sum = 0; &#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;dp[0][0] = 1.0; &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// 半額弁当を得るとき &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dp[i+1][k+1] += dp[i][k] * P(k); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// 半額弁当を得られないとき &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dp[i+1][0] += dp[i][k] * (1.0 - P(k)); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ans[i] = sum; &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;while( scanf("%d", &n ) , n ){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;printf("%.8f\n", ans[n-1] ); &#160;&#160;&#160;&#160;} }
a.cc:3:2: error: stray '#' in program 3 | &#160; | ^ a.cc:6:2: error: stray '#' in program 6 | &#160; | ^ a.cc:9:2: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:8: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:14: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:9:20: error: stray '#' in program 9 | &#160;&#160;&#160;&#160;return 1.0 / (1 << x); | ^ a.cc:11:2: error: stray '#' in program 11 | &#160; | ^ a.cc:16:2: error: stray '#' in program 16 | &#160; | ^ a.cc:18:2: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:8: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:14: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:18:20: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;int n; | ^ a.cc:19:2: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:8: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:14: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:19:20: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;double sum = 0; | ^ a.cc:20:2: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:8: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:14: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:20: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:20:26: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;&#160; | ^ a.cc:21:2: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:8: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:14: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:21:20: error: stray '#' in program 21 | &#160;&#160;&#160;&#160;dp[0][0] = 1.0; | ^ a.cc:22:2: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:8: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:14: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:22:20: error: stray '#' in program 22 | &#160;&#160;&#160;&#160;for(int i=0 ; i < MAX_N ; i++ ){ | ^ a.cc:23:2: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:8: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:14: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:20: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:26: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:32: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:38: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:23:44: error: stray '#' in program 23 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int k=0 ; k < MAX_K ; k++ ){ | ^ a.cc:24:2: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:8: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:14: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:20: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:26: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:32: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:38: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:44: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:50: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:56: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:62: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:24:68: error: stray '#' in program 24 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if( dp[i][k] > 0 ){ | ^ a.cc:25:2: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:8: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:14: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:20: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:26: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:32: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:38: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:44: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:50: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:56: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:62: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:68: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:74: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:80: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:86: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:25:92: error: stray '#' in program 25 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sum += dp[i][k] * P(k); | ^ a.cc:26:2: error: stray '#' in program 26 | &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | ^ a.cc:26:8: error: stray '#' in pro
s962039812
p00642
C++
#include<vector> #include<map> #include<queue> #include<stack> #include<cstdio> using namespace std; double dp[100000+1]; main(){ int n; while( cin >> n ) { if(n == 0)break; double ans = 0; fill(dp, dp +n+1, 0); for(int i=0; i<=n; i++){ double rate = 1, prate=1, base=1 - dp[i]; for(int j=i+1; j<=n; j++){ double nrate = rate * prate; if(nrate < 0.0000000001)break; dp[j] += (nrate * base); prate = nrate; rate *= 0.5; } ans += dp[i]; } printf("%0.8lf\n",ans); } }
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:12:10: error: 'cin' was not declared in this scope 12 | while( cin >> n ) { | ^~~ a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 5 | #include<cstdio> +++ |+#include <iostream> 6 |
s829802460
p00643
C
#include<queue> #include<iostream> using namespace std; int dy[]={-1,0,1,0},dx[]={0,-1,0,1}; struct Dice{ int t,b,n,s,e,w; int y,x; int c; Dice(int top,int bottom,int north,int south,int east,int west,int sx,int sy,int cost){ t=top,b=bottom,n=north,s=south,e=east,w=west; x=sx,y=sy,c=cost; } bool operator<(const Dice &r)const { return c>r.c; } void roll(int d) { int tmp; y+=dy[d],x+=dx[d]; if(d==0) { tmp=t; t=s; s=b; b=n; n=tmp; }else if(d==1) { tmp=t; t=e; e=b; b=w; w=tmp; }else if(d==2) { tmp=t; t=n; n=b; b=s; s=tmp; }else { tmp=t; t=w; w=b; b=e; e=tmp; } } }; int w,h; bool in(int x,int y){ if(x<0 || y<0 || x>=w || y>=h) return false; return true; } int main(){ int p[10][10]; while(cin>>h>>w && h!=0){ priority_queue<Dice> que; for(int y=0;y<h;y++) for(int x=0;x<w;x++) cin>>p[y][x]; int gx,gy,sx,sy; cin>>sy>>sx>>gy>>gx; que.push(Dice(1,6,5,2,3,4,sx,sy,0)); while(!que.empty()){ Dice now=que.top(); que.pop(); // cout<<now.x<<" "<<now.y<<" "<<now.b<<" "<<now.c<<endl; if(now.x==gx && now.y==gy) {cout<<now.c<<endl; break;} for(int r=0;r<4;r++){ Dice copy=now; copy.roll(r); if(in(copy.x,copy.y)){ copy.c+=copy.b*p[copy.y][copy.x]; que.push(copy); } } } } return 0; }
main.c:1:9: fatal error: queue: No such file or directory 1 | #include<queue> | ^~~~~~~ compilation terminated.
s429937497
p00643
C++
/* * File: main.cpp * Author: Prowindy * * Created on 2011年8月24日, 下午2:27 */ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <queue> using namespace std; int dp[16][16][8][8][8]; int main() { for (int h, w; scanf("%d%d", &h, &w) && h;) { int table[16][16]; int x, y; for (y = 0; y < h; y++) for (x = 0; x < w; x++) scanf("%d", &table[x][y]); int startX, startY, goalX, goalY; cin >> startY >> startX >> goalY >> goalX; vector<int> node; priority_queue<vector<int>, vector<vector<int> >, greater<vector<int> > > q; { node.push_back(0); node.push_back(startX); node.push_back(startY); node.push_back(1); node.push_back(2); node.push_back(3); q.push(node); } memset(dp, 100, sizeof (dp)); int oo = dp[0][0][0][0][0]; dp[startX][startY][1][2][3] = 0; while (!q.empty()) { const vector<int> node = q.top(); q.pop(); const int cost = node[0]; const int x = node[1]; const int y = node[2]; const int up = node[3]; const int south = node[4]; const int east = node[5]; if (dp[x][y][up][south][east] != cost) { continue; } // 東西南北 for (int dir = 0; dir < 4; ++dir) { int nx, ny, nup, nsouth, neast, ncost; switch (dir) { case 0: //東 if (x + 1 == w) { continue; } nx = x + 1; ny = y; nup = 7 - east; nsouth = south; neast = up; break; case 1: //西 if (x == 0) { continue; } nx = x - 1; ny = y; nup = east; nsouth = south; neast = 7 - up; break; case 2: //南 if (y + 1 == h) { continue; } nx = x; ny = y + 1; nup = 7 - south; nsouth = up; neast = east; break; case 3: //北 if (y == 0) { continue; } nx = x; ny = y - 1; nup = south; nsouth = 7 - up; neast = east; break; } ncost = cost + table[nx][ny] * (7 - nup); if (dp[nx][ny][nup][nsouth][neast] <= ncost) { continue; } dp[nx][ny][nup][nsouth][neast] = ncost; vector<int> next; next.push_back(ncost); next.push_back(nx); next.push_back(ny); next.push_back(nup); next.push_back(nsouth); next.push_back(neast); q.push(next); } } int best = oo; for (int i = 1; i <= 6; ++i) { for (int j = 1; j <= 6; ++j) { for (int k = 1; k <= 6; ++k) { best = min(best, dp[goalX][goalY][i][j][k]); } } } cout << best << endl; } }
a.cc: In function 'int main()': a.cc:52:9: error: 'memset' was not declared in this scope 52 | memset(dp, 100, sizeof (dp)); | ^~~~~~ a.cc:26:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 25 | #include <queue> +++ |+#include <cstring> 26 | using namespace std;
s014921082
p00643
C++
/* * Author: lee1r * Created Time: 2011/8/24 15:42:22 * File Name: 8.24_G.cpp */ #include<iostream> #include<sstream> #include<fstream> #include<vector> #include<list> #include<deque> #include<queue> #include<stack> #include<map> #include<set> #include<bitset> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cstring> #include<cctype> #include<cmath> #include<ctime> #define L(x) ((x)<<1) #define R(x) ((x)<<1|1) #define Half(x) ((x)>>1) #define Lowbit(x) ((x)&(-(x))) using namespace std; const int kInf(0x7f7f7f7f); const double kEps(1e-8); typedef unsigned int uint; typedef long long int64; typedef unsigned long long uint64; bool scanf(int &num) { char in; while((in=getchar())!=EOF && (in>'9' || in<'0')); if(in==EOF) return false; num=in-'0'; while(in=getchar(),in>='0' && in<='9') num*=10,num+=in-'0'; return true; } int init[7]={}; int dice[50][7]={ {0,0,0,0,0,0}, {6,2,3,5,4,1}, {6,3,5,4,2,1}, {6,4,2,3,5,1}, {1,3,2,4,5,6}, {1,4,5,3,2,6}, {2,1,3,6,4,5}, {1,5,3,2,4,6}, {5,6,3,1,4,2}, {4,2,6,5,1,3}, {2,3,6,4,1,5}, {3,5,6,2,1,4}, {5,4,6,3,1,2}, {1,2,4,5,3,6}, {2,6,4,1,3,5}, {6,5,4,2,3,1}, {5,1,4,6,3,2}, {3,2,1,5,6,4}, {2,4,1,3,6,5}, {4,5,1,2,6,3}, {5,3,1,4,6,2}, {4,1,2,6,5,3}, {3,1,5,6,2,4}, {4,6,5,1,2,3}, {3,6,2,1,5,4} }; void Left(int *a,int *b) { b[1]=a[1];b[3]=a[3]; b[0]=a[4];b[4]=a[5];b[5]=a[2];b[2]=a[0]; } void Front(int *a,int *b) { b[4]=a[4];b[2]=a[2]; b[0]=a[1];b[1]=a[5];b[5]=a[3];b[3]=a[0]; } int N,M,r[17][17],x0,y0,x1,y1; int dist[9999]; bool inq[9999]; int f(int a,int b,int c,int d) { return a*1000+b*100+c*10+d; } void SPFA() { int start(f(x0,y0,6,2)); queue<int> q; memset(inq,false,sizeof(inq)); memset(dist,0x7f,sizeof(dist)); dist[start]=0; q.push(start); inq[start]=true; while(!q.empty()) { int t(q.front());q.pop();inq[t]=false; int d(dist[t]); int nowx,nowy,nowa,nowb; nowb=t%10;t/=10; nowa=t%10;t/=10; nowy=t%10;t/=10; nowx=t%10; int pos; for(pos=1;pos<=24;pos++) if(dice[pos][0]==nowa && dice[pos][1]==nowb) break; int news[7]; if(nowy-1>=0) { Left(dice[pos],news); int tt(f(nowx,nowy-1,news[0],news[1])); if(dist[tt]>d+r[nowx][nowy-1]*news[0]) { dist[tt]=d+r[nowx][nowy-1]*news[0]; if(!inq[tt]) { q.push(tt); inq[tt]=true; } } } if(nowx+1<N) { Front(dice[pos],news); int tt(f(nowx+1,nowy,news[0],news[1])); if(dist[tt]>d+r[nowx+1][nowy]*news[0]) { dist[tt]=d+r[nowx+1][nowy]*news[0]; if(!inq[tt]) { q.push(tt); inq[tt]=true; } } } if(nowx-1>=0) { int tmp[7]; Front(dice[pos],news); Front(news,tmp); Front(tmp,news); int tt(f(nowx-1,nowy,news[0],news[1])); if(dist[tt]>d+r[nowx-1][nowy]*news[0]) { dist[tt]=d+r[nowx-1][nowy]*news[0]; if(!inq[tt]) { q.push(tt); inq[tt]=true; } } } if(nowy+1<M) { int tmp[7]; Left(dice[pos],news); Left(news,tmp); Left(tmp,news); int tt(f(nowx,nowy+1,news[0],news[1])); if(dist[tt]>d+r[nowx][nowy+1]*news[0]) { dist[tt]=d+r[nowx][nowy+1]*news[0]; if(!inq[tt]) { q.push(tt); inq[tt]=true; } } } } } int main() { #ifndef ONLINE_JUDGE //freopen("data.in","r",stdin); #endif while(scanf(N) && scanf(M) && (N || M)) { for(int i=0;i<N;i++) for(int j=0;j<M;j++) scanf(r[i][j]); scanf(x0);scanf(y0); scanf(x1);scanf(y1); // Input SPFA(); int ans(kInf); for(int i=1;i<=6;i++) for(int j=1;j<=6;j++) ans=min(ans,dist[f(x1,y1,i,j)]); printf("%d\n",ans); } return 0; }
a.cc:86:22: error: 'int y0' redeclared as different kind of entity 86 | int N,M,r[17][17],x0,y0,x1,y1; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/bits/requires_hosted.h:31, from /usr/include/c++/14/iostream:38, from a.cc:6: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:256:1: note: previous declaration 'double y0(double)' 256 | __MATHCALL (y0,, (_Mdouble_)); | ^~~~~~~~~~ a.cc:86:28: error: 'int y1' redeclared as different kind of entity 86 | int N,M,r[17][17],x0,y0,x1,y1; | ^~ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'void SPFA()': a.cc:97:20: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 97 | int start(f(x0,y0,6,2)); | ^~ | | | double (*)(double) noexcept a.cc:90:17: note: initializing argument 2 of 'int f(int, int, int, int)' 90 | int f(int a,int b,int c,int d) | ~~~~^ a.cc: In function 'int main()': a.cc:194:25: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 194 | scanf(x0);scanf(y0); | ^~ | | | double (*)(double) noexcept a.cc:35:17: note: initializing argument 1 of 'bool scanf(int&)' 35 | bool scanf(int &num) | ~~~~~^~~ a.cc:194:25: error: cannot bind rvalue '(int)y0' to 'int&' 194 | scanf(x0);scanf(y0); | ^~ a.cc:195:25: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 195 | scanf(x1);scanf(y1); | ^~ | | | double (*)(double) noexcept a.cc:35:17: note: initializing argument 1 of 'bool scanf(int&)' 35 | bool scanf(int &num) | ~~~~~^~~ a.cc:195:25: error: cannot bind rvalue '(int)y1' to 'int&' 195 | scanf(x1);scanf(y1); | ^~ a.cc:203:39: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 203 | ans=min(ans,dist[f(x1,y1,i,j)]); | ^~ | | | double (*)(double) noexcept a.cc:90:17: note: initializing argument 2 of 'int f(int, int, int, int)' 90 | int f(int a,int b,int c,int d) | ~~~~^
s756666978
p00643
C++
#include <stdlib.h> #include <stdio.h> #include <iostream> #include <algorithm> #include <string.h> #include <string> #include <map> #include <set> #include <math.h> #define M 15 using namespace std; struct node { int x, y, bottom, east; __int64 value; } Q[M*M*M*M*M*M], s, p; int mark[M][M][M][M]; __int64 dis[M][M][M][M]; int value[M][M]; int n, m; int sx, sy, ex, ey; __int64 oo = 100000000000000LL; int add[7][7] = { {0}, {5, 4, 2, 3}, {3, 1, 4, 6}, {2, 6, 5, 1}, {5, 6, 2, 1}, {6, 4, 1, 3}, {3, 2, 4, 5} }; void checkIn(int &H) { if (dis[s.x][s.y][s.bottom][s.east] > s.value) { dis[s.x][s.y][s.bottom][s.east] = s.value; if (!mark[s.x][s.y][s.bottom][s.east]) { mark[s.x][s.y][s.bottom][s.east] = 1; Q[H++] = s; } //printf("s %d %d %d %d\n", s.x, s.y, s.bottom, s.east); } } int find(int e, int b, int k) { int i; for (i = 0; i < 4; i++) if (add[e][i] == b) { return add[e][(i + k + 4) % 4]; } } void SPFA() { int i, j, k, x, y, bottom, east; int L, H; for (x = 0; x < n; x++) for (y = 0; y < m; y++) for (i = 1; i <= 6; i++) for (j = 1; j <= 6; j++) { dis[x][y][i][j] = oo; mark[x][y][i][j] = 0; } dis[sx][sy][6][3] = 0; s.x = sx, s.y = sy, s.bottom = 6, s.east = 3, s.value = 0; mark[s.x][s.y][s.bottom][s.east] = 1; L = H = 0; Q[H++] = s; while (L < H) { p = Q[L++]; mark[p.x][p.y][p.bottom][p.east] = 0; x = p.x, y = p.y; if (x > 0) {//up s.x = p.x - 1; s.y = p.y; s.bottom = find(p.east, p.bottom, 1); s.east = p.east; s.value = p.value + value[s.x][s.y] * s.bottom; checkIn(H); } if (x < n - 1) {//down s.x = p.x + 1; s.y = p.y; s.bottom = find(p.east, p.bottom, -1); s.east = p.east; s.value = p.value + value[s.x][s.y] * s.bottom; checkIn(H); } if (y > 0) {//left s.x = p.x; s.y = p.y - 1; s.bottom = 7 - p.east; s.east = p.bottom; s.value = p.value + value[s.x][s.y] * s.bottom; checkIn(H); } if (y < m - 1) {//right //puts("yes"); s.x = p.x; s.y = p.y + 1; s.bottom = p.east; s.east = 7 - p.bottom; s.value = p.value + value[s.x][s.y] * s.bottom; checkIn(H); } } } int main(int argc, char** argv) { int i, j, k; while (scanf("%d %d", &n, &m), n | m) { for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &value[i][j]); scanf("%d %d %d %d", &sx, &sy, &ex, &ey); SPFA(); __int64 ans = oo; for (i = 1; i <= 6; i++) for (j = 1; j <= 6; j++) if (dis[ex][ey][i][j] < ans) ans = dis[ex][ey][i][j]; printf("%I64d\n", ans); } return 0; }
a.cc:15:5: error: '__int64' does not name a type; did you mean '__int64_t'? 15 | __int64 value; | ^~~~~~~ | __int64_t a.cc:18:1: error: '__int64' does not name a type; did you mean '__int64_t'? 18 | __int64 dis[M][M][M][M]; | ^~~~~~~ | __int64_t a.cc:22:1: error: '__int64' does not name a type; did you mean '__int64_t'? 22 | __int64 oo = 100000000000000LL; | ^~~~~~~ | __int64_t a.cc: In function 'void checkIn(int&)': a.cc:34:9: error: 'dis' was not declared in this scope; did you mean 'div'? 34 | if (dis[s.x][s.y][s.bottom][s.east] > s.value) { | ^~~ | div a.cc:34:45: error: 'struct node' has no member named 'value' 34 | if (dis[s.x][s.y][s.bottom][s.east] > s.value) { | ^~~~~ a.cc:35:45: error: 'struct node' has no member named 'value' 35 | dis[s.x][s.y][s.bottom][s.east] = s.value; | ^~~~~ a.cc: In function 'void SPFA()': a.cc:59:21: error: 'dis' was not declared in this scope; did you mean 'div'? 59 | dis[x][y][i][j] = oo; | ^~~ | div a.cc:59:39: error: 'oo' was not declared in this scope 59 | dis[x][y][i][j] = oo; | ^~ a.cc:62:5: error: 'dis' was not declared in this scope; did you mean 'div'? 62 | dis[sx][sy][6][3] = 0; | ^~~ | div a.cc:63:53: error: 'struct node' has no member named 'value' 63 | s.x = sx, s.y = sy, s.bottom = 6, s.east = 3, s.value = 0; | ^~~~~ a.cc:76:15: error: 'struct node' has no member named 'value' 76 | s.value = p.value + value[s.x][s.y] * s.bottom; | ^~~~~ a.cc:76:25: error: 'struct node' has no member named 'value' 76 | s.value = p.value + value[s.x][s.y] * s.bottom; | ^~~~~ a.cc:84:15: error: 'struct node' has no member named 'value' 84 | s.value = p.value + value[s.x][s.y] * s.bottom; | ^~~~~ a.cc:84:25: error: 'struct node' has no member named 'value' 84 | s.value = p.value + value[s.x][s.y] * s.bottom; | ^~~~~ a.cc:92:15: error: 'struct node' has no member named 'value' 92 | s.value = p.value + value[s.x][s.y] * s.bottom; | ^~~~~ a.cc:92:25: error: 'struct node' has no member named 'value' 92 | s.value = p.value + value[s.x][s.y] * s.bottom; | ^~~~~ a.cc:101:15: error: 'struct node' has no member named 'value' 101 | s.value = p.value + value[s.x][s.y] * s.bottom; | ^~~~~ a.cc:101:25: error: 'struct node' has no member named 'value' 101 | s.value = p.value + value[s.x][s.y] * s.bottom; | ^~~~~ a.cc: In function 'int main(int, char**)': a.cc:115:9: error: '__int64' was not declared in this scope; did you mean '__ynf64'? 115 | __int64 ans = oo; | ^~~~~~~ | __ynf64 a.cc:118:21: error: 'dis' was not declared in this scope; did you mean 'div'? 118 | if (dis[ex][ey][i][j] < ans) | ^~~ | div a.cc:118:41: error: 'ans' was not declared in this scope; did you mean 'abs'? 118 | if (dis[ex][ey][i][j] < ans) | ^~~ | abs a.cc:120:27: error: 'ans' was not declared in this scope; did you mean 'abs'? 120 | printf("%I64d\n", ans); | ^~~ | abs a.cc: In function 'int find(int, int, int)': a.cc:50:1: warning: control reaches end of non-void function [-Wreturn-type] 50 | } | ^
s700366393
p00643
C++
#include <iostream> #include <vector> #include <queue> #include <cstdio> using namespace std; const int INF = 1 << 30; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; class Dice { private: /* pip[0] = top, pip[1] = south, pip[2] = east pip[3] = bottom, pip[4] = north, pip[5] = west */ int pip[6]; public: enum { TOP, SOUTH, EAST, BOTTOM, NORTH, WEST }; Dice(int top = 1, int south = 2, int east = 3) { pip[TOP] = top; pip[SOUTH] = south; pip[EAST] = east; pip[BOTTOM] = 7 - top; pip[NORTH] = 7 - south; pip[WEST] = 7 - east; } // east:+, west:- void rotateX(int r) { while (r < 0) r += 4; r %= 4; for (int i = 0; i < r; ++i) { int tmp = pip[TOP]; pip[TOP] = pip[WEST]; pip[WEST] = pip[BOTTOM]; pip[BOTTOM] = pip[EAST]; pip[EAST] = tmp; } } // south:+, north:- void rotateY(int r) { while (r < 0) r += 4; r %= 4; for (int i = 0; i < r; ++i) { int tmp = pip[TOP]; pip[TOP] = pip[NORTH]; pip[NORTH] = pip[BOTTOM]; pip[BOTTOM] = pip[SOUTH]; pip[SOUTH] = tmp; } } int get(int p) const { return pip[p]; } }; class State { public: int x, y, cost; Dice dice; State(int _x = 0, int _y = 0, int _cost) :x(_x), y(_y), cost(_cost) {} bool operator < (const State& st) const { return this->cost > st.cost; } }; int main() { int h, w; while (cin >> h >> w) { if ((h|w) == 0) break; vector<vector<int> > mass(h, vector<int>(w)); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) cin >> mass[i][j]; } int sx, sy, gx, gy; cin >> sy >> sx >> gy >> gx; priority_queue<State> que; que.push(State(sx, sy, 0)); int dp[10][10][6][6][6]; // dp[y][x][top][south][east] for (int y = 0; y < 10; ++y) for (int x = 0; x < 10; ++x) for (int t = 0; t < 6; ++t) for (int s = 0; s < 6; ++s) for (int e = 0; e < 6; ++e) dp[y][x][t][s][e] = INF; while (!que.empty()) { const State st = que.top(); que.pop(); if (st.x == gx && st.y == gy) { cout << st.cost << endl; break; } if (dp[st.y][st.x][st.dice.get(Dice::TOP)][st.dice.get(Dice::SOUTH)][st.dice.get(Dice::EAST)] < st.cost) continue; dp[st.y][st.x][st.dice.get(Dice::TOP)][st.dice.get(Dice::SOUTH)][st.dice.get(Dice::EAST)] = st.cost; for (int d = 0; d < 4; ++d) { int x = st.x + dx[d]; int y = st.y + dy[d]; if (x < 0 || w <= x || y < 0 || h <= y) continue; Dice dice = st.dice; if (dx[d] != 0) dice.rotateX(dx[d]); else dice.rotateY(dy[d]); int cost = st.cost + mass[y][x] * dice.get(Dice::BOTTOM); if (dp[y][x][dice.get(Dice::TOP)][dice.get(Dice::SOUTH)][dice.get(Dice::EAST)] > cost) { dp[y][x][dice.get(Dice::TOP)][dice.get(Dice::SOUTH)][dice.get(Dice::EAST)] = cost; State tmp(x, y, cost); tmp.dice = dice; que.push(tmp); } } } } return 0; }
a.cc:73:37: error: default argument missing for parameter 3 of 'State::State(int, int, int)' 73 | State(int _x = 0, int _y = 0, int _cost) | ~~~~^~~~~ a.cc:73:13: note: ...following parameter 1 which has a default argument 73 | State(int _x = 0, int _y = 0, int _cost) | ~~~~^~~~~~
s907133816
p00643
C++
#include<queue> #include<iostream> using namespace std; int dy[]={-1,0,1,0},dx[]={0,-1,0,1}; struct Dice{ int t,b,n,s,e,w; int y,x; int c; Dice(int top,int bottom,int north,int south,int east,int west,int sx,int sy,int cost){ t=top,b=bottom,n=north,s=south,e=east,w=west; x=sx,y=sy,c=cost; } bool operator<(const Dice &r)const { return c>r.c; } void roll(int d) { int tmp; y+=dy[d],x+=dx[d]; if(d==0) { tmp=t; t=s; s=b; b=n; n=tmp; }else if(d==1) { tmp=t; t=e; e=b; b=w; w=tmp; }else if(d==2) { tmp=t; t=n; n=b; b=s; s=tmp; }else { tmp=t; t=w; w=b; b=e; e=tmp; } } }; int w,h; bool in(int x,int y){ if(x<0 || y<0 || x>=w || y>=h) return false; return true; } int main(){ int p[10][10],memo[10][10][100]; while(cin>>h>>w && h!=0){ priority_queue<Dice> que; for(int y=0;y<h;y++) for(int x=0;x<w;x++){ cin>>p[y][x]; } memset(memo,-1,sizeof(memo)); int gx,gy,sx,sy; cin>>sy>>sx>>gy>>gx; que.push(Dice(1,6,5,2,3,4,sx,sy,0)); while(!que.empty()){ Dice now=que.top(); que.pop(); // cout<<now.x<<" "<<now.y<<" "<<now.b<<" "<<now.c<<endl; if(now.x==gx && now.y==gy) {cout<<now.c<<endl; break;} if(memo[now.y][now.x][now.e*7+now.b]>=0 && memo[now.y][now.x][now.e*7+now.b]<=now.c) continue; for(int r=0;r<4;r++){ Dice copy=now; copy.roll(r); if(in(copy.x,copy.y)){ copy.c+=copy.b*p[copy.y][copy.x]; que.push(copy); } } } } return 0; }
a.cc: In function 'int main()': a.cc:55:17: error: 'memset' was not declared in this scope 55 | memset(memo,-1,sizeof(memo)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<iostream> +++ |+#include <cstring> 3 | using namespace std;
s633836638
p00644
C++
#include <bits/stdc++.h> using namespace std; struct edge { int to, cost; }; typedef pair< int, int > Pi; const int INF = 1LL << 29; int N, M, P; int v1[100], v2[100]; int dp1[100], dp2[100]; vector< vector< edge > > g; void Dijkstra(int s, int *v, int *dp) { priority_queue< Pi, vector< Pi >, greater< Pi > > que; fill_n(v, N, INF); fill_n(dp, N, 0); que.emplace(0, s); v[s] = 0; dp[s] = 1; while(!que.empty()) { auto p = que.top(); que.pop(); if(p.first > v[p.second]) continue; for(auto &e : g[p.second]) { if(p.first + e.cost < v[e.to]) { v[e.to] = p.first + e.cost; dp[e.to] = dp[p.second]; que.emplace(v[e.to], e.to); } else if(p.first + e.cost == v[e.to]) { dp[e.to] += dp[p.second]; } } } } int main() { cout << fixed << setprecision(10); while(cin >> N >> M >> P, N) { g = vector< vector< edge > >(N, vector< int >()); while(M--) { int X, Y, Z; cin >> X >> Y >> Z; g[X].emplace_back((edge) {Y, Z}); g[Y].emplace_back((edge) {X, Z}); } Dijkstra(0, v1, dp1); Dijkstra(N - 1, v2, dp2); while(P--) { int A; cin >> A; if(v1[A] + v2[A] == v1[N - 1]) cout << (double) dp1[A] * dp2[A] / dp1[N - 1] << endl; else cout << 0 << endl; } cout << endl; } }
a.cc: In function 'int main()': a.cc:50:52: error: no matching function for call to 'std::vector<std::vector<edge> >::vector(int&, std::vector<int>)' 50 | g = vector< vector< edge > >(N, vector< int >()); | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >]' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed: a.cc:50:52: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>') 50 | g = vector< vector< edge > >(N, vector< int >()); | ^ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; allocator_type = std::allocator<std::vector<edge> >]' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<edge> >' 678 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<edge> >]' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::vector<edge> >&&' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; allocator_type = std::allocator<std::vector<edge> >; std::false_type = std::false_type]' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; allocator_type = std::allocator<std::vector<edge> >; std::true_type = std::true_type]' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<edge> >]' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<edge> >&' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >]' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >]' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; size_type = long unsigned int; value_type = std::vector<edge>; allocator_type = std::allocator<std::vector<edge> >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<edge> >::value_type&' {aka 'const std::vector<edge>&'} 569 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<edge> >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<edge> >::allocator_type&' {aka 'const std::allocator<std::vector<edge> >&'} 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; allocator_type = std::allocator<std::vector<edge> >]' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >]' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
s544361579
p00644
C++
#include <bits/stdc++.h> using namespace std; struct edge { int to, cost; }; typedef pair< int, int > Pi; const int INF = 1LL << 30; int N, M, P; int v1[100], v2[100]; double dp1[100], dp2[100]; vector< vector< edge > > g; void Dijkstra(int s, int *v, int *dp) { priority_queue< Pi, vector< Pi >, greater< Pi > > que; fill_n(v, N, INF); fill_n(dp, N, 0); que.emplace(0, s); v[s] = 0; dp[s] = 1; while(!que.empty()) { auto p = que.top(); que.pop(); if(p.first > v[p.second]) continue; for(auto &e : g[p.second]) { if(p.first + e.cost < v[e.to]) { v[e.to] = p.first + e.cost; dp[e.to] = dp[p.second]; que.emplace(v[e.to], e.to); } else if(p.first + e.cost == v[e.to]) { dp[e.to] += dp[p.second]; } } } } int main() { cout << fixed << setprecision(10); while(cin >> N >> M >> P, N) { g.resize(N); while(M--) { int X, Y, Z; cin >> X >> Y >> Z; g[X].emplace_back((edge) {Y, Z}); g[Y].emplace_back((edge) {X, Z}); } Dijkstra(0, v1, dp1); Dijkstra(N - 1, v2, dp2); while(P--) { int A; cin >> A; if(v1[A] + v2[A] == v1[N - 1]) cout << (double) dp1[A] * dp2[A] / dp1[N - 1] << endl; else cout << 0 << endl; } cout << endl; g.clear(); } }
a.cc: In function 'int main()': a.cc:57:21: error: cannot convert 'double*' to 'int*' 57 | Dijkstra(0, v1, dp1); | ^~~ | | | double* a.cc:18:35: note: initializing argument 3 of 'void Dijkstra(int, int*, int*)' 18 | void Dijkstra(int s, int *v, int *dp) | ~~~~~^~ a.cc:58:25: error: cannot convert 'double*' to 'int*' 58 | Dijkstra(N - 1, v2, dp2); | ^~~ | | | double* a.cc:18:35: note: initializing argument 3 of 'void Dijkstra(int, int*, int*)' 18 | void Dijkstra(int s, int *v, int *dp) | ~~~~~^~
s792501736
p00644
C++
// AOJ1058 Winter Bells #include <iostream> #include <vector> #include <string.h> using namespace std; typedef vector< vector<int> > graph; void visit(graph &g, vector<int> &order, vector<bool> &mark, int pos){ for(int i=0;i<g[pos].size();i++){ int next = g[pos][i]; if(mark[next]) continue; visit(g, order, mark, next); } mark[pos] = true; order.push_back(pos); } vector<int> topologicalSort(graph &g){ vector<int> res; vector<bool> mark(g.size(), false); for(int i=0;i<g.size();i++){ if(mark[i]) continue; visit(g, res, mark, i); } reverse(res.begin(), res.end()); return res; } int main(){ int n, m, r; int cost[100][100]; while(cin >> n >> m >> r, n){ vector< vector< pair<int, int> > > g(n); for(int i=0;i<n;i++) for(int j=0;j<n;j++) cost[i][j] = i==j ? 0 : 100000000; for(int i=0;i<m;i++){ int p, q, c; cin >> p >> q >> c; cost[p][q] = cost[q][p] = min(cost[p][q], c); g[p].push_back(make_pair(q,c)); g[q].push_back(make_pair(p,c)); } for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]); graph h(n); for(int i=0;i<n;i++){ if(cost[0][i]+cost[i][n-1]!=cost[0][n-1]) continue; for(int j=0;j<g[i].size();j++){ if(cost[i][n-1]==cost[g[i][j].first][n-1]+g[i][j].second){ h[i].push_back(g[i][j].first); } } } vector<int> ord = topologicalSort(h); vector<double> prob(n, 0.0); prob[0] = 1.0; for(int i=0;i<ord.size();i++){ for(int j=0;j<h[ord[i]].size();j++) prob[h[ord[i]][j]] += (double)prob[ord[i]]/h[ord[i]].size(); } for(int i=0;i<r;i++){ int t; cin >> t; printf("%.8lf\n", prob[t]); } puts(""); } }
a.cc: In function 'std::vector<int> topologicalSort(graph&)': a.cc:28:9: error: 'reverse' was not declared in this scope 28 | reverse(res.begin(), res.end()); | ^~~~~~~
s132858403
p00645
Java
import java.io.*; import java.util.*; public class Myon { public static void main(String args[]) throws Exception { new Myon();} static int MAX = 9999; Myon(){ Scanner cin = new Scanner(System.in); int i,j,k,num; while(true){ int n; n = cin.nextInt(); if(n==0) break; int input[] = new int[n]; for(i=0;i<n;i++){ input[i] = 0; for(j=0;j<n;j++){ if(cin.nextInt()!=0) input[i] += 1<<j; } } num = n*(n+1)/2; int range[] = new int[num]; int count = 0; for(i=0;i<=n;i++){ for(j=i+1;j<=n;j++){ range[count++] = (1<<j)- (1<<i); } } int memo[] = new int[1<<num]; int plus[] = new int[1<<num]; for(i=0;i<(1<<num);i++){ memo[i] = 0; plus[i] = 0; for(j=0;j<num;j++){ if(((1<<j)&i)!=0){ memo[i] ^= range[j]; plus[i]++; } } } //System.out.println("start!"); int dp[] = new int[1<<num]; for(j=0;j<(1<<num);j++) dp[j] = MAX; dp[0] = 0; for(i=0;i<n;i++){ int newdp[] = new int[1<<num]; for(j=0;j<(1<<num);j++) newdp[j] = MAX; for(j=0;j<(1<<num);j++){ if(dp[j]==MAX) continue; int need = memo[j] ^ input[i]; //System.out.println("test"); for(k=0;k<(1<<num);k++){ if(need != memo[k]) continue; //System.out.println("test"); newdp[j ^ k] = Math.min(newdp[j ^ k], dp[j]+plus[k]); } } dp = newdp.clone(); } int res = MAX; for(j=0;j<(1<<num);j++) res = Math.min(res, dp[j]+Integer.bitCount(j)); //System.out.println(res); for(j=0;j<res/2;j++) System.out.print("myon"); System.out.println(); } } }
Main.java:3: error: class Myon is public, should be declared in a file named Myon.java public class Myon ^ 1 error
s267991866
p00645
C++
#include <iostream> #include <queue> using namespace std; #define loop(i,a,b) for(int i=(a);i<int(b);i++) #define rep(i,b) loop(i,0,b) int n; struct State { int step, g; State(int step, int g) :step(step), g(g){} void flip(int x, int y, int w, int h){ int t = (((1 << w) - 1) << x); rep(i, h){ g ^= t << (n*(i + y)); } } void print(){ rep(i, n){ rep(j, n){ cout << ((g >> (i*n + j)) & 1); } cout << endl; } } }; int main(){ while (cin >> n && n){ State init(0, 0); rep(i, n)rep(j, n){ int x; cin >> x; if (x)init.flip(j, i, 1, 1); } queue<State> q; q.push(init); static bool vis[1 << 25]; memset(vis, 0, sizeof(vis)); vis[init.g] = true; int res = -1; while (q.size()){ State s = q.front(); q.pop(); if (s.g == 0) { res = s.step; break; } vis[s.g] = true; rep(i, n){ rep(j, n){ if ((s.g >> (i*n + j)) & 1){ rep(h, n - i){ rep(w, n - j){ s.flip(j, i, w + 1, h + 1); s.step++; if (!vis[s.g]) q.push(s); s.flip(j, i, w + 1, h + 1); s.step--; } } } } } } rep(i, res)cout << "myon"; cout << endl; } }
a.cc: In function 'int main()': a.cc:43:9: error: 'memset' was not declared in this scope 43 | memset(vis, 0, sizeof(vis)); | ^~~~~~ 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 |
s225065622
p00645
C++
#include <bits/stdc++.h> using namespace std; typedef vector<vector<bool>> vii; // #include<unordered_map> class HashVI { // ???n???b???V?????????????????I???u???W???F???N???g public: size_t operator()(const vector<vector<bool>> &x) const { const int C = 997; // ???f?????? size_t t = 0; for (int i = 0; i != x.size(); ++i) { for (int j = 0; j < x[i].size(); ++j) { t = t * C + x[i][j]; } } return t; } }; unordered_map<vector<vector<bool>>,int,HashVI>memo; int N; int solve(const vii &field){ if(memo.find(field)==memo.end()){ for(int y=0;y<field.size();++y){ for(int x=0;x<field[y].size();++x){ if(field[y][x]){ int ans=100; for(int xsz=1;xsz<=N-x;++xsz){ for(int ysz=1;ysz<=N-y;++ysz){ vii nextfield(field); for(int dy=0;dy<ysz;++dy){ for(int dx=0;dx<xsz;++dx){ int nexty=y+dy; int nextx=x+dx; nextfield[nexty][nextx]=!nextfield[nexty][nextx]; } } ans=min(ans,1+solve(nextfield)); } } return memo[field]=ans; } } } return memo[field]=0; } return memo[field]; } int main(){ while(true){ cin>>N; if(!N)break; memo.clear(); vii field(N,vector<int>(N)); for(int i=0;i<N;++i){ for(int j=0;j<N;++j){ cin>>field[i][j]; } } int ans=solve(field); for(int i=0;i<ans;++i){ cout<<"myon"; } cout<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:54:35: error: no matching function for call to 'std::vector<std::vector<bool> >::vector(int&, std::vector<int>)' 54 | vii field(N,vector<int>(N)); | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed: a.cc:54:35: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>') 54 | vii field(N,vector<int>(N)); | ^ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; allocator_type = std::allocator<std::vector<bool> >]' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<bool> >' 678 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<bool> >]' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::vector<bool> >&&' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; allocator_type = std::allocator<std::vector<bool> >; std::false_type = std::false_type]' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; allocator_type = std::allocator<std::vector<bool> >; std::true_type = std::true_type]' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<bool> >]' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<bool> >&' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; size_type = long unsigned int; value_type = std::vector<bool>; allocator_type = std::allocator<std::vector<bool> >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<bool> >::value_type&' {aka 'const std::vector<bool>&'} 569 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<bool> >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<bool> >::allocator_type&' {aka 'const std::allocator<std::vector<bool> >&'} 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >; allocator_type = std::allocator<std::vector<bool> >]' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided a.cc:57:20: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<bool>::reference') 57 | cin>>field[i][j]; | ~~~^~~~~~~~~~~~~ | | | | | std::vector<bool>::reference | std::istream {aka std::basic_istream<char>} In file included 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: /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:57:32: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool' 57 | cin>>field[i][j]; | ~~~~~~~~~~^ In file included from /usr/include/c++/14/vector:67: /usr/include/c++/14/bits/stl_bvector.h:99:5: note: after user-defined conversion: 'std::_Bit_reference::operator bool() const' 99 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /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:57:32: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'bool' 57 | cin>>field[i][j]; | ~~~~~~~~~~^ /usr/include/c++/14/bits/stl_bvector.h:99:5: note: after user-defined conversion: 'std::_Bit_reference::operator bool() const' 99 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /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:57:32: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'bool' 57 | cin>>field[i][j]; | ~~~~~~~~~~^ /usr/include/c++/14/bits/stl_bvector.h:99:5: note: after user-defined conversion: 'std::_Bit_reference::operator bool() const' 99 | operator bool()
s851593877
p00645
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; int dp[1<<5][1<<5][1<<5][1<<5][1<<5]; bool passed[1<<5][1<<5][1<<5][1<<5][1<<5]; int n; int field[5][5]; const int INF=1000000; int dfs(int s1,int s2,int s3,int s4,int s5){ if(!s1&&!s2&&!s3&&!s4&&!s5){ return 0; } if(dp[s1][s2][s3][s4][s5]!=0) return dp[s1][s2][s3][s4][s5]; int minRet=INF; // ‹éŒ`¶ã‚̍À•W for(int miny = 0; miny < n; miny++){ for(int minx= 0; minx < n; minx++){ // ‹éŒ`‰E‰º‚̍À•W for(int maxy = miny; maxy < n; maxy++){ for(int maxx = minx; maxx < n; maxx++){ int ns[5]; ns[0] = s1; ns[1] = s2; ns[2] = s3; ns[3] = s4; ns[4] = s5; // Œˆ’肵‚½”͈͂̃rƒbƒg‚𔽓]‚·‚é for(int i = miny; i <= maxy; i++){ for(int j = minx; j <= maxx; j++){ if(((ns[i] >> j) & 1)){ ns[i] &= ~(1 << j); } else{ ns[i] |= (1<<j); } } } // Ä‹A if(passed[ns[0]][ns[1]][ns[2]][ns[3]][ns[4]]) continue; passed[ns[0]][ns[1]][ns[2]][ns[3]][ns[4]]=true; if(ns[0]==0){ // cout<<endl; } minRet=min(minRet,1+dfs(ns[0],ns[1],ns[2],ns[3],ns[4])); passed[ns[0]][ns[1]][ns[2]][ns[3]][ns[4]]=false; } } } } dp[s1][s2][s3][s4][s5]=minRet; return minRet; //if(n==1){ // return 1; //} //else if(n==2){ // return 1; //} //else if(n==3){ // if(s1==0&&s2==0&&s3==0) // return 0; // if(dp[s1][s2][s3][0][0]!=INF) // return dp[s1][s2][s3][0][0]; // // “ñ’Ê‚è‚Ì•û–@‚ª‚ ‚é // int ns1 = s1; // int ns2 = s2; // int ns3 = s3; // // for(int i = 0; i < 3; i++){ // if(((s1 >> i) & 1)){ // ns1 &= ~(1 << i); // } // else{ // ns1 |= (1<<i); // } // if(((s2 >> i) & 1)){ // ns2 &= ~(1 << i); // } // else{ // ns2 |= (1<<i); // } // if(((s3 >> i) & 1)){ // ns3 &= ~(1 << i); // } // else{ // ns3 |= (1<<i); // } // } // minRet=min(minRet,1+dfs(ns1,ns2,ns3,0,0)); // ns1=s1;ns2=s2;ns3=s3; // for(int i = 0; i < 3; i++){ // if(i == 1){ // if(((s2 >> i) & 1)){ // ns2 &= ~(1 << i); // } // else{ // ns2 |= (1<<i); // } // } // } // minRet=min(minRet,1+dfs(ns1,ns2,ns3,0,0)); // dp[s1][s2][s3][0][0]=minRet; // return minRet; //} //else if(n==4){ // if(s1==0&&s2==0&&s3==0&&s4==0) // return 0; // if(dp[s1][s2][s3][s4][0]!=INF) // return dp[s1][s2][s3][s4][0]; // // “ñ’Ê‚è‚Ì•û–@‚ª‚ ‚é // int ns1 = s1; // int ns2 = s2; // int ns3 = s3; // int ns4 = s4; // // for(int i = 0; i < 4; i++){ // if(((s1 >> i) & 1)){ // ns1 &= ~(1 << i); // } // else{ // ns1 |= (1<<i); // } // if(((s2 >> i) & 1)){ // ns2 &= ~(1 << i); // } // else{ // ns2 |= (1<<i); // } // if(((s3 >> i) & 1)){ // ns3 &= ~(1 << i); // } // else{ // ns3 |= (1<<i); // } // if(((s4 >> i) & 1)){ // ns4 &= ~(1 << i); // } // else{ // ns4 |= (1<<i); // } // } // minRet=min(minRet,1+dfs(ns1,ns2,ns3,ns4,0)); // ns1=s1;ns2=s2;ns3=s3;ns4=s4; // for(int i = 0; i < 4; i++){ // if(i == 1 || i == 2){ // if(((s2 >> i) & 1)){ // ns2 &= ~(1 << i); // } // else{ // ns2 |= (1<<i); // } // if(((s3 >> i) & 1)){ // ns3 &= ~(1 << i); // } // else{ // ns3 |= (1<<i); // } // } // } // minRet=min(minRet,1+dfs(ns1,ns2,ns3,ns4,0)); // dp[s1][s2][s3][ns4][0]=minRet; // return minRet; //} //else if(n==5){ // if(s1==0&&s2==0&&s3==0&&s4==0&&s5==0) // return 0; // if(dp[s1][s2][s3][s4][s5]!=INF) // return dp[s1][s2][s3][s4][s5]; // // ŽO’Ê‚è‚Ì•û–@‚ª‚ ‚é // int ns1 = s1; // int ns2 = s2; // int ns3 = s3; // int ns4 = s4; // int ns5 = s5; // // for(int i = 0; i < 5; i++){ // if(((s1 >> i) & 1)){ // ns1 &= ~(1 << i); // } // else{ // ns1 |= (1<<i); // } // if(((s2 >> i) & 1)){ // ns2 &= ~(1 << i); // } // else{ // ns2 |= (1<<i); // } // if(((s3 >> i) & 1)){ // ns3 &= ~(1 << i); // } // else{ // ns3 |= (1<<i); // } // if(((s4 >> i) & 1)){ // ns4 &= ~(1 << i); // } // else{ // ns4 |= (1<<i); // } // if(((s5 >> i) & 1)){ // ns5 &= ~(1 << i); // } // else{ // ns5 |= (1<<i); // } // } // minRet=min(minRet,1+dfs(ns1,ns2,ns3,ns4,ns5)); // ns1=s1;ns2=s2;ns3=s3;ns4=s4;ns5=s5; // for(int i = 0; i < 5; i++){ // if(i != 0 && i != 4){ // if(((s2 >> i) & 1)){ // ns2 &= ~(1 << i); // } // else{ // ns2 |= (1<<i); // } // if(((s4 >> i) & 1)){ // ns4 &= ~(1 << i); // } // else{ // ns4 |= (1<<i); // } // } // if(i == 1 || i == 3 || i == 2){ // if(((s3 >> i) & 1)){ // ns3 &= ~(1 << i); // } // else{ // ns3 |= (1<<i); // } // } // } // minRet=min(minRet,1+dfs(ns1,ns2,ns3,ns4,ns5)); // ns1=s1;ns2=s2;ns3=s3;ns4=s4;ns5=s5; // for(int i = 0; i < 5; i++){ // if(i == 2){ // if(((s3 >> i) & 1)){ // ns3 &= ~(1 << i); // } // else{ // ns3 |= (1<<i); // } // } // } // minRet=min(minRet,1+dfs(ns1,ns2,ns3,ns4,ns5)); // dp[s1][s2][s3][ns4][ns5]=minRet; // return minRet; //} } int main(){ while(cin>>n&&n!=0){ int s[5]; s[0]=s[1]=s[2]=s[3]=s[4]=0; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin>>field[i][j]; if(field[i][j]){ s[i] |= (1 << j); } } } memset(dp,0,sizeof(dp)); memset(passed,0,sizeof(passed)); passed[s[0]][s[1]][s[2]][s[3]][s[4]]=true; cout<<dfs(s[0],s[1],s[2],s[3],s[4])<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:276:17: error: 'memset' was not declared in this scope 276 | memset(dp,0,sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <vector> +++ |+#include <cstring> 4 |
s767594817
p00645
C++
unsigned char cost[1<<20]; int mask[5][5][6][6]; void gen(){ memset(cost,-1,sizeof(cost)); cost[0]=0; rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ int m=(1<<w)-1; rep(k,h)mask[i][j][h][w]^=m<<(i+k)*5+j; } queue<int> Q; Q.push(0); int cnt=0; while(!Q.empty()){ int c=Q.front(),cc=cost[c]; Q.pop(); rep(i,4)rep(j,5)for(int h=1;h<=4-i;h++)for(int w=1;w<=5-j;w++){ int nc=c^mask[i][j][h][w]; if(cost[nc]>cc+1)cost[nc]=cc+1,Q.push(nc); } } } int lim; int getcost(int c){ int ret=cost[c&(1<<20)-1],bit=0; for(c>>=20;c;c&=c-1)bit++; return ret+min(bit,6-bit); } void rec(int c,int x,int cnt){ if(c>>20==0)lim=min(lim,cost[c]+cnt); if(x>=5)return; rep(i,5)for(int j=x;j<5;j++){ int nc=c^mask[i][x][5-i][j-x+1]; if(!(nc&1<<20+x))rec(nc,x+1,cnt+1); } if(!(c&1<<20+x))rec(c,x+1,cnt); } int solve(int c){ lim=getcost(c); rec(c,0,0); return lim; } int main(){ gen(); int n,ans; while(cin>>n,n){ int c=0,t; rep(i,n)rep(j,n){ cin>>t; if(t)c^=1<<i*5+j; } ans=n<5?cost[c]:solve(c); rep(i,ans)cout<<"myon"; cout<<endl; } return 0; }
a.cc: In function 'void gen()': a.cc:4:9: error: 'memset' was not declared in this scope 4 | memset(cost,-1,sizeof(cost)); | ^~~~~~ a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' +++ |+#include <cstring> 1 | unsigned char cost[1<<20]; a.cc:6:13: error: 'i' was not declared in this scope 6 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^ a.cc:6:9: error: 'rep' was not declared in this scope 6 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^~~ a.cc:6:37: error: 'h' was not declared in this scope 6 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^ a.cc:6:60: error: 'w' was not declared in this scope 6 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^ a.cc:6:65: error: 'j' was not declared in this scope 6 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^ a.cc:10:9: error: 'queue' was not declared in this scope 10 | queue<int> Q; Q.push(0); int cnt=0; | ^~~~~ a.cc:10:15: error: expected primary-expression before 'int' 10 | queue<int> Q; Q.push(0); int cnt=0; | ^~~ a.cc:10:23: error: 'Q' was not declared in this scope 10 | queue<int> Q; Q.push(0); int cnt=0; | ^ a.cc: In function 'int getcost(int)': a.cc:23:20: error: 'min' was not declared in this scope 23 | return ret+min(bit,6-bit); | ^~~ a.cc: In function 'void rec(int, int, int)': a.cc:26:25: error: 'min' was not declared in this scope 26 | if(c>>20==0)lim=min(lim,cost[c]+cnt); | ^~~ a.cc:29:13: error: 'i' was not declared in this scope 29 | rep(i,5)for(int j=x;j<5;j++){ | ^ a.cc:29:9: error: 'rep' was not declared in this scope; did you mean 'rec'? 29 | rep(i,5)for(int j=x;j<5;j++){ | ^~~ | rec a.cc:29:29: error: 'j' was not declared in this scope 29 | rep(i,5)for(int j=x;j<5;j++){ | ^ a.cc: In function 'int main()': a.cc:44:15: error: 'cin' was not declared in this scope 44 | while(cin>>n,n){ | ^~~ a.cc:46:21: error: 'i' was not declared in this scope 46 | rep(i,n)rep(j,n){ | ^ a.cc:46:17: error: 'rep' was not declared in this scope; did you mean 'rec'? 46 | rep(i,n)rep(j,n){ | ^~~ | rec a.cc:51:41: error: 'cout' was not declared in this scope; did you mean 'cost'? 51 | rep(i,ans)cout<<"myon"; cout<<endl; | ^~~~ | cost a.cc:51:47: error: 'endl' was not declared in this scope 51 | rep(i,ans)cout<<"myon"; cout<<endl; | ^~~~
s664103136
p00645
C++
#include <cstring> #include <cstdio> #include <iostream> using namespace std; unsigned char cost[1<<20]; int mask[5][5][6][6]; void gen(){ memset(cost,-1,sizeof(cost)); cost[0]=0; rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ int m=(1<<w)-1; rep(k,h)mask[i][j][h][w]^=m<<(i+k)*5+j; } queue<int> Q; Q.push(0); int cnt=0; while(!Q.empty()){ int c=Q.front(),cc=cost[c]; Q.pop(); rep(i,4)rep(j,5)for(int h=1;h<=4-i;h++)for(int w=1;w<=5-j;w++){ int nc=c^mask[i][j][h][w]; if(cost[nc]>cc+1)cost[nc]=cc+1,Q.push(nc); } } } int lim; int getcost(int c){ int ret=cost[c&(1<<20)-1],bit=0; for(c>>=20;c;c&=c-1)bit++; return ret+min(bit,6-bit); } void rec(int c,int x,int cnt){ if(c>>20==0)lim=min(lim,cost[c]+cnt); if(x>=5)return; rep(i,5)for(int j=x;j<5;j++){ int nc=c^mask[i][x][5-i][j-x+1]; if(!(nc&1<<20+x))rec(nc,x+1,cnt+1); } if(!(c&1<<20+x))rec(c,x+1,cnt); } int solve(int c){ lim=getcost(c); rec(c,0,0); return lim; } int main(){ gen(); int n,ans; while(cin>>n,n){ int c=0,t; rep(i,n)rep(j,n){ cin>>t; if(t)c^=1<<i*5+j; } ans=n<5?cost[c]:solve(c); rep(i,ans)cout<<"myon"; cout<<endl; } return 0; }
a.cc: In function 'void gen()': a.cc:12:13: error: 'i' was not declared in this scope 12 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^ a.cc:12:9: error: 'rep' was not declared in this scope 12 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^~~ a.cc:12:37: error: 'h' was not declared in this scope 12 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^ a.cc:12:60: error: 'w' was not declared in this scope 12 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^ a.cc:12:65: error: 'j' was not declared in this scope 12 | rep(i,5)rep(j,5)for(int h=1;h<=5-i;h++)for(int w=1;w<=5-j;w++){ | ^ a.cc:16:9: error: 'queue' was not declared in this scope 16 | queue<int> Q; Q.push(0); int cnt=0; | ^~~~~ a.cc:4:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>' 3 | #include <iostream> +++ |+#include <queue> 4 | a.cc:16:15: error: expected primary-expression before 'int' 16 | queue<int> Q; Q.push(0); int cnt=0; | ^~~ a.cc:16:23: error: 'Q' was not declared in this scope 16 | queue<int> Q; Q.push(0); int cnt=0; | ^ a.cc: In function 'void rec(int, int, int)': a.cc:35:13: error: 'i' was not declared in this scope 35 | rep(i,5)for(int j=x;j<5;j++){ | ^ a.cc:35:9: error: 'rep' was not declared in this scope; did you mean 'rec'? 35 | rep(i,5)for(int j=x;j<5;j++){ | ^~~ | rec a.cc:35:29: error: 'j' was not declared in this scope 35 | rep(i,5)for(int j=x;j<5;j++){ | ^ a.cc: In function 'int main()': a.cc:52:21: error: 'i' was not declared in this scope 52 | rep(i,n)rep(j,n){ | ^ a.cc:52:17: error: 'rep' was not declared in this scope; did you mean 'rec'? 52 | rep(i,n)rep(j,n){ | ^~~ | rec
s199163835
p00645
C++
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<iostream> #include<vector> #include<algorithm> #include<map> #define calc __builtin_popcount using namespace std; int n,G[5][5],ans; map<int,int>vis; vector<int>move[30]; int H(int sta,int k){ return (calc(sta)+k-1)/k; } int Q[50]; void show(int sta){ for(int r=0;r<n;r++){ for(int c=0;c<n;c++) putchar((sta&(1<<(r*n+c)))?'1':'0'); puts(""); } puts("----"); } void ws(int dep,int sta,int k,int last){ if(dep==3||k==0)return; if(vis.find(sta)==vis.end()){ vis[sta]=dep; }else if(vis[sta]>dep){ vis[sta]=dep; } for(int i=last;i<move[k].size();i++){ ws(dep+1,sta^move[k][i],k,i); } ws(dep,sta,k-1,0); } bool succ; void DFS(int dep,int k,int sta,int last){ if(k==0)return; if(dep+H(sta,k)>=ans)return; if(sta==0){ ans=dep; /*printf("ans:%d\n",ans); for(int i=0;i<dep;i++){ show(Q[i]); }*/ return; } for(int i=last;i<move[k].size();i++){ DFS(dep+1,k,sta^move[k][i],i); } DFS(dep,k-1,sta,0); } int lim; bool DFS5(int dep,int k,int sta,int last){ if(dep+H(sta,k)>lim)return false; if(vis.find(sta)!=vis.end()){ ans=dep+vis[sta]; return true; } for(int i=last;i<move[k].size();i++){ if(DFS5(dep+1,k,sta^move[k][i],i))return true; } if(DFS5(dep,k-1,sta,0))return true; return false; } void init(){ for(int r=1;r<=n;r++) for(int c=1;c<=n;c++){ for(int i=0;i+r-1<n;i++) for(int j=0;j+c-1<n;j++){ int sta=0; for(int y=i;y<i+r;y++) for(int x=j;x<j+c;x++) sta^=(1<<(y*n+x)); move[r*c].push_back(sta); } } } map<int,int> aa; int chan(){ int sta=0; for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(G[i][j])sta^=(1<<(i*n+j)); return sta; } void init2(){ aa.clear(); memset(G,0,sizeof(G)); G[0][0]=1;G[0][2]=1;G[0][4]=1; G[2][0]=1;G[2][2]=1;G[2][4]=1; G[4][0]=1;G[4][2]=1;G[4][4]=1; aa[chan()]=9; int dx[9]={0,0,0,2,2,2,4,4,4}; int dy[9]={0,2,4,0,2,4,0,2,4}; for (int i=0;i<9;++i){ G[dx[i]][dy[i]]=0; aa[chan()]=8; G[dx[i]][dy[i]]=1; } for (int i=0;i<8;++i) for (int j=i+1;j<9;++j){ G[dx[i]][dy[i]]=0; G[dx[j]][dy[j]]=0; aa[chan()]=7; G[dx[i]][dy[i]]=1; G[dx[j]][dy[j]]=1; } } int main(){ n=5; init(); ws(0,0,25,0); int maxans=0; //printf("%d\n",vis.size()); init2(); while(cin>>n){ if(n==0)break; for(int i=0;i<=n*n;i++)move[i].clear(); init(); int sta=0; for(int i=0;i<n;i++) for(int j=0;j<n;j++){ scanf("%d",&G[i][j]); if(G[i][j])sta^=(1<<(i*n+j)); } // cout << sta << endl; if (aa.find(sta)!=aa.end()){ printf("%d\n",aa[sta]); continue; } succ=false; ans=10; if(n<5){ DFS(0,n*n,sta,0); }else{ for(lim=1;;lim++){ if(DFS5(0,n*n,sta,0)) break; } } /* if(ans>maxans){ cout<<ans<<endl; for (int i=0;i<5;++i){ for (int j=0;j<5;++j) printf("%d ",G[i][j]); puts(""); } maxans=ans; }*/ } }
a.cc: In function 'void ws(int, int, int, int)': a.cc:32:26: error: reference to 'move' is ambiguous 32 | for(int i=last;i<move[k].size();i++){ | ^~~~ In file included from /usr/include/c++/14/algorithm:86, from a.cc:6: /usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)' 353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first); | ^~~~ In file included from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from /usr/include/c++/14/math.h:36, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:12:12: note: 'std::vector<int> move [30]' 12 | vector<int>move[30]; | ^~~~ a.cc:33:30: error: reference to 'move' is ambiguous 33 | ws(dep+1,sta^move[k][i],k,i); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)' 353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:12:12: note: 'std::vector<int> move [30]' 12 | vector<int>move[30]; | ^~~~ a.cc: In function 'void DFS(int, int, int, int)': a.cc:49:26: error: reference to 'move' is ambiguous 49 | for(int i=last;i<move[k].size();i++){ | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)' 353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:12:12: note: 'std::vector<int> move [30]' 12 | vector<int>move[30]; | ^~~~ a.cc:50:33: error: reference to 'move' is ambiguous 50 | DFS(dep+1,k,sta^move[k][i],i); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)' 353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:12:12: note: 'std::vector<int> move [30]' 12 | vector<int>move[30]; | ^~~~ a.cc: In function 'bool DFS5(int, int, int, int)': a.cc:61:26: error: reference to 'move' is ambiguous 61 | for(int i=last;i<move[k].size();i++){ | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)' 353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:12:12: note: 'std::vector<int> move [30]' 12 | vector<int>move[30]; | ^~~~ a.cc:62:37: error: reference to 'move' is ambiguous 62 | if(DFS5(dep+1,k,sta^move[k][i],i))return true; | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)' 353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:12:12: note: 'std::vector<int> move [30]' 12 | vector<int>move[30]; | ^~~~ a.cc: In function 'void init()': a.cc:76:25: error: reference to 'move' is ambiguous 76 | move[r*c].push_back(sta); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)' 353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:12:12: note: 'std::vector<int> move [30]' 12 | vector<int>move[30]; | ^~~~ a.cc: In function 'void init2()': a.cc:92:9: error: 'memset' was not declared in this scope 92 | memset(G,0,sizeof(G)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include<map> +++ |+#include <cstring> 8 | #define calc __builtin_popcount a.cc: In function 'int main()': a.cc:128:40: error: reference to 'move' is ambiguous 128 | for(int i=0;i<=n*n;i++)move[i].clear(); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)' 353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:12:12: note: 'std::vector<int> move [30]' 12 | vector<int>move[30]; | ^~~~
s648938701
p00645
C++
#include <stdio.h> #include <vector> using namespace std; #define SIZE (5) #define SET(t, x, y) (((t) |= (1 << ((y) * SIZE + (x))))) #define CHECK(t, x, y) (((t) & ((1 << ((y) * SIZE + (x))))) != 0) int ans; unsigned int hash[1 << 25]; int numofbits5(unsigned int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); } int dfs(unsigned int field, vector<unsigned int>& table, int depth) { if (field == 0){ if (ans > depth){ ans = depth; } return (0); } if (ans <= depth || hash[field] <= depth){ return (0); } hash[field] = depth; for (int i = table.size() - 1; i >= 0; i--){ if (numofbits5(field) > numofbits5(field ^ table[i])){ dfs(field ^ table[i], table, depth + 1); } } return (0); } int main(void) { unsigned int field; int n; vector<unsigned int> table; while (1){ scanf("%d", &n); if (n == 0){ break; } table.clear(); memset(hash, -1, sizeof(hash)); for (int y = 0; y < n; y++){ for (int x = 0; x < n; x++){ for (int i = 1; i <= n - y; i++){ for (int j = 1; j <= n - x; j++){ table.push_back(0); for (int dy = y; dy < y + i; dy++){ for (int dx = x; dx < x + j; dx++){ SET(table.back(), dx, dy); } } } } } } field = 0; ans = 0; for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ int t; scanf("%d", &t); if (t == 1){ SET(field, j, i); ans++; } } } ans = n * n / 2 + 1; dfs(field, table, 0); for (int i = 0; i < ans; i++){ printf("myon"); } puts(""); } return (0); }
a.cc: In function 'int dfs(unsigned int, std::vector<unsigned int>&, int)': a.cc:29:29: error: reference to 'hash' is ambiguous 29 | if (ans <= depth || hash[field] <= depth){ | ^~~~ In file included from /usr/include/c++/14/bits/stl_bvector.h:65, from /usr/include/c++/14/vector:67, from a.cc:2: /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:14: note: 'unsigned int hash [33554432]' 11 | unsigned int hash[1 << 25]; | ^~~~ a.cc:33:9: error: reference to 'hash' is ambiguous 33 | hash[field] = depth; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:14: note: 'unsigned int hash [33554432]' 11 | unsigned int hash[1 << 25]; | ^~~~ a.cc: In function 'int main()': a.cc:59:24: error: reference to 'hash' is ambiguous 59 | memset(hash, -1, sizeof(hash)); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:14: note: 'unsigned int hash [33554432]' 11 | unsigned int hash[1 << 25]; | ^~~~ a.cc:59:41: error: reference to 'hash' is ambiguous 59 | memset(hash, -1, sizeof(hash)); | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:11:14: note: 'unsigned int hash [33554432]' 11 | unsigned int hash[1 << 25]; | ^~~~ a.cc:59:17: error: 'memset' was not declared in this scope 59 | memset(hash, -1, sizeof(hash)); | ^~~~~~ 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 |
s359718096
p00645
C++
#include <iostream> #include <vector> #include <map> #include <queue> #include <algorithm> using namespace std; // dp[n-1][bits] := 最小のmyonの回数 vector<char> dp[3]; // dp_4[bits] := n が 4 のときの最小のmyonの回数 map<int,char> dp_4; // dp_5[bits] := n が 5 のときの最小のmyonの回数 map<int,char> dp_5; // (x,y) の値(0 or 1) を返す int get(int n, int bits, int x, int y){ return ((bits & (1 << (x+y*n))) > 0 ); } void debug(int bits, int n){ cout << "debug : " << endl; for(int y=0 ; y < n ; y++ ){ for(int x=0 ; x < n ; x++ ){ cout << get(n,bits,x,y); } cout << endl; } cout << endl; } // [(sx,sy),(gx,gy)] の範囲に myon をかける (0 <=> 1 の反転) int myon(int bits, int n, int sx, int sy, int gx, int gy){ for(int y = sy ; y <= gy ; y++ ){ for(int x = sx ; x <= gx ; x++ ){ int k = 1 << (x+y*n); (bits & k)? bits -= k : bits += k; } } return bits; } // n = 3 のときのすべての状態からの最小の myon の回数を計算する // n*n のすべて 0 の状態からBFS void solve_2(int n){ queue< pair<int,char> > q; q.push( pair<int,char>( 0 , 0 ) ); map<int,bool> memo; while( !q.empty() ){ int bits = q.front().first; char cnt = q.front().second; q.pop(); if( memo[bits] ) continue; memo[bits] = true; dp[n-1][bits] = cnt; for(int y = 0 ; y < n ; y++ ){ for(int x = 0 ; x < n ; x++ ){ for(int my = y ; my < n ; my++ ){ for(int mx = x ; mx < n ; mx++){ int next = myon( bits , n , x , y , mx , my ); if( !memo[next] ){ q.push( pair<int,char>( next , cnt+1 ) ); } } } } } } } // n = 4 のときの一部の最小の myon の回数を計算する // n*n のすべて 0 の状態からBFS (2手以下まで) void solve_3(){ queue< pair<int,char> > q; q.push( pair<int,char>( 0 , 0 ) ); map<int,bool> memo; while( !q.empty() ){ int bits = q.front().first; char cnt = q.front().second; q.pop(); if( memo[bits] ) continue; memo[bits] = true; dp_4[bits] = cnt; if( dp_4.size() >= 10000 ) break; for(int y = 0 ; y < 4 ; y++ ){ for(int x = 0 ; x < 4 ; x++ ){ for(int my = y ; my < 4 ; my++ ){ for(int mx = x ; mx < 4 ; mx++){ int next = myon( bits , 4 , x , y , mx , my ); if( !memo[next] ){ q.push( pair<int,int>( next , cnt+1 ) ); } } } } } } } // n = 5 のときの一部の最小の myon の回数を計算する // n*n のすべて 0 の状態からBFS (2手以下まで) void solve_4(){ queue< pair<int,char> > q; q.push( pair<int,char>( 0 , 0 ) ); map<int,bool> memo; while( !q.empty() ){ int bits = q.front().first; char cnt = q.front().second; q.pop(); if( memo[bits] ) continue; memo[bits] = true; dp_5[bits] = cnt; if( dp_5.size() >= 10000 ) break; for(int y = 0 ; y < 5 ; y++ ){ for(int x = 0 ; x < 5 ; x++ ){ for(int my = y ; my < 5 ; my++ ){ for(int mx = x ; mx < 5 ; mx++){ int next = myon( bits , 5 , x , y , mx , my ); if( !memo[next] ){ q.push( pair<int,int>( next , cnt+1 ) ); } } } } } } } // n <= 4 のときのまだ求めていないときに BFS で求める /*int bfs(int bits, int n){ queue< pair<int,char> > q; q.push( pair<int,char>( bits , 0 ) ); map<int,bool> memo; while( !q.empty() ){ int bits = q.front().first; char cnt = q.front().second; q.pop(); if( q.size() + memo.size() >= 20000 ){ return 3; } if( n == 4 ){ if( dp_4.count(bits) ){ return dp_4[bits] + cnt; } }else if( n == 5 ){ if( dp_5.count(bits) ){ return dp_5[bits] + cnt; } } if( memo[bits] ) continue; memo[bits] = true; for(int y = 0 ; y < n ; y++ ){ for(int x = 0 ; x < n ; x++ ){ for(int my = y ; my < n ; my++ ){ for(int mx = x ; mx < n ; mx++){ int next = myon( bits , n , x , y , mx , my ); if( !memo[next] ){ q.push( pair<int,int>( next , cnt+1 ) ); } } } } } } }*/ int dfs(int bits, int n, int cnt){ if( n == 4 ){ if( dp_4.count(bits) ){ return dp_4[bits] + cnt; } }else if( n == 5 ){ if( dp_5.count(bits) ){ return dp_5[bits] + cnt; } } for(int y = 0 ; y < n ; y++ ){ for(int x = 0 ; x < n ; x++ ){ for(int my = y ; my < n ; my++ ){ for(int mx = x ; mx < n ; mx++){ int next = myon( bits , n , x , y , mx , my ); dfs( next , n , cnt + 1 ); } } } } } // n <= 4 のすべての解と n = 5 の一部の解を求めておく void solve(){ for(int i=0 ; i < 5 ; i++ ){ if( i == 0 ){ vector<char> v(2); v[0] = 0; v[1] = 1; dp[0] = v; }else if( i == 1 ){ vector<char> v(16); int f[16] = {0,1,1,1,1,1,2,2,1,2,1,2,1,2,2,1}; for(int j=0 ; j < 16 ; j++ ){ v[j] = f[j]; } dp[1] = v; }else if( i == 2 ){ vector<char> v(512); dp[2] = v; solve_2( 3 ); }else if( i == 3 ){ //vector<char> v(65536); //dp[3] = v; //solve_2( 4 ); solve_3(); }else if( i == 4 ){ solve_4(); } } } int main(){ // n <= 4 のすべての解と n = 5 の一部の解を求めておく solve(); //cout << "dp_5.size() : " << dp_5.size() << endl; //cout << "input" << endl; string s[5] = { "" , "myon" , "myonmyon", "myonmyonmyon", "myonmyonmyonmyon"}; int n; while( cin >> n , n ){ int bits = 0; for(int i=0 ; i < n*n ; i++ ){ int b; cin >> b; bits |= (b << i); } // debug( bits , n ); int ans = 0; if( n <= 3 ){ cout << s[ dp[n-1][bits] ] << endl; }else if( n == 4 ){ if( dp_4.count(bits) ) cout << s[ dp_4[bits] ] << endl; else cout << s[ dfs(bits,n) ] << endl; }else if( n == 5 ){ if( dp_5.count(bits) ) cout << s[ dp_5[bits] ] << endl; else cout << s[ dfs(bits,n) ] << endl; } } }
a.cc: In function 'int main()': a.cc:264:47: error: too few arguments to function 'int dfs(int, int, int)' 264 | cout << s[ dfs(bits,n) ] << endl; | ~~~^~~~~~~~ a.cc:182:5: note: declared here 182 | int dfs(int bits, int n, int cnt){ | ^~~ a.cc:269:47: error: too few arguments to function 'int dfs(int, int, int)' 269 | cout << s[ dfs(bits,n) ] << endl; | ~~~^~~~~~~~ a.cc:182:5: note: declared here 182 | int dfs(int bits, int n, int cnt){ | ^~~ a.cc: In function 'int dfs(int, int, int)': a.cc:204:1: warning: control reaches end of non-void function [-Wreturn-type] 204 | } | ^
s993311949
p00645
C++
#include <iostream> #include <string> #include <algorithm> #include <memory.h> #include <cstdio> #include <cmath> using namespace std; #define MAX 999999999 int xorMemo[5][5][5][5][5]; short n, f[1<<25]; inline short min(short a, short b){ return a < b ? a : b; } inline short solve(int bit){ if (bit == 0) return 0; if (f[bit] != -1) return f[bit]; short li, lj; for (li=0;li<n;li++){ for (lj=0;lj<n;lj++) if ((bit & (1<<(n*li+lj))) != 0) break; if (lj != n) break; } int res = MAX; for (short hi=li;hi<n;hi++) for (short hj=lj;hj<n;hj++){ int next = (bit ^ xorMemo[n-1][li][lj][hi][hj]); res = min(res, solve(next)+1); } return f[bit] = res; } short main(){ memset(xorMemo,0,sizeof(xorMemo)); memset(f,-1,sizeof(f)); for (short m=1;m<6;m++) for (short li=0;li<m;li++) for (short lj=0;lj<m;lj++) for (short hi=li;hi<m;hi++) for (short hj=lj;hj<m;hj++) for (short i=li;i<hi+1;i++) for (short j=lj;j<hj+1;j++){ xorMemo[m-1][li][lj][hi][hj] |= (1<<(i*m+j)); //cout << xorMemo[m-1][li][lj][hi][hj] << " "; } while (scanf("%d",&n) && n != 0){ int bit = 0; for (short i=0;i<n;i++) for (short j=0;j<n;j++){ short x; scanf("%d",&x); if(x == 1) bit |= (1<<(i*n+j)); } short ans = solve(bit); for (short i=1;i<=ans;i++) printf("myon"); printf("\n"); } return 0; }
cc1plus: error: '::main' must return 'int'
s127800990
p00645
C++
#include<iostream> #include<vector> #include<queue> #include<algorithm> using namespace std; #define REP(i,a,b) for(int i=a;i<b;i++) int n,g,bit,res; int dis[1<<20]; vector<int> mask[5][5]; int rec(int g, int t){ if(t == 5){ if( (g & 31) )return 1000000; return dis[g>>5]; } int res = rec(g,t+1); for(int i=0;i<mask[0][t].size();i++)res = min(res,rec(g^mask[0][t][i],t+1)+1); return res; } int main(){ REP(i,0,5)REP(j,0,5)REP(k,i,5)REP(l,j,5){ int tmp = 0; REP(y,i,k+1)REP(x,j,l+1)tmp |= 1<<(y*5+x); mask[i][j].push_back(tmp); } for(int i=0;i<(1<<20);i++)dis[i] = -1; dis[0] = 0; queue<int> q; q.push(0); while(q.size()){ int p = q.front(); q.pop(); REP(i,0,4)REP(j,0,5)REP(k,0,mask[i][j].size()){ if(mask[i][j][k]>=1<<20)continue; int nxt = p^mask[i][j][k]; if(dis[nxt]<0){ dis[nxt] = dis[p] + 1; q.push(nxt); } } } while(cin >> n,n){ g = 0; REP(i,0,5)REP(j,0,5) if(i<n && j<n){ cin >> bit; g |= bit<<(i*5+j); } if(n<5)res = dis[g]; else res = rec(g,0); for(int i=0;i<tmp;i++)cout << "myon"; cout << endl; } }
a.cc: In function 'int main()': a.cc:56:19: error: 'tmp' was not declared in this scope; did you mean 'tm'? 56 | for(int i=0;i<tmp;i++)cout << "myon"; | ^~~ | tm
s168334557
p00646
C
#include<stdio.h> #define u_llint unsigned long long int u_llint euclid(u_llint m,u_llint n); int main(void){ u_llint l,i,j,c; while(scanf("%llu",&l)&&l!=0){ c=0; for(i=1;i<=l;i++){ if(l%i!=0) continue; for(j=i;j<=l;j++){ if(l%j!=0) continue; c+=(i*j==l*euclid(i,j)) ? 1:0; } printf("%llu\n",c); } return 0; } u_llint euclid(u_llint m,u_llint n){ if(n==0) return m; return euclid(n,m%n); }
main.c: In function 'main': main.c:24:1: error: expected declaration or statement at end of input 24 | } | ^
s847857654
p00646
C
#include<iostream> #include<algorithm> #include<cmath> #include<set> #include<vector> using namespace std; typedef long long ll; vector<ll> getDiv(ll n){ vector<ll> res; for(ll i=1;i*i<=n;i++) if(n%i == 0) { res.push_back(i); if(i*i != n) res.push_back(n/i); } return res; } int main() { long long n; while(cin >> n,n) { int cnt = 0; vector<ll> s = getDiv(n); for(int i= 0;i<s.size();i++) { for(int j=i;j<s.size();j++) { ll a,b; a = s[i]; b = s[j]; if(a/__gcd(a,b)*b == n) cnt++; } } cout << cnt << endl; } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s888136895
p00646
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #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 <iomanip> #define REP(i,n) for(i=0; i < (n); i++) #define REPONE(i, n) for(i=1; i <= (n); i++) #define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++) #define ITER(c) __typeof((c).begin()) #define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++) #define SZ(c) ((int) (c).size()) #define ALL(c) c.begin(), c.end() #define SUM(c) accumulate(ALL(c), 0) #define EXIST(c,v) (find(ALL(c), (v)) != (c).end()) #define PB push_back #define MP make_pair using namespace std; static const double EPS = 1e-9; static const double PI = 3.141592653589793238462643383279; typedef long long ll; vector<int> primeTable(int n){ vector<int> ps; vector<int> table(n+1, 0); for(int i=2; i<=n; i++){ if(!table[i]){ ps.push_back(i); if(i <= sqrt(n)) table[i*i] = i; } else{ int j = i, step = table[i]; while(j+step<=n){ if(!table[j+step]) { table[j+step] = step; break; } else { int tmp = step; step = table[j+step]; table[j+tmp] = tmp; j += tmp; } } } } return ps; } int main(){ ll n; vector<int> ps=primeTable(1100000); int s = SZ(ps); while(cin>>n){ if(n==0) break; vector<int> es; for(int i=0;n!=1 && i<s;i++){ if(n%ps[i]==0){ int cnt=1; n/=ps[i]; while(n%ps[i]==0){ n /= ps[i]; cnt++; } es.PB(cnt); } } if(i==s-1 && n!=1) es.PB(1); ll ans=1; for(int i=0;i<SZ(es);i++){ ans *= (2*es[i]+1); } cout << ans/2 + 1 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:84:12: error: 'i' was not declared in this scope 84 | if(i==s-1 && n!=1) es.PB(1); | ^
s680024050
p00646
C++
#include<iostream> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<cstdio> #include<climits> #include<cmath> #include<cstring> #include<string> #include<sstream> #define f first #define s second #define mp make_pair #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++) #define ALL(c) (c).begin(), (c).end() using namespace std; typedef unsigned int uint; typedef long long ll; template<int m> class Prime{ std::vector<bool> p; std::vector<int> ps; public: Prime(){ p = std::vector<bool>(m,true); assert(m>1); p[0]=p[1]=false; for(int i=4;i<m;i+=2) p[i]=false; ps.push_back(2); for(int i=3;i<m;i+=2){ if(p[i]){ ps.push_back(i); for(int j=i+i;j<m;j+=i) p[j]=false; } } } bool isPrime(int n){ assert(m>n); return p[n]; } int operator [] (int n){ if(n<ps.size()) return ps[n]; else return 0; } int size(){ return ps.size(); } }; int main(){ Prime<1000000+100> p; ll n; while(cin>>n, n){ long long ans = 1; for(int i=0; p[i] <= n; i++){ int cc = 0; while(n % p[i] == 0){ cc++; n /= p[i]; } if(cc != 0) ans *= (cc + 1) + (cc + 1) - 1; } if(n != 1) ans *= 3; cout << (ans - 1) / 2 + 1 << endl; } return 0; }
a.cc: In constructor 'Prime<m>::Prime()': a.cc:33:5: error: there are no arguments to 'assert' that depend on a template parameter, so a declaration of 'assert' must be available [-fpermissive] 33 | assert(m>1); | ^~~~~~ a.cc:33:5: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) a.cc: In member function 'bool Prime<m>::isPrime(int)': a.cc:48:5: error: there are no arguments to 'assert' that depend on a template parameter, so a declaration of 'assert' must be available [-fpermissive] 48 | assert(m>n); | ^~~~~~ a.cc: In instantiation of 'Prime<m>::Prime() [with int m = 1000100]': a.cc:63:22: required from here 63 | Prime<1000000+100> p; | ^ a.cc:33:11: error: 'assert' was not declared in this scope 33 | assert(m>1); | ~~~~~~^~~~~ a.cc:12:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 11 | #include<sstream> +++ |+#include <cassert> 12 |
s229135039
p00646
C++
#include <iostream> #include <set> #include <algorithm> #include <map> #include <cstdlib> #include <cstdio> #include <vector> using namespace std; typedef long long ll; map<int,int> decomposition(ll L){ map<int,int> cnt; for(ll i = 2; i*i <= L; i++){ if(L%i==0){ while(1){ if(L%i==0){ cnt[i]++; //cnt[L/i]++; L/=i; } else break; } } } if(L!=1) cnt[L]++; return cnt; } map<int,int> res; pair<int,int> nums[10001]; pair<int,int> divNum[10001]; int cn; int ct=0; void dfs(map<int,int>::iterator cp){ if(cp==res.end()){ // ツ仰、ツ津環閉板閉ェツづーツ個按づ淞つスツづァツ、ツ残ツづィツづ個要ツ素ツづ個閉ェツ環づ個陛サツ法ツづ個堕債青板づーツ青板つヲツづゥ //vector<int> v; set<int> s; for(int i = 0; i < cn; i++){ if(divNum[i].second-nums[i].second>0) s.insert(i); } int mul=(int)pow(2.0,(int)s.size()); if(mul!=1) mul/=2; ct+=mul; } else{ for(int i = 0; i <= cp->second; i++){ nums[cn].first=cp->first; nums[cn].second=i; cn++; cp++; dfs(cp); cp--; cn--; } } } int main(){ ll L; while(cin>>L&&L!=0){ res.clear(); res=decomposition(L); cn=0; for(map<int,int>::iterator it = res.begin(); it != res.end(); it++){ divNum[cn].first=it->first; divNum[cn].second=it->second; cn++; } // ツ仰、ツ津環閉板閉ェツづ個個按津ィ cn=0; ct=0; dfs(res.begin()); cout<<ct<<endl; } return 0; }
a.cc: In function 'void dfs(std::map<int, int>::iterator)': a.cc:50:30: error: 'pow' was not declared in this scope 50 | int mul=(int)pow(2.0,(int)s.size()); | ^~~
s505849087
p00646
C++
#include<stdio.h> #include<math.h> #include<string.h> #define N 500001 #define M 50000 //M=(N)/ln(N) bool is[N]; int p[M]; int pnum; int getprm(int n) { int i,j,k=0; int s,e=(int)(sqrt(0.0+n)+1); memset(is,1,sizeof(is)); p[k++]=2;is[0]=is[1]=0; for(i=4;i<n;i+=2) is[i]=0; for(i=3;i<e;i+=2) if(is[i]) { p[k++]=i; for(s=i*2,j=i*i;j<n;j+=s) is[j]=0; } for(;i<n;i+=2) if(is[i]) p[k++]=i; return k; } int pf[60],pfnum=0,lim[60]; void pfact(__int64 n){ pfnum=0; for(int i=0;i<pnum&&p[i]*p[i]<=n;++i) if(n%p[i]==0){ lim[pfnum]=0; while(n%p[i]==0)n/=p[i],++lim[pfnum]; pf[pfnum++]=p[i]; } if(n!=1) lim[pfnum]=1,pf[pfnum++]=n; } int main() { __int64 sum1,sum2,n,res; int i,j; pnum=getprm(200001); while(scanf("%I64d",&n)&&n) { pfact(n); res=1; for(i=0;i<pfnum;i++) res*=(2*lim[i]+1); res++; printf("%I64d\n",res/2); } }
a.cc:28:6: error: variable or field 'pfact' declared void 28 | void pfact(__int64 n){ | ^~~~~ a.cc:28:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'? 28 | void pfact(__int64 n){ | ^~~~~~~ | __ynf64 a.cc: In function 'int main()': a.cc:40:5: error: '__int64' was not declared in this scope; did you mean '__ynf64'? 40 | __int64 sum1,sum2,n,res; | ^~~~~~~ | __ynf64 a.cc:43:26: error: 'n' was not declared in this scope 43 | while(scanf("%I64d",&n)&&n) | ^ a.cc:45:9: error: 'pfact' was not declared in this scope 45 | pfact(n); | ^~~~~ a.cc:46:9: error: 'res' was not declared in this scope 46 | res=1; | ^~~
s150189474
p00646
C++
printf("%d\n",ans); } }
a.cc:3:11: error: expected constructor, destructor, or type conversion before '(' token 3 | printf("%d\n",ans); | ^ a.cc:4:3: error: expected declaration before '}' token 4 | } | ^ a.cc:5:1: error: expected declaration before '}' token 5 | } | ^
s450766716
p00646
C++
#include<iostream> #include<iomanip> #include<algorithm> #include<cmath> #include<vector> #include<map> using namespace std; vector<long long int>p; int a[1000001]; int main() { int flag;int l; p.push_back(2);p.push_back(3);p.push_back(5); p.push_back(7);p.push_back(11);p.push_back(13); p.push_back(17);p.push_back(19);p.push_back(23); p.push_back(29);p.push_back(31);p.push_back(37); p.push_back(41);p.push_back(43);p.push_back(47); p.push_back(53);p.push_back(59);p.push_back(61); for(long long int i=7;i<1000;i+=2) { l=p.size();flag=1; for(int j=17;p[j]<=sqrt(i*1.0) && j<l;j++) if(i%p[j]==0){flag=0;break;} if(flag==1)p.push_back(i); } l=p.size(); memset(a,1,sizeof(a)); for(int i=1;i<l;i++) for(long long int j=p[i];j<1000000;j+=p[i]) a[j]=0; for(int i=63;i<1000000;i+=2) if(a[i])p.push_back(a[i]); l=p.size(); for(long long int n;cin>>n && n;) { if(n==1){cout<<1<<endl;continue;} map<long long int,int>m; for(int i=0;i<l;i++) while(n%p[i]==0) { m[p[i]]++; n/=p[i]; } int sum=1; map<long long int,int>::iterator it; for(it=m.begin();it!=m.end();it++) sum*=2*(it->second+1)-1; sum=(sum+1)/2; cout<<sum<<endl; } }
a.cc: In function 'int main()': a.cc:27:9: error: 'memset' was not declared in this scope 27 | memset(a,1,sizeof(a)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include<map> +++ |+#include <cstring> 7 | using namespace std;
s234661529
p00647
C
#define zone(h) ( (11<=(h)&&(h)<15)?0:(18<=(h)&&(h)<21)?1:(21<=(h)&&(h)<26)?2:3 ) int a[3],b[3]; char s[9];char *r(int i){strcpy(s,"no guest");if(a[i])sprintf(s,"%d",b[i]*100/a[i]);return s;} main(n,h,m,H,M){ for(;scanf("%d",&n),n){ a[0]=a[1]=a[2]=b[0]=b[1]=b[2]=0; for(;n;n--){ scanf("%d:%d %d",&h,&m,&M); if(h<2)h+=24; H=M<m?h+1:h; if(zone(H)>2)continue; a[zone(H)]++; if((H*60+M)-(h*60+m)<=8)b[zone(H)]++; } printf("lunch %s\n",r(0)); printf("dinner %s\n",r(1)); printf("midnight %s\n",r(2)); } return 0; }
main.c: In function 'r': main.c:3:26: error: implicit declaration of function 'strcpy' [-Wimplicit-function-declaration] 3 | char s[9];char *r(int i){strcpy(s,"no guest");if(a[i])sprintf(s,"%d",b[i]*100/a[i]);return s;} | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strcpy' +++ |+#include <string.h> 1 | #define zone(h) ( (11<=(h)&&(h)<15)?0:(18<=(h)&&(h)<21)?1:(21<=(h)&&(h)<26)?2:3 ) main.c:3:26: warning: incompatible implicit declaration of built-in function 'strcpy' [-Wbuiltin-declaration-mismatch] 3 | char s[9];char *r(int i){strcpy(s,"no guest");if(a[i])sprintf(s,"%d",b[i]*100/a[i]);return s;} | ^~~~~~ main.c:3:26: note: include '<string.h>' or provide a declaration of 'strcpy' main.c:3:55: error: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration] 3 | char s[9];char *r(int i){strcpy(s,"no guest");if(a[i])sprintf(s,"%d",b[i]*100/a[i]);return s;} | ^~~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'sprintf' +++ |+#include <stdio.h> 1 | #define zone(h) ( (11<=(h)&&(h)<15)?0:(18<=(h)&&(h)<21)?1:(21<=(h)&&(h)<26)?2:3 ) main.c:3:55: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch] 3 | char s[9];char *r(int i){strcpy(s,"no guest");if(a[i])sprintf(s,"%d",b[i]*100/a[i]);return s;} | ^~~~~~~ main.c:3:55: note: include '<stdio.h>' or provide a declaration of 'sprintf' main.c: At top level: main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int] 4 | main(n,h,m,H,M){ | ^~~~ main.c: In function 'main': main.c:4:1: error: type of 'n' defaults to 'int' [-Wimplicit-int] main.c:4:1: error: type of 'h' defaults to 'int' [-Wimplicit-int] main.c:4:1: error: type of 'm' defaults to 'int' [-Wimplicit-int] main.c:4:1: error: type of 'H' defaults to 'int' [-Wimplicit-int] main.c:4:1: error: type of 'M' defaults to 'int' [-Wimplicit-int] main.c:5:14: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 5 | for(;scanf("%d",&n),n){ | ^~~~~ main.c:5:14: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:5:14: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] main.c:5:14: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:5:30: error: expected ';' before ')' token 5 | for(;scanf("%d",&n),n){ | ^ | ; main.c:15:17: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 15 | printf("lunch %s\n",r(0)); | ^~~~~~ main.c:15:17: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:15:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:15:17: note: include '<stdio.h>' or provide a declaration of 'printf'
s812295105
p00647
C
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int main() { int n; while(scanf("%d",&n)&&n) { int hh,mm,MM,lunchsum=0,dinnersum=0,midnightsum=0,lunch=0,dinner=0,midnight=0; int i; for(i=1;i<=n;i++) { scanf("%d%*c%d%d",&hh, &mm, &MM); if(hh>=11&&hh<=14) { lunchsum++; if((MM>mm&&MM-mm<=8)||(MM<mm&&MM+60-mm<=8)) { lunch++; } } else if(hh>=18&&hh<=20) { dinnersum++; if((MM>mm&&MM-mm<=8)||(MM<mm&&MM+60-mm<=8)) { dinner++; } } else if(hh<=1&&hh>=21) { midnightsum++; if((MM>mm&&MM-mm<=8)||(MM<mm&&MM+60-mm<=8)) { midnight++; } } } printf("lunch "); if(lunchsum==0) { printf("no guest\n"); } else { printf("%d\n",(int)(1.0*lunch/lunchsum*100)); } printf("dinner "); if(dinnersum==0) { printf("no guest\n"); } else { printf("%d\n",(int)(1.0*dinner/dinnersum*100)); } printf("midnight "); if(midnightsum==0) { printf("no guest\n"); } else { printf("%d\n",(int)(1.0*midnight/midnightsum*100)); } } return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s409056444
p00647
C
#include<stdio.h> int main() { int n,i,a,b,d,e,f,g; int lunchsum,dinnersum,midnightsum,lunchss,dinnerss,midnightss; char c; while(scanf("%d",&n)&&(n!=0)) { lunchsum=0; dinnersum=0; midnightsum=0; lunchss=0; dinnerss=0; midnightss=0; for(i=0;i<n;i++) { scanf("%d%c%d%d",&a,&c,&b,&d); if(a>=11&&a<=14) { lunchsum++; if((d-b)<=8&&(d-b)>=0) lunchss++; else if((d-b)<0) { if((d+60-b)<=8&&(a!=14)) lunchss++; } } else if(a>=18&&a<=20) { dinnersum++; if((d-b)<=8&&(d-b)>=0) dinnerss++; else if((d-b)<0) { if((d+60-b)<=8&&(a!=20)) dinnerss++; } } else if((a>=21&&a<=23)||a<=1&&a>=0
main.c: In function 'main': main.c:42:59: error: expected ')' at end of input 42 | else if((a>=21&&a<=23)||a<=1&&a>=0 | ~ ^ | ) main.c:42:25: error: expected declaration or statement at end of input 42 | else if((a>=21&&a<=23)||a<=1&&a>=0 | ^~~~ main.c:42:25: error: expected declaration or statement at end of input main.c:42:25: error: expected declaration or statement at end of input
s927148628
p00647
C++
// ConsoleApplication1.cpp : ??????????????? ??¢????????±????????§????????¨????????? ????????????????????????????????? // #include<stdio.h> #include"stdafx.h" int main(void){ int n,cnt,a,b,c,i,m; int cnt1 =0; int cnt2 =0; int L=0; int D=0; int M=0; int LP,DP,MP; i = 0; cnt = 0; scanf("%d",&n); while(i<n){ scanf("%d%*c%d%d",&a, &b, &c); i++; if(a == 0) break; m = a * 60 + b; if(m<660){ M++; if(c-a<=8){ cnt++; }else if(c-a <0){ if((60-a)+c<=8){ cnt++; } } }else if(m<900){ L++; if(c-a<=8){ cnt++; }else if(c-a <0){ if((60-a)+c<=8){ cnt1++; } } }else if(m<1260){ D++; if(c-a<=8){ cnt++; }else if(c-a <0){ if((60-a)+c<=8){ cnt2++; } } }else if(m<=1440){ M++; if(c-a<=8){ cnt++; }else if(c-a <0){ if((60-a)+c<=8){ cnt++; } } } } LP = (int)(L/cnt1)*100; DP = (int)(D/cnt2)*100; MP = (int)(M/cnt)*100; if(LP==0){ printf("lunch no guest\n"); }else{ printf("lunch %d\n",LP); } if(DP==0){ printf("dinner no guest\n"); }else{ printf("dinner %d\n",LP); } if(MP==0){ printf("midnight no guest\n"); }else{ printf("midnight %d\n",MP); } return 0; }
a.cc:6:9: fatal error: stdafx.h: No such file or directory 6 | #include"stdafx.h" | ^~~~~~~~~~ compilation terminated.
s348258157
p00647
C++
#include <stdio.h> #include <string.h> #define LUNCH 0 #define DINNER 1 #define MIDNIGHT 2 #define OK 0 #define NG 1 int main(void){ int n, i, j, hh, mm, MM, ans[3][2], *p; char str_MM[3]; while(1){ scanf_s("%d",&n); if(n == 0){ break; } memset(ans,0,sizeof(ans)); for(i = 0;i < n;i++){ scanf_s("%d%*c%d%d",&hh,&mm,&MM); /* scanf("%s",str_MM); MM = 0; for(i = 0;i < 2;i++){ MM = MM * 10 + (str_MM[i] - '0'); }*/ if(2 <= hh && hh <= 10 || 15 <= hh && hh <= 17){ continue; } if(11 <= hh && hh <= 14){ p = ans[LUNCH]; }else if(18 <= hh && hh <= 20){ p = ans[DINNER]; }else{ p = ans[MIDNIGHT]; } if((MM + 60 - mm) % 60 <= 8){ p[OK]++; }else{ p[NG]++; } } if(ans[LUNCH][OK] != 0 || ans[LUNCH][NG] != 0){ printf("lunch %d\n",ans[LUNCH][OK] * 100 / (ans[LUNCH][OK] + ans[LUNCH][NG])); }else{ printf("lunch no guest\n"); } if(ans[DINNER][OK] != 0 || ans[DINNER][NG] != 0){ printf("dinner %d\n",ans[DINNER][OK] * 100 / (ans[DINNER][OK] + ans[DINNER][NG])); }else{ printf("dinner no guest\n"); } if(ans[MIDNIGHT][OK] != 0 || ans[MIDNIGHT][NG] != 0){ printf("midnight %d\n",ans[MIDNIGHT][OK] * 100 / (ans[MIDNIGHT][OK] + ans[MIDNIGHT][NG])); }else{ printf("midnight no guest\n"); } } return 0; }
a.cc: In function 'int main()': a.cc:17:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 17 | scanf_s("%d",&n); | ^~~~~~~ | scanf
s257468950
p00647
C++
#include <iostream> #include <string> #include <sstream> #include <algorithm> #include <vector> #include <utility> #include <functional> #include <stack> #include <queue> #include <map> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <deque> using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define pb push_back #define mp make_pair #define all(r) r.begin(),r.end() #define fi first #define se second #define println(X) cout<<X<<endl; #define DBG(X) cout<<#X<<" : "<<X<<endl; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; string str[]={"linch ", "dinner ", "midnight "}; int main(){ int n; while(cin>> n && n){ int h, m1, m2; char c; int a, b; vi v(3, 0), u(3, 0); while(n--){ cin>>h>>c>>m1>>m2; a = b = h*60; a += m1; b += m2 + (m1>m2?60:0); if(11*60<=a&&a<=14*60+59){ u[0]++; if(b-a<=8) v[0]++; } else if(18*60<=a&&a<=20*60+59){ u[1]++; if(b-a<=8) v[1]++; } else if((21*60<=a||a<=60+59){ u[2]++; if(b-a<=8) v[2]++; //cout<<m1<<" "<<m2<<endl; } } rep(i, 3){ cout<<str[i]; if(u[i]==0) cout<<"no guest"<<endl; else cout<<v[i]*100/u[i]<<endl; } } }
a.cc: In function 'int main()': a.cc:62:53: error: expected ')' before '{' token 62 | else if((21*60<=a||a<=60+59){ | ~ ^ | ) a.cc:67:17: error: expected primary-expression before '}' token 67 | } | ^
s446790774
p00647
C++
#include<iostream> #include<cstdio> using namespace std; int main() { int n; while (cin >> n&&n != 0) { int a[3][2]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) a[i][j] = 0; } int b, c, d; for (int i = 0; i < n; i++) { scanf_s("%d:%d %d", &b, &c, &d); int e = b * 60 + c, f = 0; bool l = false; if (c > d) { f = d + 60 - c; } else { f = d - c; } if (f <= 8) l = true; if (e >= 660 && e < 15 * 60) { if (l) a[0][1]++; a[0][0]++; } else if (e >= 18 * 60 && e < 21 * 60) { if (l) a[1][1]++; a[1][0]++; } else if (e >= 21 & 60 || e < 2 * 60) { if (l) a[2][1]++; a[2][0]++; } } if (a[0][0] == 0) { cout << "lunch no guest" << endl; } else { cout << "lunch " << (a[0][1] * 100) / a[0][0] << endl; } if (a[1][0] == 0) { cout << "dinner no guest" << endl; } else { cout << "dinner " << (a[1][1] * 100) / a[1][0] << endl; } if (a[2][0] == 0) { cout << "midnight no guest" << endl; } else { cout << "midnight " << (a[2][1] * 100) / a[2][0] << endl; } } }
a.cc: In function 'int main()': a.cc:13:25: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 13 | scanf_s("%d:%d %d", &b, &c, &d); | ^~~~~~~ | scanf
s868481408
p00647
C++
#include<iostream> #include<cstdio> using namespace std; int main() { int n; while (cin >> n&&n != 0) { int a[3][2]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) a[i][j] = 0; } int b, c, d; for (int i = 0; i < n; i++) { scanf_s("%d:%d %d", &b, &c, &d); if (b < 2) b += 24; int e = b * 60 + c, f = 0; bool l = false; if (c > d) { f = d + 60 - c; } else { f = d - c; } if (f <= 8) l = true; if (e >= 11*60 && e < 15 * 60) { if (l) a[0][1]++; a[0][0]++; } else if (e >= 18 * 60 && e < 21 * 60) { if (l) a[1][1]++; a[1][0]++; } else if (e >= 21 & 60 || e < 2 * 60) { if (l) a[2][1]++; a[2][0]++; } } if (a[0][0] == 0) { cout << "lunch no guest" << endl; } else { cout << "lunch " << (a[0][1] * 100) / a[0][0] << endl; } if (a[1][0] == 0) { cout << "dinner no guest" << endl; } else { cout << "dinner " << (a[1][1] * 100) / a[1][0] << endl; } if (a[2][0] == 0) { cout << "midnight no guest" << endl; } else { cout << "midnight " << (a[2][1] * 100) / a[2][0] << endl; } } }
a.cc: In function 'int main()': a.cc:13:25: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 13 | scanf_s("%d:%d %d", &b, &c, &d); | ^~~~~~~ | scanf
s568293875
p00647
C++
#include<iostream> #include<cstdio> using namespace std; int main() { int n; while (cin >> n&&n != 0) { int a[3][2]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) a[i][j] = 0; } int b, c, d; for (int i = 0; i < n; i++) { scanf_s("%d:%d %d", &b, &c, &d); if (b < 2) b += 24; int e = b * 60 + c, f = 0; bool l = false; if (c > d) { f = d + 60 - c; } else { f = d - c; } if (f <= 8) l = true; if (e >= 11*60 && e < 15 * 60) { if (l) a[0][1]++; a[0][0]++; } else if (e >= 18 * 60 && e < 21 * 60) { if (l) a[1][1]++; a[1][0]++; } else if (e >= 21 & 60) { if (l) a[2][1]++; a[2][0]++; } } if (a[0][0] == 0) { cout << "lunch no guest" << endl; } else { cout << "lunch " << (a[0][1] * 100) / a[0][0] << endl; } if (a[1][0] == 0) { cout << "dinner no guest" << endl; } else { cout << "dinner " << (a[1][1] * 100) / a[1][0] << endl; } if (a[2][0] == 0) { cout << "midnight no guest" << endl; } else { cout << "midnight " << (a[2][1] * 100) / a[2][0] << endl; } } }
a.cc: In function 'int main()': a.cc:13:25: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 13 | scanf_s("%d:%d %d", &b, &c, &d); | ^~~~~~~ | scanf
s527733970
p00647
C++
#include<iostream> #include<cstdio> using namespace std; int main() { int n; while (cin >> n&&n != 0) { int a[3][2]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) a[i][j] = 0; } int b, c, d; for (int i = 0; i < n; i++) { scanf_s("%d:%d %d", &b, &c, &d); if (b < 11) b += 24; if (d < c) d += 60; int f = d - c; int e = b * 60 + c; if (e >= 11 * 60 && e < 15 * 60) { a[0][0]++; if (f <= 8) a[0][1]++; } if (e >= 18 * 60 && e < 21 * 60) { a[1][0]++; if (f <= 8) a[1][1]++; } if (e >= 21 * 60) { a[2][0]++; if (f <= 8) a[2][1]++; } } if (a[0][0] == 0) { cout << "lunch no guest" << endl; } else { cout << "lunch " << (a[0][1] * 100) / a[0][0] << endl; } if (a[1][0] == 0) { cout << "dinner no guest" << endl; } else { cout << "dinner " << (a[1][1] * 100) / a[1][0] << endl; } if (a[2][0] == 0) { cout << "midnight no guest" << endl; } else { cout << "midnight " << (a[2][1] * 100) / a[2][0] << endl; } } }
a.cc: In function 'int main()': a.cc:13:25: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 13 | scanf_s("%d:%d %d", &b, &c, &d); | ^~~~~~~ | scanf
s164737119
p00647
C++
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; struct time{ int h , m ; time(int hh , int mm ){ h=hh;m=mm; } void operator ++ (){ m++; if( m == 60 ){ m = 0; h ++ ; if( h == 24 ) h = 0; } } int at(){ if( (h>=11&&m>=0) &&( h <=14 && m <= 59) )return 0; if( ( h >=18&&m>=0 ) && (h<=20&&m<=59)) return 1; if( (h>=21&&m>=0)||(h<=1&&m<=59)) return 2; return 3; } }; int ans[3][2]; int main(){ int n ;while(~scanf("%d",&n),n){ memset(ans,0,sizeof(ans)); int a , b , c ; for(int i = 0 ; i< n ; ++ i ){ scanf("%d%*c%d%d",&a, &b, &c); time tmp = time(a,b); int aat = tmp.at(); if( aat == 3 ) continue ; ans[aat][0]++; int k = 0 ; while( tmp.m != c ){ tmp++; k++; } if( k <= 8 ) ans[aat][1]++; } printf("lunch "); if( ans[0][0] == 0 ) printf("no guest\n"); else printf("%d\n",ans[0][1]*100/ans[0][0]); printf("dinner "); if( ans[1][0] == 0 ) printf("no guest\n"); else printf("%d\n",ans[1][1]*100/ans[1][0]); printf("midnight "); if( ans[2][0] == 0 ) printf("no guest\n"); else printf("%d\n",ans[2][1]*100/ans[2][0]); } }
a.cc: In function 'int main()': a.cc:36:29: error: expected ';' before 'tmp' 36 | time tmp = time(a,b); | ^~~~ | ; a.cc:37:35: error: 'tmp' was not declared in this scope; did you mean 'tm'? 37 | int aat = tmp.at(); | ^~~ | tm
s776930022
p00647
C++
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; struct Time{ int h , m ; time(){ } void operator ++ (){ m++; if( m == 60 ){ m = 0; h ++ ; if( h == 24 ) h = 0; } } int at(){ if( (h>=11&&m>=0) &&( h <=14 && m <= 59) )return 0; if( ( h >=18&&m>=0 ) && (h<=20&&m<=59)) return 1; if( (h>=21&&m>=0)||(h<=1&&m<=59)) return 2; return 3; } }; int ans[3][2]; int main(){ int n ;while(~scanf("%d",&n),n){ memset(ans,0,sizeof(ans)); int a , b , c ; Time tmp; for(int i = 0 ; i< n ; ++ i ){ scanf("%d:%d%d",&a,&b,&c); tmp.h = a; tmp.m = b; int aat = tmp.at(); if( aat == 3 ) continue ; ans[aat][0]++; int k = 0 ; while( tmp.m != c ){ tmp++; k++; } if( k <= 8 ) ans[aat][1]++; } printf("lunch "); if( ans[0][0] == 0 ) printf("no guest\n"); else printf("%d\n",ans[0][1]*100/ans[0][0]); printf("dinner "); if( ans[1][0] == 0 ) printf("no guest\n"); else printf("%d\n",ans[1][1]*100/ans[1][0]); printf("midnight "); if( ans[2][0] == 0 ) printf("no guest\n"); else printf("%d\n",ans[2][1]*100/ans[2][0]); } }
a.cc:9:9: error: ISO C++ forbids declaration of 'time' with no type [-fpermissive] 9 | time(){ | ^~~~ a.cc: In member function 'int Time::time()': a.cc:11:9: warning: no return statement in function returning non-void [-Wreturn-type] 11 | } | ^ a.cc: In function 'int main()': a.cc:45:36: error: no 'operator++(int)' declared for postfix '++' [-fpermissive] 45 | tmp++; | ~~~^~
s069505143
p00648
Java
import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int channelCnt = sc.nextInt(); Queue queue = new PriorityQueue(1, new WatchinTVA().new MyComparator()); for(int i=0 ; i<channelCnt ; i++) { Bangumi bangumi = new WatchinTVA().new Bangumi(sc.next(), sc.next(), sc.next()); queue.add(bangumi); } int favCnt = sc.nextInt(); List list = new ArrayList(); for(int j=0 ; j<favCnt ; j++) { list.add(sc.next()); } List favList = new ArrayList(); Object[] o = queue.toArray(); Arrays.sort(o, new WatchinTVA().new MyComparator()); for(int i=0 ; i<o.length ; i++) { Bangumi b = (Bangumi)o[i]; for(int j=0 ; j<list.size() ; j++) { if(list.get(j).toString().equals(b.name)) { favList.add(b); } } } Queue queue2 = new PriorityQueue(1, new WatchinTVA().new MyComparator()); outside: for(int i=0 ; i<o.length ; i++) { Bangumi b = (Bangumi)o[i]; boolean flg = true; for(int j=0 ; j<favList.size() ; j++) { Bangumi bb = (Bangumi)favList.get(j); if((b.time+30) > bb.time && (b.time+30) < (bb.time+30)) { flg = false; } } if(flg) queue2.add(b); } Object[] o1 = queue2.toArray(); Arrays.sort(o1, new WatchinTVA().new MyComparator()); int beforeEnd = 0; int result = 0; for(int l=0 ; l<o1.length ; l++) { if(((Bangumi)o1[l]).time > beforeEnd) { result++; beforeEnd = ((Bangumi)o1[l]).time + 30; } } System.out.println(result); } public class MyComparator implements Comparator<Object> { public int compare(Object o1, Object o2) { Bangumi a = (Bangumi)o1; Bangumi b = (Bangumi)o2; if(a.time > b.time) return 1; else if(a.time < b.time) { return -1; }else { return 0; } } } public class Bangumi { String name; int time; public Bangumi(String name, String youbi, String time){ this.name = name; this.time = new Integer((youbi + time)).intValue(); } } }
Main.java:15: error: cannot find symbol Queue queue = new PriorityQueue(1, new WatchinTVA().new MyComparator()); ^ symbol: class WatchinTVA location: class Main Main.java:17: error: cannot find symbol Bangumi bangumi = new WatchinTVA().new Bangumi(sc.next(), sc.next(), sc.next()); ^ symbol: class WatchinTVA location: class Main Main.java:27: error: cannot find symbol Arrays.sort(o, new WatchinTVA().new MyComparator()); ^ symbol: class WatchinTVA location: class Main Main.java:36: error: cannot find symbol Queue queue2 = new PriorityQueue(1, new WatchinTVA().new MyComparator()); ^ symbol: class WatchinTVA location: class Main Main.java:50: error: cannot find symbol Arrays.sort(o1, new WatchinTVA().new MyComparator()); ^ symbol: class WatchinTVA location: class Main Main.java:92: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal this.time = new Integer((youbi + time)).intValue(); ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 5 errors 1 warning
s463803528
p00648
Java
\import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int channelCnt = sc.nextInt(); Queue queue = new PriorityQueue(1, new Main().new MyComparator()); for(int i=0 ; i<channelCnt ; i++) { Bangumi bangumi = new Main().new Bangumi(sc.next(), sc.next(), sc.next()); queue.add(bangumi); } int favCnt = sc.nextInt(); List list = new ArrayList(); for(int j=0 ; j<favCnt ; j++) { list.add(sc.next()); } List favList = new ArrayList(); Object[] o = queue.toArray(); Arrays.sort(o, new Main().new MyComparator()); for(int i=0 ; i<o.length ; i++) { Bangumi b = (Bangumi)o[i]; for(int j=0 ; j<list.size() ; j++) { if(list.get(j).toString().equals(b.name)) { favList.add(b); } } } Queue queue2 = new PriorityQueue(1, new Main().new MyComparator()); outside: for(int i=0 ; i<o.length ; i++) { Bangumi b = (Bangumi)o[i]; boolean flg = true; for(int j=0 ; j<favList.size() ; j++) { Bangumi bb = (Bangumi)favList.get(j); if((b.time+30) > bb.time && (b.time+30) < (bb.time+30)) { flg = false; } } if(flg) queue2.add(b); } Object[] o1 = queue2.toArray(); Arrays.sort(o1, new Main().new MyComparator()); int beforeEnd = 0; int result = 0; for(int l=0 ; l<o1.length ; l++) { if(((Bangumi)o1[l]).time > beforeEnd) { result++; beforeEnd = ((Bangumi)o1[l]).time + 30; } } System.out.println(result); } public class MyComparator implements Comparator<Object> { public int compare(Object o1, Object o2) { Bangumi a = (Bangumi)o1; Bangumi b = (Bangumi)o2; if(a.time > b.time) return 1; else if(a.time < b.time) { return -1; }else { return 0; } } } public class Bangumi { String name; int time; public Bangumi(String name, String youbi, String time){ this.name = name; this.time = new Integer((youbi + time)).intValue(); } } }
Main.java:1: error: illegal character: '\' \import java.util.ArrayList; ^ Main.java:1: error: class, interface, enum, or record expected \import java.util.ArrayList; ^ Main.java:2: error: class, interface, enum, or record expected import java.util.Arrays; ^ Main.java:3: error: class, interface, enum, or record expected import java.util.Comparator; ^ Main.java:4: error: class, interface, enum, or record expected import java.util.List; ^ Main.java:5: error: class, interface, enum, or record expected import java.util.PriorityQueue; ^ Main.java:6: error: class, interface, enum, or record expected import java.util.Queue; ^ Main.java:7: error: class, interface, enum, or record expected import java.util.Scanner; ^ 8 errors
s614684828
p00648
C++
import bisect while(1): N=int(raw_input()) if N==0: break D={} for i in range(N): inp=raw_input().split() inp[1:]=map(int, inp[1:]) stt=inp[1]*24*60+inp[2]/100*60+inp[2]%100 D[inp[0]]=stt P=int(raw_input()) Tlist=[-99999999,999999999] for i in range(P): f=raw_input() Tlist.append(D.pop(f)) Tlist.sort() for i in range(P+1): if Tlist[i+1]<Tlist[i]+30: print -1 break else: ans=P E=sorted(D.values()) for st in E: if (st - Tlist[ bisect.bisect(Tlist, st)-1])>= 30 and (Tlist[ bisect.bisect(Tlist, st)] - st ) >= 30: ans+=1 bisect.insort(Tlist, st) print ans
a.cc:1:1: error: 'import' does not name a type 1 | import bisect | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:5: error: expected unqualified-id before 'for' 7 | for i in range(N): | ^~~
s609748935
p00648
C++
#include<iostream> #include<vector> #include<map> using namespace std; int n, p; typedef pair<int, string> TV; int main() { while(cin >> n, n) { vector<TV> tvs; for(int i = 0; i < n; i++) { string name; int week, start; cin >> name >> week >> start; tvs.push_back(TV(week * 60*24 + (start / 100 * 60) + start % 100, name)); } vector<int> times; cin >> p; int curTime = -300; int tvCount = p; sort(tvs.begin(), tvs.end()); for(int i = 0; i < p; i++) { string fav; cin >> fav; for(int j = 0; j < n; j++) { if(tvs[j].second == fav) { for(int k = 0; k < (int)times.size(); k++) { if(tvs[j].first < times[k] + 30 && times[k] < tvs[j].first + 30) { goto mirenai; } } times.push_back(tvs[j].first); break; } } } // sort(times.begin(), times) for(int i = 0; i < n; i++) { bool watchable = true; for(int k = 0; k < times.size(); k++) { if(tvs[i].first < times[k] + 30 && times[k] < tvs[i].first + 30) { watchable = false; break; } } if(!watchable || tvs[i].first < curTime + 30 && curTime < tvs[i].first + 30) { } else { tvCount++; curTime = tvs[i].first; } } cout << tvCount << endl; continue; mirenai: cout << -1 << endl; } }
a.cc: In function 'int main()': a.cc:22:17: error: 'sort' was not declared in this scope; did you mean 'short'? 22 | sort(tvs.begin(), tvs.end()); | ^~~~ | short
s139119998
p00648
C++
/* * Author: FreeIdea * Created Time: 2011/8/22 13:58:15 * File Name: B.cpp */ #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <vector> #include <map> using namespace std; const int maxint = -1u>>1; template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;} template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;} const int maxn = 500 + 50; map<string, int> idx; int n, p, cnt; struct Pro { int day, time, idx; bool operator < (const Pro & A) const{ if(day == A.day) return time < A.time; return day < A.day; } void solve() { int h = time / 100; int m = time % 100; h += m / 60; m %= 60; day += h / 24; h %= 24; day %= 7; time = h * 100 + m; } }pro[maxn]; char name[100]; int day, time; bool must[maxn], cannot[maxn]; int hash(const string &str) { if(idx.count(str)) return idx[str]; ++cnt; return idx[str] = cnt; } bool con(const Pro &p1, const Pro &p2) { Pro t1 = p1, t2 = p2; if(t2 < t1) { swap(t1, t2); } t1.time += 30; t1.solve(); return t2 < t1; } int calc(int l, int r) { if(l > r) return 0; Pro tmp; tmp.day = -100; tmp.time = -100; int res = 0; for(int i = l; i <= r; i++) { if(cannot[i]) continue; if(pro[i] < tmp) continue; res++; tmp = pro[i]; tmp.time += 30; tmp.solve(); } return res; } int main() { while(scanf("%d", &n) == 1 && n) { idx.clear(); cnt = 0; for(int i = 1; i <= n; i++) { scanf("%s%d%d", name, &day, &time); pro[i].idx = hash(string(name)); pro[i].day = day; pro[i].time = time; pro[i].solve(); } scanf("%d", &p); memset(must, false, sizeof(must)); memset(cannot, false, sizeof(cannot)); for(int i = 1; i <= p; i++) { scanf("%s", name); must[hash(string(name))] = true; } stable_sort(pro + 1, pro + 1 + n); int last = 0; int ans = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(i == j) continue; if(must[pro[i].idx] && must[pro[j].idx]) { if(con(pro[i], pro[j])) { ans = -1; } } } } for(int i = 1; i <= n; i++) { if(must[pro[i].idx]) { for(int j = 1; j <= n; j++) { if(i == j) continue; if(con(pro[i], pro[j]) || con(pro[j], pro[i])) { cannot[j] = true; } } } } if(ans != -1) { ans = p; for(int i = 1; i <= n; i++) { if(must[pro[i].idx]) { ans += calc(last + 1, i - 1); last = i; } } ans += calc(last + 1, n); } printf("%d\n", ans); } return 0; }
a.cc:42:10: error: 'int time' redeclared as different kind of entity 42 | int day, time; | ^~~~ 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/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:6: /usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:84:26: error: reference to 'hash' is ambiguous 84 | pro[i].idx = hash(string(name)); | ^~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, 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: /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:45:5: note: 'int hash(const std::string&)' 45 | int hash(const string &str) { | ^~~~ a.cc:86:27: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive] 86 | pro[i].time = time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:94:18: error: reference to 'hash' is ambiguous 94 | must[hash(string(name))] = true; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:45:5: note: 'int hash(const std::string&)' 45 | int hash(const string &str) { | ^~~~
s587620264
p00648
C++
#include<iostream> #include<string> #include<map> #include<set> #include<vector> using namespace std; #define rep(i, n) for ( int i = 0; i < n; i++) static const int MAX = 500; static const int L = 30; bool overlap(int a, int b){ if ( a > b ) swap(a, b); return a + 30 > b; } int getProgram(vector<int> v){ sort(v.begin(), v.end()); int dp[MAX]; int maxv = v.size()>0?1:0; for ( int i = 0; i < v.size(); i++ ) dp[i] = 1; for ( int i = 1; i < v.size(); i++ ){ for ( int j = i-1; j >= 0; j-- ){ if ( !overlap(v[j], v[i]) ){ dp[i] = dp[j]+1; maxv = max(maxv, dp[i]); break; } } } return maxv; } int solve(int N){ int in[MAX], w, s, P; map<string, int> M; string name; vector<int> F, T; rep(i, N){ cin >> name >> w >> s; M[name] = i; in[i] = w*1440 + (s/100)*60 + s%100; } cin >> P; rep(i, P){ cin >> name; F.push_back(in[M[name]]); } int ans = getProgram(F); if ( ans == 0 ) return -1; rep(i, N){ bool f = true; for ( int j = 0; j < F.size(); j++ ){ if ( overlap(F[j], in[i]) ) { f = false; break; } } if ( f ) T.push_back(in[i]); } return ans + getProgram(T); } main(){ int N; while(1){ cin >> N; if ( N == 0 ) break; cout << solve(N) << endl; } }
a.cc: In function 'int getProgram(std::vector<int>)': a.cc:17:3: error: 'sort' was not declared in this scope; did you mean 'short'? 17 | sort(v.begin(), v.end()); | ^~~~ | short a.cc: At global scope: a.cc:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 62 | main(){ | ^~~~
s583355818
p00648
C++
#include <iostream> #include <string> #include <vector> #include <map> #include <set> #include <cstdio> using namespace std; int main(){ int n,i,r,last,time,day; for(;cin>>n,n;){ vector<pair<int,string> >program; set<string>precious; string s; { map<string,int>m; for(;n--;){ cin>>s>>day>>time; program.push_back(make_pair(day*1440+time/100*60+time%100,s)); m[s]=day*1440+time/100*60+time%100; } for(cin>>n;n--;){ cin>>s; set<string>::iterator it=precious.begin(); for(;it!=precious.end();it++){ if(abs(m[*it]-m[s])<30){puts("-1");goto next;} } precious.insert(s); } } sort(program.begin(),program.end()); for(last=r=i=0;i<program.size();i++){ if(program[i].first>=last){ last=program[i].first+30; r++; }else if(precious.find(program[i].second)!=precious.end()){ last=program[i].first+30; } } printf("%d\n",r); next:; } }
a.cc: In function 'int main()': a.cc:30:17: error: 'sort' was not declared in this scope; did you mean 'short'? 30 | sort(program.begin(),program.end()); | ^~~~ | short
s529628570
p00648
C++
/* * Author: 8mao * Created Time: 2014/3/16 13:31:26 * File Name: 1331.cpp */ # include<map> # include<set> # include<cmath> # include<queue> # include<stack> # include<vector> # include<string> # include<cstdio> # include<cstring> # include<iostream> # include<algorithm> # include<functional> using namespace std; typedef pair<int,int> PII; # define INF 1<<30 # define LL long long # define MOD 1000000007 # define VI vector<int> # define VLL vector<LL> # define VS vector<string> # define PII pair<int,int> # define F first # define S second # define mp make_pair # define pb push_back # define lb lower_bound # define up upper_bound # define lowbit(x)(x&-x) # define lson l,m,rt<<1 # define rson m+1,r,rt<<1|1 # define clr(x) (x).clear() # define sz(x) ((int)(x).size()) # define all(x) (x).begin(),(x).end() # define mem(x,y) memset(x,y,sizeof(x)) # define forall(it,c) for(typeof((c).begin())it=(c).begin();it!=(c).end();it++) # define N 505 # define M 20005 PII a[N]; int dp[N][M], n; struct node { char s[50]; int t, must, del; }e[N]; int calc(int week, int time) { int ans = week * 24 * 60; ans += time % 100 + (time / 100 * 60); return ans; } int dfs(int pos, int end) { int ans = 0; if (pos == n + 1) return 0; if (dp[pos][end] != -1) return dp[pos][end]; if (a[pos].S || a[pos].F >= end) //must 譛牙庄閭ス莨壼?髞? ans = max (ans, 1 + dfs(pos + 1, a[pos].F + 30)); ans = max (ans, dfs(pos + 1, end)); return dp[pos][end] = ans; } int Jireh(int m) { int i, j; for (i = 1; i <= m; i++) if (e[i].must) { for (j = 1; j <= m; j++) if (j != i && abs(e[j].t - e[i].t) < 30) //豕ィ諢冗せ,譛牙庄閭ス莨壼?髞? e[j].del = 1; } for (i = 1; i <= m; i++) if (e[i].must && e[i].del) return 0; n = 0; for (i = 1; i <= m; i++) if (!e[i].del) { ++n; a[n].F = e[i].t; a[n].S = e[i].must; } return 1; } int cmp(const node &a, const node &b) { return a.t < b.t; } int main() { int i, j, n, m, x, y; char s[50]; while (scanf ("%d", &n) != EOF && n) { mem (dp, -1); for (i = 1; i <= n; i++) { scanf ("%s", e[i].s); scanf ("%d %d", &x, &y); e[i].t = calc(x, y); e[i].must = e[i].del = 0; } scanf ("%d", &m); for (i = 1; i <= m; i++) { scanf ("%s", s); for (j = 1; j <= n; j++) if (strcmp(e[j].s, s) == 0) { e[j].must = 1; break; } } sort (e + 1, e + n + 1, cmp); if (!Jireh(n)) { printf ("-1\n"); continue; } int ans = dfs(1, 0); printf ("%d\n", ans); } return 0; }
a.cc: In function 'int Jireh(int)': a.cc:82:9: error: expected primary-expression before '}' token 82 | } | ^
s329637946
p00650
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> using namespace std; #ifdef _MSC_VER #define __typeof__ decltype template <class T> int popcount(T n) { return n ? 1 + popcount(n & (n - 1)) : 0; } #endif #ifdef __GNUC__ template <class T> int popcount(T n); template <> int popcount(unsigned int n) { return n ? __builtin_popcount(n) : 0; } template <> int popcount(int n) { return n ? __builtin_popcount(n) : 0; } template <> int popcount(unsigned long long n) { return n ? __builtin_popcountll(n) : 0; } template <> int popcount(long long n) { return n ? __builtin_popcountll(n) : 0; } #endif #define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++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 rep(i, n) for (int i = 0; i < n; ++i) template <class T> void max_swap(T& a, const T& b) { a = max(a, b); } template <class T> void min_swap(T& a, const T& b) { a = min(a, b); } typedef long long ll; typedef pair<int, int> pint; const double EPS = 1e-8; const double PI = acos(-1.0); const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { 1, 0, -1, 0 }; bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; } template <class T> void print(T a, int n, int br = 1, const string& deli = ", ") { cout << "{ "; for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } cout << " }"; while (br--) cout << endl; } template <class T> void print(const vector<T>& v, int br = 1, const string& deli = ", ") { print(v, v.size(), br, deli); } template <class T> class UnionFind { private: T* parent; T* rank; public: int groups; UnionFind(int n) : groups(n) { parent = new T[n]; rank = new T[n]; for (int i = 0; i < n; ++i) { parent[i] = i; rank[i] = 0; } } void unite(T a, T b) { T root_a = find(a); T root_b = find(b); if (root_a == root_b) return; --groups; if (rank[root_a] < rank[root_b]) parent[root_a] = root_b; else if (rank[root_a] > rank[root_b]) parent[root_b] = root_a; else { parent[root_a] = root_b; ++rank[root_a]; } } bool same(T a, T b) { return find(a) == find(b); } T find(T e) { if (parent[e] == e) return e; else return parent[e] = find(parent[e]); } }; class SCC { public: int V; vector<vector<int> > g; vector<vector<int> > rg; vector<int> vs; // 帰りの順番, 後ろのほう要素は始点側 vector<bool> used; vector<int> component; SCC(int V) : V(V), g(V), rg(V), vs(V), used(V), component(V) { } void add_edge(int from, int to) { g[from].push_back(to); rg[to].push_back(from); } void dfs(int v) { used[v] = true; for (int i = 0; i < g[v].size(); ++i) if (!used[g[v][i]]) dfs(g[v][i]); vs.push_back(v); } void rdfs(int v, int k) { used[v] = true; component[v] = k; for (int i = 0; i < rg[v].size(); ++i) if (!used[rg[v][i]]) rdfs(rg[v][i], k); } // 強連結成分の数を返す // O(V + E) // グラフの始点側の値(component[v])は小さい // 末端は大きい値, 最末端(component[v] == scc() - 1) int scc() { vs.clear(); fill(used.begin(), used.end(), false); for (int i = 0; i < V; ++i) if (!used[i]) dfs(i); fill(used.begin(), used.end(), false); int k = 0; for (int i = vs.size() - 1; i >= 0; --i) if (!used[vs[i]]) rdfs(vs[i], k++); return k; } }; int main() { ios::sync_with_stdio(false); int n, m; while (cin >> n >> m, n) { vector<pint> e[128]; // (to, cost) UnionFind<int> uf(n); int res = 0; while (m--) { int x, y, c; cin >> x >> y >> c; if (c <= 0) res += c; else { e[x].push_back(pint(y, c)); uf.unite(x, y); } } if (uf.groups == 1) { SCC scc(n); for (int i = 0; i < n; ++i) for (int j = 0; j < e[i].size(); ++j) scc.add_edge(i, e[i][j].first); scc.scc(); int min_cost = INT_MAX; map<int, vector<int> > cost_in_scc; for (int i = 0; i < n; ++i) { for (int j = 0; j < e[i].size(); ++j) { int x = i, y = e[i][j].first, c = e[i][j].second; if (scc.component[x] != scc.component[y]) min_swap(min_cost, c); else cost_in_scc[scc.component[x]].push_back(c); } } foreach (it, cost_in_scc) { vector<int>& v = it->second; sort(all(v)); min_swap(min_cost, v[0] + v[1]); } res += min_cost; } cout << res << endl; } }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.