submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s515457108
p00197
Java
#include<iostream> #include<climits> #include<math.h> #include<vector> #include<algorithm> #include<cstdio> #include <string> #include <complex> #include <functional> using namespace std; typedef pair<int,int> P; double dat[100][100]; double dp[200][100];//動的計画法 int main(){ int a,b,cnt,tmp; while(cin>>a>>b,a){ cnt=0; while(b){ a%=b; tmp=b; b=a; a=tmp; cnt++; } cout<<a<<" "<<cnt<<endl; } }
Main.java:1: error: illegal character: '#' #include<iostream> ^ Main.java:2: error: illegal character: '#' #include<climits> ^ Main.java:3: error: illegal character: '#' #include<math.h> ^ Main.java:4: error: illegal character: '#' #include<vector> ^ Main.java:5: error: illegal character: '#' #include<algorithm> ^ Main.java:6: error: illegal character: '#' #include<cstdio> ^ Main.java:7: error: illegal character: '#' #include <string> ^ Main.java:8: error: illegal character: '#' #include <complex> ^ Main.java:9: error: illegal character: '#' #include <functional> ^ Main.java:11: error: class, interface, enum, or record expected typedef pair<int,int> P; ^ Main.java:12: error: class, interface, enum, or record expected double dat[100][100]; ^ Main.java:13: error: class, interface, enum, or record expected double dp[200][100];//????? ^ Main.java:16: error: not a statement while(cin>>a>>b,a){ ^ Main.java:25: error: not a statement cout<<a<<" "<<cnt<<endl; ^ Main.java:14: error: unnamed classes are a preview feature and are disabled by default. int main(){ ^ (use --enable-preview to enable unnamed classes) Main.java:16: error: ')' expected while(cin>>a>>b,a){ ^ Main.java:16: error: ';' expected while(cin>>a>>b,a){ ^ 17 errors
s708387648
p00197
C
a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}}
main.c:1:1: warning: data definition has no type or storage class 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int] main.c:1:3: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int] 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^ main.c:1:5: error: return type defaults to 'int' [-Wimplicit-int] 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^ main.c: In function 'c': main.c:1:35: error: 'return' with no value, in function returning non-void [-Wreturn-mismatch] 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^~~~~~ main.c:1:5: note: declared here 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^ main.c: At top level: main.c:1:57: error: return type defaults to 'int' [-Wimplicit-int] 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^~~~ main.c: In function 'main': main.c:1:72: error: 'intx' undeclared (first use in this function); did you mean 'int'? 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^~~~ | int main.c:1:72: note: each undeclared identifier is reported only once for each function it appears in main.c:1:77: error: 'y' undeclared (first use in this function) 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^ main.c:1:79: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} main.c:1:79: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^~~~~ main.c:1:79: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:93: error: 'x' undeclared (first use in this function) 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^ main.c:1:142: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | a,b;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){intx,y;scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}} | ^~~~~~ main.c:1:142: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:142: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:142: note: include '<stdio.h>' or provide a declaration of 'printf'
s350643163
p00197
C
#include <bits/stdc++.h> using namespace std; // pp basics #define in , #define esc_paren(...) __VA_ARGS__ #define pp_empty(...) #define pp_cat_i(x, y) x ## y #define pp_cat(x, y) pp_cat_i(x, y) #define pp_inc0 1 #define pp_inc1 2 #define pp_inc2 3 #define pp_inc3 4 #define pp_inc4 5 #define pp_inc5 6 #define pp_inc6 7 #define pp_inc7 8 #define pp_inc8 9 #define pp_inc(i) pp_cat(pp_inc, i) // pp args counter #define pp_arg10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, ...) _9 #define pp_has_comma(...) pp_arg10(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 0) #define pp_trigger_paren(...) , #define pp_is_empty(...) \ pp_is_empty1( \ pp_has_comma(__VA_ARGS__), \ pp_has_comma(pp_trigger_paren __VA_ARGS__), \ pp_has_comma(__VA_ARGS__()), \ pp_has_comma(pp_trigger_paren __VA_ARGS__()) \ ) #define pp_paste5(_0, _1, _2, _3, _4) _0 ## _1 ## _2 ## _3 ## _4 #define pp_is_empty1(_0, _1, _2, _3) pp_has_comma(pp_paste5(pp_is_empty_case_, _0, _1, _2, _3)) #define pp_is_empty_case_0001 , #define pp_is_one(...) pp_is_one_(__VA_ARGS__, pp_one_seq) #define pp_is_one_(...) pp_is_one_n(__VA_ARGS__) #define pp_is_one_n(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10, N, ...) N #define pp_one_seq 0,0,0,0,0,0,0,0,0,1,0 #define pp_narg(...) \ pp_narg_(__VA_ARGS__, pp_narg_seq) #define pp_narg_(...) \ pp_narg_n(__VA_ARGS__) #define pp_narg_n( \ _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \ _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ _61,_62,_63,n,...) n #define pp_narg_seq \ 63,62,61,60, \ 59,58,57,56,55,54,53,52,51,50, \ 49,48,47,46,45,44,43,42,41,40, \ 39,38,37,36,35,34,33,32,31,30, \ 29,28,27,26,25,24,23,22,21,20, \ 19,18,17,16,15,14,13,12,11,10, \ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 // pp if #define pp_if_0(x, y) y #define pp_if_1(x, y) x #define pp_if(cond, x, y) pp_cat(pp_if_, cond)(x, y) // pp foreach #define pp_foreach_i9(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i8(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i7(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i6(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i5(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i4(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i3(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i2(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i1(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i0(i, f, x, ...) f(x) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach_i(i, f, ...) pp_if(pp_is_empty(__VA_ARGS__), pp_empty, pp_cat(pp_foreach_i, i))(pp_inc(i), f, __VA_ARGS__) #define pp_foreach(f, ...) pp_foreach_i(0, f, __VA_ARGS__) // alternative rep macro #define rep(...) rep1(rep2, (__VA_ARGS__)) #define rep1(X, A) X A #define rep2(i, ...) pp_if(pp_is_one(__VA_ARGS__), rep_len1(i, __VA_ARGS__), rep3(i, __VA_ARGS__)) #define rep_len1(i, end, ...) for (int i = 0; i < end; i++) #define rep3(i, iter, ...) rep4(rep5, (iter, i, esc_paren __VA_ARGS__)) #define rep4(X, A) X A #define rep5(iter, ...) iter(__VA_ARGS__) // iterators #define up up_iter , #define up_iter3(i, start, end) for (int i = start; i < end; i++) #define up_iter4(i, start, end, up) for (int i = start; i < end; i += up) #define up_iter(...) pp_cat(up_iter, pp_narg(__VA_ARGS__))(__VA_ARGS__) #define down down_iter , #define down_iter2(i, end) for(int i = end-1; i >= 0; i--) #define down_iter3(i, start, end) for (int i = end-1; i >= start; i--) #define down_iter4(i, start, end, down) for (int i = end-1; i >= start; i -= down) #define down_iter(...) pp_cat(down_iter, pp_narg(__VA_ARGS__))(__VA_ARGS__) #define viter viter_iter , #define viter_iter(i, v) auto tmpitr=v.begin(); for (auto i=*tmpitr; tmpitr != v.end(); tmpitr++) // debug macros #define debug_var_elem(v) << #v << "=" << v << " " #ifdef DEBUG #define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl #define debug_var(...) cout << "L" << __LINE__ << ": " pp_foreach(debug_var_elem, __VA_ARGS__) << endl #define debug_ary(ary) cout << "L" << __LINE__ << " [ "; for(auto ele : ary) cout << ele << " "; cout << "]" << endl; #define debug_time(...) {auto start = clock(); __VA_ARGS__ ;auto end = clock();cout << (double)(end - start) << "ms" << endl;} #else #define debug_echo(e) #define debug_var(...) #define debug_ary(ary) #define debug_time(...) #endif // short names typedef long long ll; #define down_queue(...) priority_queue<__VA_ARGS__> #define up_queue(...) priority_queue<__VA_ARGS__, vector<__VA_ARGS__>, greater<__VA_ARGS__>> #define all(x) x.begin(), x.end() #define rall(x) x.begin(), x.end(), greater<int>() #define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++) #define digit(x) ((int)log10((double)(x)) + 1) #define mp(...) make_pair(__VA_ARGS__) #define pb(...) push_back(__VA_ARGS__) #define pf(...) push_front(__VA_ARGS__) vector<int> digit_split(int n){vector<int> result(digit(n));for(int i = 0; n; i++){result[i] = n % 10;n /= 10;}return result;} #define vec_cpy(to,from) copy(all(to),back_inserter(from)) #define ary_cpy(to,from) memcpy(to, from, sizeof(from)) #define MOD 1000000007 // math bool is_prime(ll n){switch(n){case 0:case 1: return false;case 2: return true;}if(n % 2 == 0) return false;for(ll i=3;i * i <= n; i += 2)if(n%i == 0) return false;return true;} // pp unionfind #define pp_gen_field(list) pp_gen_field1 list #define pp_gen_field1(name, val) decltype(val) name; #define pp_gen_init(list) pp_gen_init1 list #define pp_gen_init1(name, val) ,val #define pp_gen_find_set_wrap(ufnodename) ufnodename pp_gen_find_set #define pp_gen_find_set(list) pp_gen_find_set1 list #define pp_gen_find_set1(name, val) \ find_set_ ## name(int x, decltype(val) v) { \ if (nodes[x].parent == x) { \ nodes[x].name = v; \ return nodes[x]; \ } else { \ return nodes[x] = find_set_ ## name(nodes[x].parent, v); \ } \ } #define pp_gen_unite_set(list) pp_gen_unite_set1 list #define pp_gen_unite_set1(name, val) \ if (nodes[x].name == val) { \ find_set_ ## name(x, find(y).name); \ } \ if (nodes[y].name == val) { \ find_set_ ## name(y, find(x).name); \ } #define def_unionfind(ufname, ufnodename, ...) \ struct ufnodename { \ int parent; \ pp_foreach(pp_gen_field, __VA_ARGS__) \ }; \ struct ufname { \ vector<ufnodename> nodes; \ vector<int> rank; \ ufname(int n) : nodes(n+1), rank(n+1) { \ rep (i in n) { \ nodes[i] = ufnodename{i pp_foreach(pp_gen_init, __VA_ARGS__)}; \ rank[i] = 0; \ } \ } \ ufnodename find(int x) { \ if (nodes[x].parent == x) { \ return nodes[x]; \ } else { \ return nodes[x] = find(nodes[x].parent); \ } \ } \ pp_foreach(pp_gen_find_set_wrap(ufnodename), __VA_ARGS__) \ void unite(int x, int y) { \ x = find(x).parent; \ y = find(y).parent; \ if (x == y) return; \ if (rank[x] < rank[y]) { \ pp_foreach(pp_gen_unite_set, __VA_ARGS__); \ nodes[x].parent = y; \ } else { \ pp_foreach(pp_gen_unite_set, __VA_ARGS__); \ nodes[y].parent = x; \ if (rank[x] == rank[y]) rank[x]++; \ } \ } \ bool same(int x, int y) { \ return find(x).parent == find(y).parent; \ } \ } pair<ll,ll> gcd(ll a, ll b){ ll n = 0; while(b){ debug_var(a,b); ll tmp = a % b; a = b; b = tmp; n++; } return mp(a,n); } int main(){ ll a,b; while(true){ cin >> a >> b; if(a + b == 0) return 0; pair<int,int> r = gcd(a,b); cout << r.first << " " << r.second << endl; } return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s823622416
p00197
C
#include <stdio.h> int main(void) { int a1, a2, x, y; int amari,i=0; scanf("%d %d", &a1, &a2); //1. 2number if(a1==0 && a2==0)break; if(a1<a2){ x = a2; y = a1; } for(i=0;amari =! 0;i++){ amari = x % y; x = y; y = amari; } printf("%d %d\n", x, i); return 0; }
main.c: In function 'main': main.c:6:27: error: break statement not within loop or switch 6 | if(a1==0 && a2==0)break; | ^~~~~
s552245701
p00197
C
#include <stdio.h> int main(void) { int a1, a2, x, y; int amari,i=0; scanf("%d %d", &a1, &a2); //1. 2number if(a1==0 && a2==0) break; if(a1<a2){ x = a2; y = a1; } for(i=0;amari =! 0;i++){ amari = x % y; x = y; y = amari; } printf("%d %d\n", x, i); return 0; }
main.c: In function 'main': main.c:6:28: error: break statement not within loop or switch 6 | if(a1==0 && a2==0) break; | ^~~~~
s967329535
p00197
C
#include <stdio.h> int main(void) { int x,y,i=0,a,amari; while (scanf("%d%d",&x,&y)!=EOF&&(x!=0||y!=0)) { if (x<y) { a=x; x=y; y=a; } while (y!=0) { x%=y; amari=x; x=y; y=amari; count++; } printf("%d %d\n",x,i); } return 0; }
main.c: In function 'main': main.c:15:13: error: 'count' undeclared (first use in this function) 15 | count++; | ^~~~~ main.c:15:13: note: each undeclared identifier is reported only once for each function it appears in
s782701936
p00197
C
#include <stdio.h> int main(void) { int x,y,a,amari; while (scanf("%d%d",&x,&y)!=EOF&&(x!=0||y!=0)) { if (x<y) { a=x; x=y; y=a; } i = 0; while (y!=0) { x%=y; amari=x; x=y; y=amari; i++; } printf("%d %d\n",x,i); } return 0; }
main.c: In function 'main': main.c:10:9: error: 'i' undeclared (first use in this function) 10 | i = 0; | ^ main.c:10:9: note: each undeclared identifier is reported only once for each function it appears in
s952876974
p00197
C
#include <stdio.h> int main(void) { int x,y,a,amari; while (scanf("%d%d",&x,&y)!=EOF&&(x!=0||y!=0)) { if (x<y) { a=x; x=y; y=a; } i = 0; while (y!=0) { x%=y; amari=x; x=y; y=amari; i++; } printf("%d %d\n",x,i); } return 0; }
main.c: In function 'main': main.c:10:9: error: 'i' undeclared (first use in this function) 10 | i = 0; | ^ main.c:10:9: note: each undeclared identifier is reported only once for each function it appears in
s635433180
p00197
C
#include <stdio.h> int main(void) { int x,y,a,amari; while (scanf("%d%d",&x,&y)!=EOF&&(x!=0||y!=0)) { if (x<y) { a=x; x=y; y=a; } i = 0; while (y!=0) { amari = x % y; x = y; y = amari; i++; } printf("%d %d\n",x,i); } return 0; }
main.c: In function 'main': main.c:10:9: error: 'i' undeclared (first use in this function) 10 | i = 0; | ^ main.c:10:9: note: each undeclared identifier is reported only once for each function it appears in
s593017091
p00197
C
#include <stdio.h> int main(void){ int i,l,a,x,b,amari,num; for(i = 0; i <1000; i++){ scanf("%d %d", &a, &b); if(a == 0 && b == 0) break; if(a < b){ //chage a = y; y = x; x = a; } num = 0; for(l = 0; b != 0; l++){ //keisan amari = a%b; a = b; b = amari; num++; } printf("%d %d\n", x, num); } return 0; }
main.c: In function 'main': main.c:8:11: error: 'y' undeclared (first use in this function) 8 | a = y; | ^ main.c:8:11: note: each undeclared identifier is reported only once for each function it appears in
s020100465
p00197
C
#include <stdio.h> int main(void){ int i,j,a,x,b,amari,num; for(i = 0; i <1000; i++){ scanf("%d %d", &a, &b); if(a == 0 && b == 0) break; if(a < b){ //chage a = y; y = x; x = a; } num = 0; for(j = 0; y != 0; j++){ //keisan amari = a%b; x = y; y = amari; j++; } printf("%d %d\n", x, num); } return 0; }
main.c: In function 'main': main.c:8:11: error: 'y' undeclared (first use in this function) 8 | a = y; | ^ main.c:8:11: note: each undeclared identifier is reported only once for each function it appears in
s760380775
p00197
C
#include <stdio.h> int main(void){ int i,j,a,x,b,amari,num; for(i = 0; i <1000; i++){ scanf("%d %d", &a, &b); if(a == 0 && b == 0) break; if(a < b){ a = y; y = x; x = a; } num = 0; for(j = 0; y != 0; j++){ amari = a%b; x = y; y = amari; j++; } printf("%d %d\n", x, num); } return 0; }
main.c: In function 'main': main.c:8:11: error: 'y' undeclared (first use in this function) 8 | a = y; | ^ main.c:8:11: note: each undeclared identifier is reported only once for each function it appears in
s214696183
p00197
C
#include <stdio.h> int main(void){ int i,j,a,x,b,amari,num; for(i = 0; i <1000; i++){ scanf("%d %d", &a, &b); if(x == 0 && y == 0) break; if(a < b){ a = y; y = x; x = a; } num = 0; for(j = 0; y != 0; j++){ amari = a%b; x = y; y = amari; j++; } printf("%d %d\n", x, num); } return 0; }
main.c: In function 'main': main.c:6:20: error: 'y' undeclared (first use in this function) 6 | if(x == 0 && y == 0) break; | ^ main.c:6:20: note: each undeclared identifier is reported only once for each function it appears in
s864617016
p00197
C
#include <stdio.h> int main(void){ int i,j,a,x,b,amari,num; for(i = 0; i <1000; i++){ scanf("%d %d", &x, &y); if(x == 0 && y == 0) break; if(a < b){ a = y; y = x; x = a; } num = 0; for(j = 0; y != 0; j++){ amari = a%b; x = y; y = amari; j++; } printf("%d %d\n", x, num); } return 0; }
main.c: In function 'main': main.c:5:27: error: 'y' undeclared (first use in this function) 5 | scanf("%d %d", &x, &y); | ^ main.c:5:27: note: each undeclared identifier is reported only once for each function it appears in
s254779756
p00197
C
#include <stdio.h> int main(void){ int i,j,a,x,y,amari,num; for(i = 0; i <1000; i++){ scanf("%d %d", &x, &y); if(x == 0 && y == 0) break; if(a < b){ a = y; y = x; x = a; } num = 0; for(j = 0; y != 0; j++){ amari = a%b; x = y; y = amari; j++; } printf("%d %d\n", x, num); } return 0; }
main.c: In function 'main': main.c:7:14: error: 'b' undeclared (first use in this function) 7 | if(a < b){ | ^ main.c:7:14: note: each undeclared identifier is reported only once for each function it appears in
s309946238
p00197
C
#include <stdio.h> int main(void){ int i,j,a,x,y,amari,num; for(i = 0; i <1000; i++){ scanf("%d %d", &x, &y); if(x == 0 && y == 0) break; if(x < y){ a = y; y = x; x = a; } num = 0; for(j = 0; y != 0; j++){ amari = a%b; x = y; y = amari; j++; } printf("%d %d\n", x, num); } return 0; }
main.c: In function 'main': main.c:14:17: error: 'b' undeclared (first use in this function) 14 | amari = a%b; | ^ main.c:14:17: note: each undeclared identifier is reported only once for each function it appears in
s498534679
p00197
C
#include<stdio.h> int main(void) { int a,b,r,tmp; scanf("%d",&a); scanf("%d",%b); if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } printf("最大公約数 = %d\n", b); return 0; }
main.c: In function 'main': main.c:6:13: error: expected expression before '%' token 6 | scanf("%d",%b); | ^
s823203514
p00197
C
#include<stdio.h> int main(void) { int a,b,r,tmp; scanf("%d",&a); scanf("%d",%b); if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } printf("最大公約数 = %d\n", b); return 0; }
main.c: In function 'main': main.c:6:13: error: expected expression before '%' token 6 | scanf("%d",%b); | ^
s974385115
p00197
C
#include<stdio.h> int main(void) { int a,b,r,tmp; printf("1つ目の自然数 = \n"); scanf("%d",&a); printf("2つ目の自然数 = \n"); scanf("%d",%b); if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } printf("最大公約数 = %d\n", b); return 0; }
main.c: In function 'main': main.c:8:13: error: expected expression before '%' token 8 | scanf("%d",%b); | ^
s450349447
p00197
C
#include<stdio.h> int main(void) { int a,b,r,tmp; printf("1つ目の自然数 = \n"); scanf("%d",&a); printf("2つ目の自然数 = \n"); scanf("%d",%b); if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } printf("最大公約数 = %d\n", b); return 0; }
main.c: In function 'main': main.c:8:13: error: expected expression before '%' token 8 | scanf("%d",%b); | ^
s417885940
p00197
C
#include<stdio.h> int main() { int a,b,r,tmp; printf("1つ目の自然数 = \n"); scanf("%d",&a); printf("2つ目の自然数 = \n"); scanf("%d",%b); if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } printf("最大公約数 = %d\n", b); return 0; }
main.c: In function 'main': main.c:8:13: error: expected expression before '%' token 8 | scanf("%d",%b); | ^
s795019319
p00197
C
#include<stdio.h> int main(void) { int a,b,r,tmp; scanf("%d",&a); scanf("%d",%b); printf("%d %d\n",a,b) if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } printf("%d\n", b); return 0; }
main.c: In function 'main': main.c:6:13: error: expected expression before '%' token 6 | scanf("%d",%b); | ^ main.c:7:23: error: expected ';' before 'if' 7 | printf("%d %d\n",a,b) | ^ | ; 8 | if(a<b){ | ~~
s765629894
p00197
C
#include<stdio.h> int main(void) { int a,b,r,tmp; scanf("%d",&a); scanf("%d",&b); printf("%d %d\n",a,b) if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } printf("%d\n", b); return 0; }
main.c: In function 'main': main.c:7:23: error: expected ';' before 'if' 7 | printf("%d %d\n",a,b) | ^ | ; 8 | if(a<b){ | ~~
s460879754
p00197
C
#include <stdio.h> int main(void) { int=a,b,c,r,tmp; scanf("%d %d",&a,&b); c=a*b; if(a<b){ tmp = a; a = b; b = tmp; } r=a%b; while(r!=0) { a=b; b=r; r=a%b; } printf("%d %d",b,a); return 0; }
main.c: In function 'main': main.c:4:4: error: expected identifier or '(' before '=' token 4 | int=a,b,c,r,tmp; | ^ main.c:5:16: error: 'a' undeclared (first use in this function) 5 | scanf("%d %d",&a,&b); | ^ main.c:5:16: note: each undeclared identifier is reported only once for each function it appears in main.c:5:19: error: 'b' undeclared (first use in this function) 5 | scanf("%d %d",&a,&b); | ^ main.c:7:1: error: 'c' undeclared (first use in this function) 7 | c=a*b; | ^ main.c:10:5: error: 'tmp' undeclared (first use in this function) 10 | tmp = a; | ^~~ main.c:15:1: error: 'r' undeclared (first use in this function) 15 | r=a%b; | ^
s715806356
p00197
C
#include <stdio.h> #include <stdlib.h> // ユークリッドの互除法を利用した、最大公約数を求める関数 int gcd(int a, int b) { int c; if (a < b) { a+=b; b=a-b; a-=b; } while (b != 0) { c = a % b; a = b; b = c;   count++; } return a; } int main(void) { int a, b; scanf("%d %d", &a, &b); if (a <= 0 || b <= 0) { exit(EXIT_FAILURE ); } printf("%d %d\n", gcd(a, b),count); return EXIT_SUCCESS; }
main.c: In function 'gcd': main.c:17:1: error: stray '\343' in program 17 | <U+3000><U+3000>count++; | ^~~~~~~~ main.c:17:3: error: stray '\343' in program 17 | <U+3000><U+3000>count++; | ^~~~~~~~ main.c:17:5: error: 'count' undeclared (first use in this function) 17 |   count++; | ^~~~~ main.c:17:5: note: each undeclared identifier is reported only once for each function it appears in main.c: In function 'main': main.c:33:34: error: 'count' undeclared (first use in this function) 33 | printf("%d %d\n", gcd(a, b),count); | ^~~~~
s485934642
p00197
C
#include <stdio.h> #include <stdlib.h> // ユークリッドの互除法を利用した、最大公約数を求める関数 int gcd(int a, int b) { int c,count; if (a < b) { a+=b; b=a-b; a-=b; } while (b != 0) { c = a % b; a = b; b = c;   count++; } return a; } int main(void) { int a, b; scanf("%d %d", &a, &b); if (a <= 0 || b <= 0) { exit(EXIT_FAILURE ); } printf("%d %d\n", gcd(a, b),count); return EXIT_SUCCESS; }
main.c: In function 'gcd': main.c:17:1: error: stray '\343' in program 17 | <U+3000><U+3000>count++; | ^~~~~~~~ main.c:17:3: error: stray '\343' in program 17 | <U+3000><U+3000>count++; | ^~~~~~~~ main.c: In function 'main': main.c:33:34: error: 'count' undeclared (first use in this function) 33 | printf("%d %d\n", gcd(a, b),count); | ^~~~~ main.c:33:34: note: each undeclared identifier is reported only once for each function it appears in
s117363772
p00197
C
#include <stdio.h> #include <stdlib.h> // ユークリッドの互除法を利用した、最大公約数を求める関数 int gcd(int a, int b) { int c,count; if (a < b) { a+=b; b=a-b; a-=b; } while (b != 0) { c = a % b; a = b; b = c;   count+=; } return a; } int main(void) { int a, b; scanf("%d %d", &a, &b); if (a <= 0 || b <= 0) { exit(EXIT_FAILURE ); } printf("%d %d\n", gcd(a, b),count); return EXIT_SUCCESS; }
main.c: In function 'gcd': main.c:17:1: error: stray '\343' in program 17 | <U+3000><U+3000>count+=; | ^~~~~~~~ main.c:17:3: error: stray '\343' in program 17 | <U+3000><U+3000>count+=; | ^~~~~~~~ main.c:17:12: error: expected expression before ';' token 17 |   count+=; | ^ main.c: In function 'main': main.c:33:34: error: 'count' undeclared (first use in this function) 33 | printf("%d %d\n", gcd(a, b),count); | ^~~~~ main.c:33:34: note: each undeclared identifier is reported only once for each function it appears in
s124633138
p00197
C
#include<stdio.h> int main(void) { int a,b,r,tmp; scanf("%d",&a); scanf("%d",&b); printf("%d %d\n",a,b) if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } printf("%d\n", b); return 0; }
main.c: In function 'main': main.c:7:23: error: expected ';' before 'if' 7 | printf("%d %d\n",a,b) | ^ | ; 8 | if(a<b){ | ~~
s389632302
p00197
C
#include <iostream> #include <cstdio> using namespace std; int gcd(int a, int b) { int r; while((r = a % b) != 0) { a = b; b = r; } return b; } int main(void){ int a, b, tmp; if (a < b){ tmp = b; b = a; a = tmp; } while(cin >> a >> b) { int lcm = a * b / gcd(a,b); cout << gcd(a,b) << " " << lcm << endl; } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s814956197
p00197
C
#include <iostream> #include <cstdio> using namespace std; int gcd(float a, float b) { float r; while((r = a % b) != 0) { a = b; b = r; } return b; } int main(void){ float a, b, tmp; if (a < b){ tmp = b; b = a; a = tmp; } while(cin >> a >> b) { int lcm = a * b / gcd(a,b); cout << gcd(a,b) << " " << lcm << endl; } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s294775792
p00197
C
#include <iostream> #include <cstdio> using namespace std; int counter; int gcd(int a, int b){ if (b == 0) return a; counter++; return gcd(b, a%b); } int main(void){ int a, b; while(cin>>a>>b){ if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0;}
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s146548035
p00197
C
#include<stdio.h> #define SWAP(type,a,b)do{ type temp=a; a=b;b=temp; } while(0) int main(){ int a,b,i,cnt; while(1){ scanf("%d %d",&a,&b); if(a==0&&b==0) return 0; if(a<b)SWAP(int,a,b); cnt=0; while(b!=0){ a%=b; SWAP(int,a,b); cnt++; } printf("%d %d\n",a,cnt); } }
main.c:4:8: error: no macro name given in #define directive 4 | #define | ^ main.c:5:2: error: return type defaults to 'int' [-Wimplicit-int] 5 | SWAP(type,a,b)do{ | ^~~~ main.c: In function 'SWAP': main.c:5:16: error: expected declaration specifiers before 'do' 5 | SWAP(type,a,b)do{ | ^~ main.c:9:1: error: expected declaration specifiers before 'while' 9 | while(0) | ^~~~~ main.c:5:2: error: type of 'type' defaults to 'int' [-Wimplicit-int] 5 | SWAP(type,a,b)do{ | ^~~~ main.c:5:2: error: type of 'a' defaults to 'int' [-Wimplicit-int] main.c:5:2: error: type of 'b' defaults to 'int' [-Wimplicit-int] main.c:34: error: expected '{' at end of input
s791154629
p00197
C
#include<stdio.h> #define SWAP(type,a,b)do{type temp=a;a=b;b=temp;}while(0) int main(){ int a,b,i,cnt; while(1){ scanf("%d %d",&a,&b); if(a==0&&b==0) return 0; if(a<b)SWAP(int,a,b); cnt=0; while(b!=0){ a%=b; SWAP(int,a,b); cnt++; } printf("%d %d\n",a,cnt); } }
main.c:1:19: warning: extra tokens at end of #include directive 1 | #include<stdio.h> #define SWAP(type,a,b)do{type temp=a;a=b;b=temp;}while(0) int main(){ int a,b,i,cnt; while(1){ scanf("%d %d",&a,&b); if(a==0&&b==0) return 0; if(a<b)SWAP(int,a,b); cnt=0; while(b!=0){ a%=b; SWAP(int,a,b); cnt++; } printf("%d %d\n",a,cnt); } } | ^ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s009740924
p00197
C
#include <stdio.h> int main(void) { int a, b, c, i; while(1){ scanf("%d %d", &a, &b); if(a == 0 && b == 0) break; if(a < b){ c = b; b = a; a = c; } for(i = 0; i++){ a = a % b; c = a; a = b; b = c; if(b == 0) break; } printf("%d %d\n", a, i+1); } return 0; }
main.c: In function 'main': main.c:16:23: error: expected ';' before ')' token 16 | for(i = 0; i++){ | ^ | ;
s153035196
p00197
C
R(x,y,c){y?R(y,x%y,c-1):x&&printf("%d %d\n",x,-c);}main(x,y){for(;~scanf("%d%d",&x,&y);)R(x,y,x<y);
main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int] 1 | R(x,y,c){y?R(y,x%y,c-1):x&&printf("%d %d\n",x,-c);}main(x,y){for(;~scanf("%d%d",&x,&y);)R(x,y,x<y); | ^ main.c: In function 'R': main.c:1:1: error: type of 'x' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'y' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:28: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | R(x,y,c){y?R(y,x%y,c-1):x&&printf("%d %d\n",x,-c);}main(x,y){for(;~scanf("%d%d",&x,&y);)R(x,y,x<y); | ^~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf' +++ |+#include <stdio.h> 1 | R(x,y,c){y?R(y,x%y,c-1):x&&printf("%d %d\n",x,-c);}main(x,y){for(;~scanf("%d%d",&x,&y);)R(x,y,x<y); main.c:1:28: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 1 | R(x,y,c){y?R(y,x%y,c-1):x&&printf("%d %d\n",x,-c);}main(x,y){for(;~scanf("%d%d",&x,&y);)R(x,y,x<y); | ^~~~~~ main.c:1:28: note: include '<stdio.h>' or provide a declaration of 'printf' main.c: At top level: main.c:1:52: error: return type defaults to 'int' [-Wimplicit-int] 1 | R(x,y,c){y?R(y,x%y,c-1):x&&printf("%d %d\n",x,-c);}main(x,y){for(;~scanf("%d%d",&x,&y);)R(x,y,x<y); | ^~~~ main.c: In function 'main': main.c:1:52: error: type of 'x' defaults to 'int' [-Wimplicit-int] main.c:1:52: error: type of 'y' defaults to 'int' [-Wimplicit-int] main.c:1:68: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | R(x,y,c){y?R(y,x%y,c-1):x&&printf("%d %d\n",x,-c);}main(x,y){for(;~scanf("%d%d",&x,&y);)R(x,y,x<y); | ^~~~~ main.c:1:68: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:68: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] main.c:1:68: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:1: error: expected declaration or statement at end of input 1 | R(x,y,c){y?R(y,x%y,c-1):x&&printf("%d %d\n",x,-c);}main(x,y){for(;~scanf("%d%d",&x,&y);)R(x,y,x<y); | ^
s230210469
p00197
C
#include<stdio.h> int main(void){ int i,tmp,x,y,step=0; for(j=0;;j++){ scanf("%d %d",&x,&y); if(x==0&&y==0){ break; } for(i=0;;i++){ x=x%y; tmp=x; x=y; y=tmp; step++; if(y==0){ break; } } } printf("%d %d\n",x,step); return 0; }
main.c: In function 'main': main.c:6:13: error: 'j' undeclared (first use in this function) 6 | for(j=0;;j++){ | ^ main.c:6:13: note: each undeclared identifier is reported only once for each function it appears in
s257787453
p00197
C++
#include<iostream> using namespace std; int main() { int a, b,r, kouyaku[1001], kazu[1001],kaisuu,s; kaisuu = 0; while (1) { cin >> a >> b; if (a == 0&&b == 0) { goto a; } kaisuu = kaisuu + 1; s = 0; a:; for (int i = 1; i <= kaisuu; i++) { cout << kouyaku[i]<<" " << kazu[i] << endl; } }
a.cc: In function 'int main()': a.cc:18:2: error: expected '}' at end of input 18 | } | ^ a.cc:3:12: note: to match this '{' 3 | int main() { | ^
s047085431
p00197
C++
include<iostream> using namespace std; int main() { int a, b, r, kouyaku[1001], kazu[1001], kaisuu, s; kaisuu = 0; while (1) { cin >> a >> b; if (a == 0 && b == 0) { goto a; } kaisuu = kaisuu + 1; s = 0; } a:; for (int i = 1; i <= kaisuu; i++) { cout << kouyaku[i] << " " << kazu[i] << endl; } }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:7:17: error: 'cin' was not declared in this scope 7 | cin >> a >> b; | ^~~ a.cc:16:25: error: 'cout' was not declared in this scope 16 | cout << kouyaku[i] << " " << kazu[i] << endl; | ^~~~ a.cc:16:65: error: 'endl' was not declared in this scope 16 | cout << kouyaku[i] << " " << kazu[i] << endl; | ^~~~
s834385064
p00197
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b); } int main(){ int a,b; while(1){ cin>>a>>b; if(a==0&&b==0)break; cout<<gdc(a,b)<<endl; } }
a.cc: In function 'int main()': a.cc:13:23: error: 'gdc' was not declared in this scope; did you mean 'gcd'? 13 | cout<<gdc(a,b)<<endl; | ^~~ | gcd
s149319807
p00197
C++
#include<iostream> using namespace std; typedef long long int; int ct=0; int gcd(int a,int b){ ct++; if(a%b==0)return b; return gcd(b,a%b); } int main(){ int x,y; while(cin>>x>>y,x==0&&y==0){ if(x<y){ int tmp=x; x=y; y=tmp; } cout<<gcd(x,y)<<" "<<ct<<endl; ct=0; } return 0; }
a.cc:5:19: error: declaration does not declare anything [-fpermissive] 5 | typedef long long int; | ^~~
s048435295
p00197
C++
#include <cstdio> int ans = 0; int GCD(int a, int b){ if(b==0)return a; ans++; return GCD(b, a%b); } int main(){ int x,y; while(scanf("%d %d",&x, &y), x+y){ ans=0; if(x<y)std::swap(x,y); int gcd = GCD(x,y); printf("%d %d\n",gcd, ans); } }
a.cc: In function 'int main()': a.cc:13:29: error: 'swap' is not a member of 'std' 13 | if(x<y)std::swap(x,y); | ^~~~
s357830233
p00197
C++
#include <cstdio> int ans = 0; int GCD(int a, int b){ if(b==0)return a; ans++; return GCD(b, a%b); } int main(){ int x,y; while(scanf("%d %d",&x, &y), x+y){ ans=0; if(x<y)swap(x,y); int gcd = GCD(x,y); printf("%d %d\n",gcd, ans); } }
a.cc: In function 'int main()': a.cc:13:24: error: 'swap' was not declared in this scope 13 | if(x<y)swap(x,y); | ^~~~
s489499238
p00197
C++
#include <iostream> using namespace std; int gcd(int a, int b, int step); int main() { int a, b; while (cin >> a >> b, a){ gcd(a, b, 0); } return (0); } void gcd(int a, int b, int step) { if (b == 0){ cout << a << " " << step << endl; } else if (a < b){ return (gcd(a, b % a, step + 1)); } else { return (gcd(b, a % b, step + 1)); } }
a.cc:17:6: error: ambiguating new declaration of 'void gcd(int, int, int)' 17 | void gcd(int a, int b, int step) | ^~~ a.cc:4:5: note: old declaration 'int gcd(int, int, int)' 4 | int gcd(int a, int b, int step); | ^~~ a.cc: In function 'void gcd(int, int, int)': a.cc:23:20: error: return-statement with a value, in function returning 'void' [-fpermissive] 23 | return (gcd(a, b % a, step + 1)); | ~~~~^~~~~~~~~~~~~~~~~~~~~ a.cc:26:20: error: return-statement with a value, in function returning 'void' [-fpermissive] 26 | return (gcd(b, a % b, step + 1)); | ~~~~^~~~~~~~~~~~~~~~~~~~~
s909401141
p00197
C++
#include<stdio.h> int main(void) { int n,m,i,a; while(1){ scanf("%d %d",&n,&m); if(n==0&&m==0) break; a=0; if(n<m){ i=n; n=m; m=i; while(1){ i=n%m; n=m; m=i; a++; if(m==0) break; } printf("%d %d\n",n,a); } return 0; }
a.cc: In function 'int main()': a.cc:23:2: error: expected '}' at end of input 23 | } | ^ a.cc:3:1: note: to match this '{' 3 | { | ^
s730337074
p00197
C++
#include <iostream> #include <algorithm> using namespace std; int main(){ int x,y; while(cin>>x){ cin>>y; if(x==0&&y==0)break; int cnt=0; while(true){ if(y==0)break; x=x%y; swap(x,y); cnt++; } cout<<x<<" "<<cnt<<endl; } return 0; } }
a.cc:20:1: error: expected declaration before '}' token 20 | } | ^
s825822498
p00197
C++
#include <stdio.h> int main(void) { long a1, a2, x, y; int amari,i=0; scanf("%ld %ld", &a1, &a2); //1. 2number if(a1<a2){ x = a2; y = a1; } for(amari =! 0){ amari = x % y; x = y; y = amari; i++; } printf("%ld %ld\n", x, i); return 0; }
a.cc: In function 'int main()': a.cc:13:23: error: expected ';' before ')' token 13 | for(amari =! 0){ | ^ | ; a.cc:23:9: error: expected primary-expression before 'return' 23 | return 0; | ^~~~~~ a.cc:21:35: error: expected ')' before 'return' 21 | printf("%ld %ld\n", x, i); | ^ | ) 22 | 23 | return 0; | ~~~~~~ a.cc:13:12: note: to match this '(' 13 | for(amari =! 0){ | ^
s115997066
p00197
C++
#include <stdio.h> int main(void) { long a1, a2, x, y; int amari,i=0; scanf("%ld %ld", &a1, &a2); //1. 2number if(m==0 && n==0)break; if(a1<a2){ x = a2; y = a1; } for(amari =! 0){ amari = x % y; x = y; y = amari; i++; } printf("%ld %ld\n", x, i); return 0; }
a.cc: In function 'int main()': a.cc:6:12: error: 'm' was not declared in this scope 6 | if(m==0 && n==0)break; | ^ a.cc:6:20: error: 'n' was not declared in this scope 6 | if(m==0 && n==0)break; | ^ a.cc:6:25: error: break statement not within loop or switch 6 | if(m==0 && n==0)break; | ^~~~~ a.cc:13:23: error: expected ';' before ')' token 13 | for(amari =! 0){ | ^ | ; a.cc:23:9: error: expected primary-expression before 'return' 23 | return 0; | ^~~~~~ a.cc:21:35: error: expected ')' before 'return' 21 | printf("%ld %ld\n", x, i); | ^ | ) 22 | 23 | return 0; | ~~~~~~ a.cc:13:12: note: to match this '(' 13 | for(amari =! 0){ | ^
s813153544
p00197
C++
#include <stdio.h> int main(void) { long a1, a2, x, y; int amari,i=0; scanf("%ld %ld", &a1, &a2); //1. 2number if(m==0 && n==0)break; if(a1<a2){ x = a2; y = a1; } while(amari =! 0){ amari = x % y; x = y; y = amari; i++; } printf("%ld %ld\n", x, i); return 0; }
a.cc: In function 'int main()': a.cc:6:12: error: 'm' was not declared in this scope 6 | if(m==0 && n==0)break; | ^ a.cc:6:20: error: 'n' was not declared in this scope 6 | if(m==0 && n==0)break; | ^ a.cc:6:25: error: break statement not within loop or switch 6 | if(m==0 && n==0)break; | ^~~~~
s694552357
p00197
C++
#include <stdio.h> int main(void) { long a1, a2, x, y; int amari,i=0; scanf("%ld %ld", &a1, &a2); //1. 2number if(a1==0 && a2==0)break; if(a1<a2){ x = a2; y = a1; } while(amari =! 0){ amari = x % y; x = y; y = amari; i++; } printf("%ld %ld\n", x, i); return 0; }
a.cc: In function 'int main()': a.cc:6:27: error: break statement not within loop or switch 6 | if(a1==0 && a2==0)break; | ^~~~~
s562898343
p00197
C++
#include<bits/stdc++.h> using namespace std; int main() {  int x,y,num;  while(cin>>x>>y,x&&y){   if(x<y)swap(x,y);   for(int i=1;;i++){    num=x%y;    x=y;    y=num;    if(!num){     cout<<x<<" "<<i<<endl;     break;    }   }  } }
a.cc:5:1: error: extended character   is not valid in an identifier 5 |  int x,y,num; | ^ a.cc:6:1: error: extended character   is not valid in an identifier 6 |  while(cin>>x>>y,x&&y){ | ^ a.cc:7:1: error: extended character   is not valid in an identifier 7 |   if(x<y)swap(x,y); | ^ a.cc:7:1: error: extended character   is not valid in an identifier a.cc:8:1: error: extended character   is not valid in an identifier 8 |   for(int i=1;;i++){ | ^ a.cc:8:1: error: extended character   is not valid in an identifier a.cc:9:1: error: extended character   is not valid in an identifier 9 |    num=x%y; | ^ a.cc:9:1: error: extended character   is not valid in an identifier a.cc:9:1: error: extended character   is not valid in an identifier a.cc:10:1: error: extended character   is not valid in an identifier 10 |    x=y; | ^ a.cc:10:1: error: extended character   is not valid in an identifier a.cc:10:1: error: extended character   is not valid in an identifier a.cc:11:1: error: extended character   is not valid in an identifier 11 |    y=num; | ^ a.cc:11:1: error: extended character   is not valid in an identifier a.cc:11:1: error: extended character   is not valid in an identifier a.cc:12:1: error: extended character   is not valid in an identifier 12 |    if(!num){ | ^ a.cc:12:1: error: extended character   is not valid in an identifier a.cc:12:1: error: extended character   is not valid in an identifier a.cc:13:1: error: extended character   is not valid in an identifier 13 |     cout<<x<<" "<<i<<endl; | ^ a.cc:13:1: error: extended character   is not valid in an identifier a.cc:13:1: error: extended character   is not valid in an identifier a.cc:13:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier 14 |     break; | ^ a.cc:14:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier a.cc:14:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier 15 |    } | ^ a.cc:15:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier a.cc:16:1: error: extended character   is not valid in an identifier 16 |   } | ^ a.cc:16:1: error: extended character   is not valid in an identifier a.cc:17:1: error: extended character   is not valid in an identifier 17 |  } | ^ a.cc: In function 'int main()': a.cc:5:1: error: '\U00003000int' was not declared in this scope 5 |  int x,y,num; | ^~~~~ a.cc:6:14: error: 'x' was not declared in this scope 6 |  while(cin>>x>>y,x&&y){ | ^ a.cc:6:17: error: 'y' was not declared in this scope; did you mean 'yn'? 6 |  while(cin>>x>>y,x&&y){ | ^ | yn a.cc:6:1: error: '\U00003000while' was not declared in this scope 6 |  while(cin>>x>>y,x&&y){ | ^~~~~~~
s371727058
p00197
C++
#include <iostream> using namespace std; int counter; int gcd(int a, int b){ if (b == 0) return a; counter++; else return gcd(b, a%b); } int main(void){ int a, b; while(cin>>a>>b){ if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0; }
a.cc: In function 'int gcd(int, int)': a.cc:10:8: error: 'else' without a previous 'if' 10 | else return gcd(b, a%b); | ^~~~
s844315383
p00197
C++
#include <iostream> #include <cstdio> using namespace std; int gcd(int a, int b){ if (b == 0) return a; else return gcd(b, a%b) counter++; } int main(void){ int counter; int a, b; while(cin>>a>>b){ if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0; }
a.cc: In function 'int gcd(int, int)': a.cc:7:31: error: expected ';' before 'counter' 7 | else return gcd(b, a%b) | ^ | ; 8 | counter++; | ~~~~~~~ a.cc:8:8: error: 'counter' was not declared in this scope 8 | counter++; | ^~~~~~~
s565926888
p00197
C++
#include <iostream> #include <cstdio> using namespace std; int gcd(int a, int b){ if (b == 0) return a; else return gcd(b, a%b); counter++; } int main(void){ int counter; int a, b; while(cin>>a>>b){ if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0; }
a.cc: In function 'int gcd(int, int)': a.cc:8:8: error: 'counter' was not declared in this scope 8 | counter++; | ^~~~~~~
s235105078
p00197
C++
#include <iostream> #include <cstdio> using namespace std; int counter; int gcd(int a, int b){ if (b == 0) return a; else return gcd(b, a%b); counter++; } int main(void){ int a, b; while(cin>>a>>b){ if(a < b){ x = a; a = b; b = x; } if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:12: error: 'x' was not declared in this scope 17 | x = a; | ^
s914250255
p00197
C++
#include <iostream> #include <cstdio> using namespace std; int gcd(int a, int b){ if (b == 0) return a; else return gcd(b, a%b); counter++; } int main(void){ int a, b, counter; while(cin>>a>>b){ if(a < b){ x = a; a = b; b = x; } if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0; }
a.cc: In function 'int gcd(int, int)': a.cc:7:8: error: 'counter' was not declared in this scope 7 | counter++; | ^~~~~~~ a.cc: In function 'int main()': a.cc:14:12: error: 'x' was not declared in this scope 14 | x = a; | ^
s777967109
p00197
C++
#include <iostream> using namespace std; int gcd(int a, int b){ if (b == 0) return a; else return gcd(b, a%b); counter++; } int main(void){ int a, b, counter; while(cin>>a>>b){ if(a < b){ x = a; a = b; b = x; } if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0; }
a.cc: In function 'int gcd(int, int)': a.cc:6:8: error: 'counter' was not declared in this scope 6 | counter++; | ^~~~~~~ a.cc: In function 'int main()': a.cc:13:12: error: 'x' was not declared in this scope 13 | x = a; | ^
s240001301
p00197
C++
#include <iostream> using namespace std; int gcd(int a, int b){ if (b == 0) return a; else return gcd(b, a%b); counter++; } int main(void){ int a, b, counter; while(cin>>a>>b){ if(a < b){ x = a; a = b; b = x; } if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0; }
a.cc: In function 'int gcd(int, int)': a.cc:6:8: error: 'counter' was not declared in this scope 6 | counter++; | ^~~~~~~ a.cc: In function 'int main()': a.cc:13:12: error: 'x' was not declared in this scope 13 | x = a; | ^
s839422706
p00197
C++
#include <iostream> using namespace std; int counter; int gcd(int a, int b){ if (b == 0) return a; else return gcd(b, a%b); counter++; } int main(void){ int a, b, counter; while(cin>>a>>b){ if(a < b){ x = a; a = b; b = x; } if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<" "<<counter<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:12: error: 'x' was not declared in this scope 14 | x = a; | ^
s272341875
p00197
C++
#include <iostream> #include <cstdio>using namespace std; int counter; int gcd(int a, int b) { if (b == 0) return a; counter++; return gcd(b, a%b); } int main(void){ int a, b, x; while(cin>>a>>b){ if(a < b){ x = a; a = b; b = x; } if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<' ’; cout<<counter<<endl; } return 0;
a.cc:2:24: warning: extra tokens at end of #include directive 2 | #include <cstdio>using namespace std; | ^~~~~~~~~ a.cc:2:10: fatal error: cstdio>usin: No such file or directory 2 | #include <cstdio>using namespace std; | ^~~~~~~~~~~~~ compilation terminated.
s585850342
p00197
C++
#include <iostream> #include <cstdio>using namespace std; int counter; int gcd(int a, int b) { if (b == 0) return a; counter++; return gcd(b, a%b); } int main(void){ int a, b, x; while(cin>>a>>b){ if(a < b){ x = a; a = b; b = x; } if(a == 0 && b == 0) return 0; counter = 0; cout<<gcd(a,b)<<' ’; cout<<counter<<endl; } return 0;
a.cc:2:24: warning: extra tokens at end of #include directive 2 | #include <cstdio>using namespace std; | ^~~~~~~~~ a.cc:2:10: fatal error: cstdio>usin: No such file or directory 2 | #include <cstdio>using namespace std; | ^~~~~~~~~~~~~ compilation terminated.
s630586034
p00197
C++
#include <bits/stdc++.h> using namespace std; int count = 0; int gcd(int x,int y){ count++; if(y == 0)return x; gcd(y,x%y); } int main(){ while(1){ int x,y; cin >> x >> y; if(x == 0 && y == 0)break; cout << gcd(x,y) << " " << count << endl; } return 0; }
a.cc: In function 'int gcd(int, int)': a.cc:8:3: error: reference to 'count' is ambiguous 8 | count++; | ^~~~~ In file included from /usr/include/c++/14/algorithm:86, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)' 4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) | ^~~~~ a.cc:5:5: note: 'int count' 5 | int count = 0; | ^~~~~ a.cc: In function 'int main()': a.cc:20:30: error: reference to 'count' is ambiguous 20 | cout << gcd(x,y) << " " << count << endl; | ^~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ /usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)' 4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) | ^~~~~ a.cc:5:5: note: 'int count' 5 | int count = 0; | ^~~~~ a.cc: In function 'int gcd(int, int)': a.cc:10:6: warning: control reaches end of non-void function [-Wreturn-type] 10 | gcd(y,x%y); | ~~~^~~~~~~
s694323932
p00197
C++
#include<bits/stdc++.h> using namespace std; int main(){ while(1){ int a,b,c; cin>>a>>b; if(a==0 && b==0){break;} c=0; t=0; int count=0; while(b!=0){ c=a%b; a=c; swap(a,b); count++; } cout<<a<<" "<<count<<endl; } }
a.cc: In function 'int main()': a.cc:10:9: error: 't' was not declared in this scope 10 | t=0; | ^
s501752267
p00197
C++
#include<bits/stdc++.h> using namespace std; int main(){ int x,y,x1,y1; int cnt=0; while(1) { cin >> x >> y; if(x==0 && y==0) { break; } /* x = max(x,y); y = min(x,y);*/ while(1) { if(x!=y) { y1 = x%y; x1 = y; cnt++; x = x1; y = y1; if(y == 0)break; } else { cnt = 1; break; } } cout << x << " " << cnt << endl; }
a.cc: In function 'int main()': a.cc:39:6: error: expected '}' at end of input 39 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s386695962
p00197
C++
#include<vector> #include<algorithm> #include<cstdio> #include <string> #include <complex> #include <functional> using namespace std; typedef pair<int,int> P; double dat[100][100]; double dp[200][100];//動的計画法 int main(){ long long a,b,cnt,tmp; while(cin>>a>>b,a){ cnt=0; if(a<b){ tmp=b; b=a; a=tmp; } while(b){ a%=b; tmp=b; b=a; a=tmp; cnt++; } cout<<a<<" "<<cnt<<endl; } }
a.cc: In function 'int main()': a.cc:13:11: error: 'cin' was not declared in this scope 13 | while(cin>>a>>b,a){ | ^~~ a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 6 | #include <functional> +++ |+#include <iostream> 7 | using namespace std; a.cc:27:9: error: 'cout' was not declared in this scope 27 | cout<<a<<" "<<cnt<<endl; | ^~~~ a.cc:27:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s501378687
p00197
C++
(){ int a[2]; while(cin>>a[0]>>a[1]){ if ( a[0]==0&&a[1]==0)break; if ( a[0]<a[1])swap(a[0],a[1]); solve(a); } }
a.cc:1:2: error: expected unqualified-id before ')' token 1 | (){ | ^
s876177236
p00198
C
#include <stdio.h> #include <string.h> ?? int main() { ????????int i0, i1, i2, i3, n, m, d[30][6], s[30], sw; ????????char c[8]; ????????char color[6][8] = {"Cyan", "Yellow", "Red", "Magenta", "Green", "Blue"}; ?? ????????scanf("%d", &n); ????????while (n > 0) { ????????????????for (i0 = 0; i0 < n; i0++) { ????????????????????????for (i1 = 0; i1 < 6; i1++) { ????????????????????????????????scanf("%s", c); ????????????????????????????????for (i2 = 0; i2 < 6; i2++) { ????????????????????????????????????????if (strcmp(c, color[i2]) == 0) { ????????????????????????????????????????????????d[i0][i1] = i2; ????????????????????????????????????????????????break; ????????????????????????????????????????} ????????????????????????????????} ????????????????????????} ????????????????} ????????????????m = 0; ????????????????for (i0 = 0; i0 < n; i0++) ????????????????????????s[i0] = 1; ????????????????for (i0 = 0; i0 < n; i0++) { ????????????????????????if (s[i0] > 0) { ????????????????????????????????m++; ????????????????????????????????s[i0] = 0; ????????????????????????????????for (i1 = i0+1; i1 < n; i1++) { ????????????????????????????????????????sw = 0; ????????????????????????????????????????for (i2 = 0; i2 < 6 && sw == 0; i2++) { ????????????????????????????????????????????????for (i3 = 0; i3 < 6 && sw == 0; i3++) { ????????????????????????????????????????????????????????if (d[i0][i2] == d[i1][i3]) { ????????????????????????????????????????????????????????????????if (d[i0][5-i2] != d[i1][5-i3]) ????????????????????????????????????????????????????????????????????????sw = 1; ????????????????????????????????????????????????????????} ????????????????????????????????????????????????} ????????????????????????????????????????} ????????????????????????????????????????if (sw == 0) ????????????????????????????????????????????????s[i1] = 0; ????????????????????????????????} ????????????????????????} ????????????????} ????????????????printf("%d\n", n-m); ????????????????scanf("%d", &n); ????????} ?? ????????return 0; }
main.c:3:1: error: expected identifier or '(' before '?' token 3 | ?? | ^
s862464704
p00198
C
#include<stdio.h> int main(void){ int i,j,n; char color[8]; while(scanf("%d",&n),n!=0){ int uesita[6]={"0"},yokomen[6]={"0"},del=0,k=-1; for(i=0;i<=n;i++){ if(i<n){ for(j=0;j<6;j++){ scanf("%s",&color); if(j==0 || j==5)uesita[i]+=color[0]; else yokomen[i]+=color[0]; } } if(k>=0){ if(k==0 || k==5 && uesita[k]==uesita[k+1])del++; else if(yokomen[k]==yokomen[k+1])del++; } k++; } printf("%d\n",del); } return 0; }
main.c: In function 'main': main.c:6:31: error: cannot initialize array of 'int' from a string literal with type array of 'char' 6 | int uesita[6]={"0"},yokomen[6]={"0"},del=0,k=-1; | ^ main.c:6:48: error: cannot initialize array of 'int' from a string literal with type array of 'char' 6 | int uesita[6]={"0"},yokomen[6]={"0"},del=0,k=-1; | ^
s540864602
p00198
C
#include<stdio.h> int main(void) { int n,i,j,z; char c1[1001],c2[1001],c3[1001],c4[1001],c5[1001],c6[1001]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%s %s %s %s %s %s",&c1[i],&c2[i],&c3[i],&c4[i],&c5[i],&c6[i]); } for(i=0;i<n;i++){ z=0; for(j=0;j<n;j++){ if(c1[i]==c1[j] && c2[i]==c2[j] && c3[i]==c3[j] && c4[i]==c4[j] && c5[i]==c5[j] && c6[i]==c6[j]){ z=z+1; } else if(c4[i]==c4[j] && c1[i]==c1[j] && c3[i]==c3[j] && c6[i]==c6[j]){ if(c5[i]==c5[j] && c2[i]==c2[j]){ z=z+1; } } else if(c4[i]==c6[j] && c1[i]==c3[j] && c3[i]==c1[j] && c6[i]==c4[j]){ if(c5[i]==c2[j] && c2[i]==c5[j]){ z=z+1; } } else if(c6[i]==c6[j] && c3[i]==c3[j] && c1[i]==c1[j] && c4[i]==c4[j]){ if(c5[i]==c5[j] && c2[i]==c2[j]){ z=z+1; } } else if(c6[i]==c4[j] && c3[i]==c1[j] && c1[i]==c3[j] && c4[i]==c6[j]){ if(c2[i]==c5[j] && c5[i]==c2[j]){ z=z+1; } } else if(c2[i]==c2[j] && c1[i]==c1[j] && c5[i]==c5[j] && c6[i]==c6[j]){ if(c4[i]==c4[j] && c3[i]==c3[j]){ z=z+1; } } else if(c2[i]==c6[j] && c1[i]==c5[j] && c5[i]==c1[j] && c6[i]==c2[j]){ if(c4[i]==c3[j] && c3[i]==c4[j]){ z=z+1; } } else if(c6[i]==c6[j] && c5[i]==c5[j] && c1[i]==c1[j] && c2[i]==c2[j]){ if(c3[i]==c3[j] && c4[i]==c4[j]){ z=z+1; } } else if(c6[i]==c2[j] && c5[i]==c1[j] && c1[i]==c5[j] && c2[i]==c6[j]){ if(c3[i]==c4[j] && c4[i]==c3[j]){ z=z+1; } } } } printf("%d\n",n); } return 0; }
main.c:60:9: error: expected identifier or '(' before 'return' 60 | return 0; | ^~~~~~ main.c:61:1: error: expected identifier or '(' before '}' token 61 | } | ^
s285414790
p00198
C++
#define sc second typedef vector<int> vi; typedef pair<int,int> pii; typedef pair<int,pii> pip; const int INF = (1<<25); const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; int main(){ int n; int ans=0; int box[30][6]; bool b[30][30]; int samenum; while(cin>> n,n){ ans=0; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ b[i][j]=false; } } for(int i=0;i<n;i++){ for(int j=0;j<6;j++){ string s; cin>> s; if(s=="Red") box[i][j]=0; else if(s=="Yellow") box[i][j]=1; else if(s=="Blue") box[i][j]=2; else if(s=="Magenta") box[i][j]=3; else if(s=="Green") box[i][j]=4; else if(s=="Cyan") box[i][j]=5; } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==j) continue; if(b[i][j]==true) continue; b[i][j]=b[j][i]=true; for(int k=0;k<6;k++){ if(box[i][0]==box[j][k]){ samenum=k; break; } } if(box[j][samenum]-box[i][0]==0){ if(box[i][5]==box[j][5]){ ans++; } } else if(box[j][samenum]-box[i][0]==1){ if(box[i][5]==box[j][4]){ ans++; } } else if(box[j][samenum]-box[i][0]==2){ if(box[i][5]==box[j][3]){ ans++; } } else if(box[j][samenum]-box[i][0]==3){ if(box[i][5]==box[j][2]){ ans++; } } else if(box[j][samenum]-box[i][0]==4){ if(box[i][5]==box[j][1]){ ans++; } } else if(box[j][samenum]-box[i][0]==5){ if(box[i][5]==box[j][0]){ ans++; } } } } cout<< ans<< endl; } }
a.cc:2:9: error: 'vector' does not name a type 2 | typedef vector<int> vi; | ^~~~~~ a.cc:3:9: error: 'pair' does not name a type 3 | typedef pair<int,int> pii; | ^~~~ a.cc:4:9: error: 'pair' does not name a type 4 | typedef pair<int,pii> pip; | ^~~~ a.cc: In function 'int main()': a.cc:14:9: error: 'cin' was not declared in this scope 14 | while(cin>> n,n){ | ^~~ a.cc:23:9: error: 'string' was not declared in this scope 23 | string s; | ^~~~~~ a.cc:24:15: error: 's' was not declared in this scope 24 | cin>> s; | ^ a.cc:75:5: error: 'cout' was not declared in this scope 75 | cout<< ans<< endl; | ^~~~ a.cc:75:18: error: 'endl' was not declared in this scope 75 | cout<< ans<< endl; | ^~~~
s161886588
p00198
C++
#include <stdio.h> #include <string.h> ?? int main() { ????????int i0, i1, i2, i3, n, m, d[30][6], s[30], sw; ????????char c[8]; ????????char color[6][8] = {"Cyan", "Yellow", "Red", "Magenta", "Green", "Blue"}; ?? ????????scanf("%d", &n); ????????while (n > 0) { ????????????????for (i0 = 0; i0 < n; i0++) { ????????????????????????for (i1 = 0; i1 < 6; i1++) { ????????????????????????????????scanf("%s", c); ????????????????????????????????for (i2 = 0; i2 < 6; i2++) { ????????????????????????????????????????if (strcmp(c, color[i2]) == 0) { ????????????????????????????????????????????????d[i0][i1] = i2; ????????????????????????????????????????????????break; ????????????????????????????????????????} ????????????????????????????????} ????????????????????????} ????????????????} ????????????????m = 0; ????????????????for (i0 = 0; i0 < n; i0++) ????????????????????????s[i0] = 1; ????????????????for (i0 = 0; i0 < n; i0++) { ????????????????????????if (s[i0] > 0) { ????????????????????????????????m++; ????????????????????????????????s[i0] = 0; ????????????????????????????????for (i1 = i0+1; i1 < n; i1++) { ????????????????????????????????????????sw = 0; ????????????????????????????????????????for (i2 = 0; i2 < 6 && sw == 0; i2++) { ????????????????????????????????????????????????for (i3 = 0; i3 < 6 && sw == 0; i3++) { ????????????????????????????????????????????????????????if (d[i0][i2] == d[i1][i3]) { ????????????????????????????????????????????????????????????????if (d[i0][5-i2] != d[i1][5-i3]) ????????????????????????????????????????????????????????????????????????sw = 1; ????????????????????????????????????????????????????????} ????????????????????????????????????????????????} ????????????????????????????????????????} ????????????????????????????????????????if (sw == 0) ????????????????????????????????????????????????s[i1] = 0; ????????????????????????????????} ????????????????????????} ????????????????} ????????????????printf("%d\n", n-m); ????????????????scanf("%d", &n); ????????} ?? ????????return 0; }
a.cc:3:1: error: expected unqualified-id before '?' token 3 | ?? | ^
s107372284
p00198
C++
#include <stdio.h> #include <string.h> ?? int main() { ????????int i0, i1, i2, i3, n, m, d[30][6], s[30], sw; ????????char c[8]; ????????char color[6][8] = {"Cyan", "Yellow", "Red", "Magenta", "Green", "Blue"}; ?? ????????scanf("%d", &n); ????????while (n > 0) { ????????????????for (i0 = 0; i0 < n; i0++) { ????????????????????????for (i1 = 0; i1 < 6; i1++) { ????????????????????????????????scanf("%s", c); ????????????????????????????????for (i2 = 0; i2 < 6; i2++) { ????????????????????????????????????????if (strcmp(c, color[i2]) == 0) { ????????????????????????????????????????????????d[i0][i1] = i2; ????????????????????????????????????????????????break; ????????????????????????????????????????} ????????????????????????????????} ????????????????????????} ????????????????} ????????????????m = 0; ????????????????for (i0 = 0; i0 < n; i0++) ????????????????????????s[i0] = 1; ????????????????for (i0 = 0; i0 < n; i0++) { ????????????????????????if (s[i0] > 0) { ????????????????????????????????m++; ????????????????????????????????s[i0] = 0; ????????????????????????????????for (i1 = i0+1; i1 < n; i1++) { ????????????????????????????????????????sw = 0; ????????????????????????????????????????for (i2 = 0; i2 < 6 && sw == 0; i2++) { ????????????????????????????????????????????????for (i3 = 0; i3 < 6 && sw == 0; i3++) { ????????????????????????????????????????????????????????if (d[i0][i2] == d[i1][i3]) { ????????????????????????????????????????????????????????????????if (d[i0][5-i2] != d[i1][5-i3]) ????????????????????????????????????????????????????????????????????????sw = 1; ????????????????????????????????????????????????????????} ????????????????????????????????????????????????} ????????????????????????????????????????} ????????????????????????????????????????if (sw == 0) ????????????????????????????????????????????????s[i1] = 0; ????????????????????????????????} ????????????????????????} ????????????????} ????????????????printf("%d\n", n-m); ????????????????scanf("%d", &n); ????????} ?? ????????return 0; }
a.cc:3:1: error: expected unqualified-id before '?' token 3 | ?? | ^
s099943334
p00198
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) //#define int long long using namespace std; struct Dice { int c[6]; //?????????????????? Dice() {} //c0:???, c1:??????, c2:???, c3:?\\, c4:???, c5:??? Dice(int c0, int c1, int c2, int c3, int c4, int c5) { c[0] = c0; c[1] = c1; c[2] = c2; c[3] = c3; c[4] = c4; c[5] = c5; } void temae() { int temp = c[0]; c[0] = c[3]; c[3] = c[5]; c[5] = c[1]; c[1] = temp; } void oku() { int temp = c[0]; c[0] = c[1]; c[1] = c[5]; c[5] = c[3]; c[3] = temp; } //y????????¢?????? void y_migi() { int temp = c[1]; c[1] = c[4]; c[4] = c[3]; c[3] = c[2]; c[2] = temp; } //y????????¢?????? void y_hidari() { int temp = c[1]; c[1] = c[2]; c[2] = c[3]; c[3] = c[4]; c[4] = temp; } //z????????¢?????? void z_migi() { int temp = c[0]; c[0] = c[4]; c[4] = c[5]; c[5] = c[2]; c[2] = temp; } //z????????¢?????? void z_hidari() { int temp = c[0]; c[0] = c[2]; c[2] = c[5]; c[5] = c[4]; c[4] = temp; } //1???????????\?????????????????¢??????2????¨????????????´????????????????\\??????????????°3????\\???????????????????????? void format() { if (c[0] == 1) { ; } else if (c[1] == 1) { oku(); } else if (c[2] == 1) { z_hidari(); } else if (c[3] == 1) { temae(); } else if (c[4] == 1) { z_migi(); } else if (c[5] == 1) { oku(); oku(); } if (c[1] == 2) { y_migi(); y_migi(); } else if (c[2] == 2) { y_migi(); } else if (c[4] == 2) { y_hidari(); } else if (c[3] == 2) { return; } else { if (c[1] == 3) { y_migi(); y_migi(); } else if (c[2] == 3) { y_migi(); } else if (c[4] == 3) { y_hidari(); } } } bool operator == (const Dice &d) const { Dice td1 = Dice(c[0], c[1], c[2], c[3], c[4], c[5]); Dice td2 = d; td1.format(); td2.format(); rep(i,6) { if (td1.c[i] != td2.c[i]) return false; } return true; } }; int n; map<string, int> c2n; string color[6]; int cc[6]; Dice d[30]; bool used[30]; signed main() { c2n["Red"] = 1; c2n["Yellow"] = 2; c2n["Blue"] = 3; c2n["Magenta"] = 4; c2n["Green"] = 5; c2n["Cyan"] = 6; while (true) { cin >> n; if (n == 0) break; rep(j,n) { rep(i,6) cin >> color[i]; cc[0] = c2n[color[0]]; cc[1] = c2n[color[1]]; cc[2] = c2n[color[2]]; cc[3] = c2n[color[4]]; cc[4] = c2n[color[3]]; cc[5] = c2n[color[5]]; d[j] = Dice(cc[0], cc[1], cc[2], cc[3], cc[4], cc[5]); } rep(i,n) used[i] = false; int ans = 0; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { if (d[i] == d[j] && used[j] = false;) { ans++; used[j] = true; } } } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:160:50: error: lvalue required as left operand of assignment 160 | if (d[i] == d[j] && used[j] = false;) | ~~~~~~~~~~~~~^~~~~~~~~~ a.cc:160:69: error: expected primary-expression before ')' token 160 | if (d[i] == d[j] && used[j] = false;) | ^
s957150617
p00198
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) //#define int long long using namespace std; struct Dice { int c[6]; //?????????????????? Dice() {} //c0:???, c1:??????, c2:???, c3:?\\, c4:???, c5:??? Dice(int c0, int c1, int c2, int c3, int c4, int c5) { c[0] = c0; c[1] = c1; c[2] = c2; c[3] = c3; c[4] = c4; c[5] = c5; } void temae() { int temp = c[0]; c[0] = c[3]; c[3] = c[5]; c[5] = c[1]; c[1] = temp; } void oku() { int temp = c[0]; c[0] = c[1]; c[1] = c[5]; c[5] = c[3]; c[3] = temp; } //y????????¢?????? void y_migi() { int temp = c[1]; c[1] = c[4]; c[4] = c[3]; c[3] = c[2]; c[2] = temp; } //y????????¢?????? void y_hidari() { int temp = c[1]; c[1] = c[2]; c[2] = c[3]; c[3] = c[4]; c[4] = temp; } //z????????¢?????? void z_migi() { int temp = c[0]; c[0] = c[4]; c[4] = c[5]; c[5] = c[2]; c[2] = temp; } //z????????¢?????? void z_hidari() { int temp = c[0]; c[0] = c[2]; c[2] = c[5]; c[5] = c[4]; c[4] = temp; } //1???????????\?????????????????¢??????2????¨????????????´????????????????\\??????????????°3????\\???????????????????????? void format() { if (c[0] == 1) { ; } else if (c[1] == 1) { oku(); } else if (c[2] == 1) { z_hidari(); } else if (c[3] == 1) { temae(); } else if (c[4] == 1) { z_migi(); } else if (c[5] == 1) { oku(); oku(); } if (c[1] == 2) { y_migi(); y_migi(); } else if (c[2] == 2) { y_migi(); } else if (c[4] == 2) { y_hidari(); } else if (c[3] == 2) { return; } else { if (c[1] == 3) { y_migi(); y_migi(); } else if (c[2] == 3) { y_migi(); } else if (c[4] == 3) { y_hidari(); } } } bool operator == (const Dice &d) const { Dice td1 = Dice(c[0], c[1], c[2], c[3], c[4], c[5]); Dice td2 = d; td1.format(); td2.format(); rep(i,6) { if (td1.c[i] != td2.c[i]) return false; } return true; } }; int n; map<string, int> c2n; string color[6]; int cc[6]; Dice d[30]; bool used[30]; signed main() { c2n["Red"] = 1; c2n["Yellow"] = 2; c2n["Blue"] = 3; c2n["Magenta"] = 4; c2n["Green"] = 5; c2n["Cyan"] = 6; while (true) { cin >> n; if (n == 0) break; rep(j,n) { rep(i,6) cin >> color[i]; cc[0] = c2n[color[0]]; cc[1] = c2n[color[1]]; cc[2] = c2n[color[2]]; cc[3] = c2n[color[4]]; cc[4] = c2n[color[3]]; cc[5] = c2n[color[5]]; d[j] = Dice(cc[0], cc[1], cc[2], cc[3], cc[4], cc[5]); } rep(i,n) used[i] = false; int ans = 0; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { if (d[i] == d[j] && used[j] == false;) { ans++; used[j] = true; } } } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:160:70: error: expected primary-expression before ')' token 160 | if (d[i] == d[j] && used[j] == false;) | ^
s786199918
p00198
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT }; class UnionFind { public: vector<int> data; UnionFind(int size):data(size, -1){} bool unionSet(int x, int y) { x = root(x); y=root(y); if(x != y) { if(data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } int root(int x) { return data[x] < 0 ? x:data[x]=root(data[x]); } }; class Dice { public: Dice(string m[6]) { f[TOP]=0; f[FRONT]=1; f[LEFT]=2; f[RIGHT]=3; f[BACK]=4; f[BOTTOM]=5; for(int i=0; i<6; i++) val[i]=m[i]; } void rotated(FACE a, FACE b, FACE c, FACE d) { int tmp = f[a]; f[a]=f[b]; f[b]=f[c]; f[c]=f[d]; f[d]=tmp; } vector<Dice> all_rotate() { vector<Dice> t; for(int i=0; i<6; (i&1?rotateY():rotateX()), i++) for(int j=0; j<4; rotateZ(), j++) t.push_back(*this); return t; } void rotateX() { rotated(TOP, BACK, BOTTOM, FRONT); } void rotateY() { rotated(TOP, LEFT, BOTTOM, RIGHT); } void rotateZ() { rotated(FRONT, RIGHT, BACK, LEFT); } string GetVal(FACE fe) { return val[f[fe]]; } int f[6]; string val[6]; }; bool isequal(vector<Dice>& a, vector<Dice>& b) { for(int k=0; k<a.size(); k++) for(int j=0; j<b.size(); j++) { bool g=true; for(int i=0; i<6; i++) { if(a[k].GetVal(i)!=b[j].GetVal(i)) { g=false; break; } } if(g) return true; } return false; } int main() { int N; while(cin >> N, N) { vector<Dice> d; for(int i=0; i<N; i++) { string s[6]; for(int j=0; j<6; j++) cin >> s[j]; d.push_back(s); } vector<vector<Dice> > face; for(int i=0; i<d.size(); i++) face.push_back(d[i].all_rotate()); int ans=0; UnionFind uf(N); for(int i=0; i<N; i++) for(int j=i+1; j<N; j++) { if(i==j) continue; if(isequal(face[j], face[i])) { if(uf.unionSet(i,j)) ans++; } } cout << ans << endl; } }
a.cc: In function 'bool isequal(std::vector<Dice>&, std::vector<Dice>&)': a.cc:82:40: error: invalid conversion from 'int' to 'FACE' [-fpermissive] 82 | if(a[k].GetVal(i)!=b[j].GetVal(i)) | ^ | | | int a.cc:67:28: note: initializing argument 1 of 'std::string Dice::GetVal(FACE)' 67 | string GetVal(FACE fe) { return val[f[fe]]; } | ~~~~~^~ a.cc:82:56: error: invalid conversion from 'int' to 'FACE' [-fpermissive] 82 | if(a[k].GetVal(i)!=b[j].GetVal(i)) | ^ | | | int a.cc:67:28: note: initializing argument 1 of 'std::string Dice::GetVal(FACE)' 67 | string GetVal(FACE fe) { return val[f[fe]]; } | ~~~~~^~
s737034426
p00198
C++
// Trouble in Shinagawa's Artifacts // URL: http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0198&lang=jp #include <cstdio> #include <cstring> #include <vector> #include <set> // ŠÖ” std::vector <int> rotate_x( std::vector <int> box ); std::vector <int> rotate_y( std::vector <int> box ); std::vector <int> rotate_z( std::vector <int> box ); // x‚ɉñ“]‚³‚¹‚éŠÖ” std::vector <int> rotate_x( std::vector <int> box ) { // x‰ñ“] // c1, c2, c3, c4, c5, c6 : default // c5, c1, c3, c4, c6, c2 int tmp = box[0]; box[0] = box[4]; box[4] = box[5]; box[5] = box[1]; box[1] = tmp; return box; } // y‚ɉñ“]‚³‚¹‚éŠÖ” std::vector <int> rotate_v( std::vector <int> box ) { // y‰ñ“] // c1, c2, c3, c4, c5, c6 : default // c1, c4, c2, c5, c3, c6 int tmp = box[1]; box[1] = box[3]; box[3] = box[4]; box[4] = box[2]; box[2] = tmp; return box; } // z‚ɉñ“]‚³‚¹‚éŠÖ” std::vector <int> rotate_z( std::vector <int> box ) { // z‰ñ“] // c1, c2, c3, c4, c5, c6 : default // c3, c2, c6, c1, c5, c4 int tmp = box[0]; box[0] = box[2]; box[2] = box[5]; box[5] = box[3]; box[3] = tmp; return box; } // ƒGƒ“ƒgƒŠ[ƒ|ƒCƒ“ƒg int main() { // •ϐ” int n; int answer; char color[32]; std::vector <int> box( 6, 0 ); std::set < std::vector <int> > table; /* // debug std::vector <int> test( 6, 0 ); for( int i = 0; i < 6; ++i ) { test[i] = i + 1; } for( int j = 0; j < 4; ++j ) { if( j > 0 ) { test = rotate_h( test ); } printf( "‰¡\n" ); for( int l = 0; l < 6; ++l ) { printf( "%d: %d\n", l, test[l] ); } puts( "//==================================================" ); // c for( int k = 0; k < 4; ++k ) { test = rotate_v( test ); printf( "c\n" ); for( int l = 0; l < 6; ++l ) { printf( "%d: %d\n", l, test[l] ); } puts( "//==================================================" ); } } // debug */ while( 1 ) { // ‰Šú‰» answer = 0; table.clear(); for( int i = 0; i < 6; ++i ) { box[i] = 0; } // “ü—Í std::fflush( stdin ); std::scanf( "%d", &n ); // “ü—͂̏I‚í‚èFƒ[ƒ‚ЂƂ if( n == 0 ) break; // n‚̐”‚¾‚¯“ǂݍž‚Þ for( int i = 0; i < n; ++i ) { std::fflush( stdin ); // Fî•ñ‚ð“ü—Í for( int j = 0; j < 6; ++j ) { std::scanf( "%s", color ); // ˆµ‚¢‚â‚·‚¢‚悤‚É•¶Žš—ñ¨®”‚ɕϊ· // F: Red, Yellow, Blue, Magenta, Green, Cyan if( std::strcmp( "Red", color ) == 0 ) box[j] = 1; else if( std::strcmp( "Yellow", color ) == 0 ) box[j] = 2; else if( std::strcmp( "Blue", color ) == 0 ) box[j] = 3; else if( std::strcmp( "Magenta", color ) == 0 ) box[j] = 4; else if( std::strcmp( "Grdeen", color ) == 0 ) box[j] = 5; else if( std::strcmp( "Cyan", color ) == 0 ) box[j] = 6; } // insert‚Ì‘O‚É“¯‚¶‚à‚Ì‚ª‚È‚¢‚©’T‚· // “¯‚¶‚à‚Ì‚ª‚ ‚Á‚½‚çƒJƒEƒ“ƒg if( table.find( box ) != table.end() ) { ++answer; continue; } // insert‚µ‚Ä‚¨‚­ // ‰¡¨cx3‚ð4‰ñ // x for( int j = 0; j < 4; ++j ) { box = rotate_x( box ); table.insert( box ); } // y for( int j = 0; j < 4; ++j ) { box = rotate_y( box ); table.insert( box ); } // z for( int j = 0; j < 4; ++j ) { box = rotate_z( box ); table.insert( box ); } } // o—Í std::printf( "%d\n", answer ); } } // main()
/usr/bin/ld: /tmp/ccMa4QUi.o: in function `main': a.cc:(.text+0x644): undefined reference to `rotate_y(std::vector<int, std::allocator<int> >)' collect2: error: ld returned 1 exit status
s235511971
p00198
C++
main(){char* l="RYBMGC";int i,j,n,a,c[6],f,s,t[4],r[][4]={{1,2,4,3},{5,2,0,3},{0,1,5,4},{0,4,5,1},{0,2,5,3},{2,1,3,4}};while(scanf("%d",&n),n){a=0;int u[9999]={0};while(n--){char b[16];for(i=0;i<6;++i){scanf("%s",b);for(j=0;l[j]!=*b;++j);c[i]=j;if(j==0)f=i;}for(i=0;i<4;++i)t[i]=c[r[f][i]];for(i=0;i<3;++i){s=0;for(j=0;j<4;++j)s=s*10+t[(i+j)%4];if(u[s]){++a;break;}else u[s]=1;}}printf("%d\n",a);}exit(0);}
a.cc:1:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 1 | main(){char* l="RYBMGC";int i,j,n,a,c[6],f,s,t[4],r[][4]={{1,2,4,3},{5,2,0,3},{0,1,5,4},{0,4,5,1},{0,2,5,3},{2,1,3,4}};while(scanf("%d",&n),n){a=0;int u[9999]={0};while(n--){char b[16];for(i=0;i<6;++i){scanf("%s",b);for(j=0;l[j]!=*b;++j);c[i]=j;if(j==0)f=i;}for(i=0;i<4;++i)t[i]=c[r[f][i]];for(i=0;i<3;++i){s=0;for(j=0;j<4;++j)s=s*10+t[(i+j)%4];if(u[s]){++a;break;}else u[s]=1;}}printf("%d\n",a);}exit(0);} | ^~~~ a.cc: In function 'int main()': a.cc:1:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] 1 | main(){char* l="RYBMGC";int i,j,n,a,c[6],f,s,t[4],r[][4]={{1,2,4,3},{5,2,0,3},{0,1,5,4},{0,4,5,1},{0,2,5,3},{2,1,3,4}};while(scanf("%d",&n),n){a=0;int u[9999]={0};while(n--){char b[16];for(i=0;i<6;++i){scanf("%s",b);for(j=0;l[j]!=*b;++j);c[i]=j;if(j==0)f=i;}for(i=0;i<4;++i)t[i]=c[r[f][i]];for(i=0;i<3;++i){s=0;for(j=0;j<4;++j)s=s*10+t[(i+j)%4];if(u[s]){++a;break;}else u[s]=1;}}printf("%d\n",a);}exit(0);} | ^~~~~~~~ a.cc:1:126: error: 'scanf' was not declared in this scope 1 | main(){char* l="RYBMGC";int i,j,n,a,c[6],f,s,t[4],r[][4]={{1,2,4,3},{5,2,0,3},{0,1,5,4},{0,4,5,1},{0,2,5,3},{2,1,3,4}};while(scanf("%d",&n),n){a=0;int u[9999]={0};while(n--){char b[16];for(i=0;i<6;++i){scanf("%s",b);for(j=0;l[j]!=*b;++j);c[i]=j;if(j==0)f=i;}for(i=0;i<4;++i)t[i]=c[r[f][i]];for(i=0;i<3;++i){s=0;for(j=0;j<4;++j)s=s*10+t[(i+j)%4];if(u[s]){++a;break;}else u[s]=1;}}printf("%d\n",a);}exit(0);} | ^~~~~ a.cc:1:380: error: 'printf' was not declared in this scope 1 | main(){char* l="RYBMGC";int i,j,n,a,c[6],f,s,t[4],r[][4]={{1,2,4,3},{5,2,0,3},{0,1,5,4},{0,4,5,1},{0,2,5,3},{2,1,3,4}};while(scanf("%d",&n),n){a=0;int u[9999]={0};while(n--){char b[16];for(i=0;i<6;++i){scanf("%s",b);for(j=0;l[j]!=*b;++j);c[i]=j;if(j==0)f=i;}for(i=0;i<4;++i)t[i]=c[r[f][i]];for(i=0;i<3;++i){s=0;for(j=0;j<4;++j)s=s*10+t[(i+j)%4];if(u[s]){++a;break;}else u[s]=1;}}printf("%d\n",a);}exit(0);} | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | main(){char* l="RYBMGC";int i,j,n,a,c[6],f,s,t[4],r[][4]={{1,2,4,3},{5,2,0,3},{0,1,5,4},{0,4,5,1},{0,2,5,3},{2,1,3,4}};while(scanf("%d",&n),n){a=0;int u[9999]={0};while(n--){char b[16];for(i=0;i<6;++i){scanf("%s",b);for(j=0;l[j]!=*b;++j);c[i]=j;if(j==0)f=i;}for(i=0;i<4;++i)t[i]=c[r[f][i]];for(i=0;i<3;++i){s=0;for(j=0;j<4;++j)s=s*10+t[(i+j)%4];if(u[s]){++a;break;}else u[s]=1;}}printf("%d\n",a);}exit(0);} a.cc:1:398: error: 'exit' was not declared in this scope 1 | main(){char* l="RYBMGC";int i,j,n,a,c[6],f,s,t[4],r[][4]={{1,2,4,3},{5,2,0,3},{0,1,5,4},{0,4,5,1},{0,2,5,3},{2,1,3,4}};while(scanf("%d",&n),n){a=0;int u[9999]={0};while(n--){char b[16];for(i=0;i<6;++i){scanf("%s",b);for(j=0;l[j]!=*b;++j);c[i]=j;if(j==0)f=i;}for(i=0;i<4;++i)t[i]=c[r[f][i]];for(i=0;i<3;++i){s=0;for(j=0;j<4;++j)s=s*10+t[(i+j)%4];if(u[s]){++a;break;}else u[s]=1;}}printf("%d\n",a);}exit(0);} | ^~~~ a.cc:1:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>' +++ |+#include <cstdlib> 1 | main(){char* l="RYBMGC";int i,j,n,a,c[6],f,s,t[4],r[][4]={{1,2,4,3},{5,2,0,3},{0,1,5,4},{0,4,5,1},{0,2,5,3},{2,1,3,4}};while(scanf("%d",&n),n){a=0;int u[9999]={0};while(n--){char b[16];for(i=0;i<6;++i){scanf("%s",b);for(j=0;l[j]!=*b;++j);c[i]=j;if(j==0)f=i;}for(i=0;i<4;++i)t[i]=c[r[f][i]];for(i=0;i<3;++i){s=0;for(j=0;j<4;++j)s=s*10+t[(i+j)%4];if(u[s]){++a;break;}else u[s]=1;}}printf("%d\n",a);}exit(0);}
s681136308
p00198
C++
#include<iostream> using namespace std; int main(){ int n,q; int i; con int s[n]; for(i=0;i<n;i++) printf("%d",&s[i]); printf("%d",&q); int t[q]; for(i=0;i<q;i++) printf("%d",&t[i]); int count=0; int h[10000000]; for(i=0;i<n;i++) h[s[i]] = 1; for(i=0;i<q;i++){ if(h[t[q]]==1){ count++; h[t[q]] = 0; } } scanf("%d\n",count); return 0; }
a.cc: In function 'int main()': a.cc:6:3: error: 'con' was not declared in this scope 6 | con | ^~~ a.cc:8:33: error: 's' was not declared in this scope 8 | for(i=0;i<n;i++) printf("%d",&s[i]); | ^ a.cc:14:22: error: 's' was not declared in this scope 14 | for(i=0;i<n;i++) h[s[i]] = 1; | ^
s606427114
p00199
Java
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, m; int a[]; while (true) { n = sc.nextInt(); m = sc.nextInt(); if ((n | m) == 0) { break; } a = new int[n]; while (m-- != 0) { String k = sc.next(); if (k.equals("A")) { for (int i = 0; i < n; i++) { if (a[i] == 0) { a[i] = 1; break; } } } else if (k.equals("B")) { boolean flag = false; for (int i = n - 1; 0 <= i; i--) { if (a[i] == 0 && (i - 1 < 0 || a[i - 1] != 1) && (n <= i + 1 || a[i + 1] != 1)) { a[i] = 2; flag = true; break; } } if (!flag) { for (int i = 0; i < n; i++) { if (a[i] == 0) { a[i] = 2; break; } } } } else if (k.equals("C")) { boolean flag = false; for (int i = 0; i < n; i++) { if (a[i] != 0) { if (i + 1 < n && a[i + 1] == 0) { a[i + 1] = 3; flag = true; break; } else if (0 <= i - 1 && a[i - 1] == 0) { a[i - 1] = 3; flag = true; break; } } } if (!flag) { a[n / 2] = 3; } } else if (k.equals("D")) { int min = 1 << 29; int minId = 0; for (int i = 0; i < n; i++) { if (a[i] == 0) { int tmp1 = 0; int tmp2 = 0; int id = i + 1; while (id < n && a[id] == 0) { tmp1++; id++; } id = i - 1; while (0 <= id && a[id] == 0) { tmp2++; id--; } if (Math.min(tmp1, tmp2) < min) { min = Math.min(tmp1, tmp2); minId = i; } } } a[minId] = 4; } } for (int i = 0; i < n; i++) { if (a[i] != 0) { System.out.print((char)(a[i] + 'A' - 1)); } else { System.out.print("#"); } } System.out.println(); } } }
Main.java:3: error: class main is public, should be declared in a file named main.java public class main { ^ 1 error
s189349564
p00199
Java
import java.util.Scanner; public class A0199 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, m; int a[]; while (true) { n = sc.nextInt(); m = sc.nextInt(); if ((n | m) == 0) { break; } a = new int[n]; while (m-- != 0) { String k = sc.next(); if (k.equals("A")) { for (int i = 0; i < n; i++) { if (a[i] == 0) { a[i] = 1; break; } } } else if (k.equals("B")) { boolean flag = false; for (int i = n - 1; 0 <= i; i--) { if (a[i] == 0 && (i - 1 < 0 || a[i - 1] != 1) && (n <= i + 1 || a[i + 1] != 1)) { a[i] = 2; flag = true; break; } } if (!flag) { for (int i = 0; i < n; i++) { if (a[i] == 0) { a[i] = 2; break; } } } } else if (k.equals("C")) { boolean flag = false; for (int i = 0; i < n; i++) { if (a[i] != 0) { if (i + 1 < n && a[i + 1] == 0) { a[i + 1] = 3; flag = true; break; } else if (0 <= i - 1 && a[i - 1] == 0) { a[i - 1] = 3; flag = true; break; } } } if (!flag) { a[n / 2] = 3; } } else if (k.equals("D")) { int max = 0; int minId = -1; for (int i = 0; i < n; i++) { if (a[i] == 0) { int tmp1 = 0; int tmp2 = 0; int id = i + 1; while (id < n && a[id] == 0) { tmp1++; id++; } if (id == n) { tmp1 = 1 << 29; } id = i - 1; while (0 <= id && a[id] == 0) { tmp2++; id--; } if (id == -1) { tmp2 = 1 << 29; } if (max < Math.min(tmp1, tmp2)) { max = Math.min(tmp1, tmp2); minId = i; } } } if (minId != -1) { a[minId] = 4; } else { for (int i = 0; i < n; i++) { if (a[i] == 0) { a[i] = 4; break; } } } } } for (int i = 0; i < n; i++) { if (a[i] != 0) { System.out.print((char)(a[i] + 'A' - 1)); } else { System.out.print("#"); } } System.out.println(); } } }
Main.java:3: error: class A0199 is public, should be declared in a file named A0199.java public class A0199 { ^ 1 error
s693021379
p00199
C
#include<stdio.h> #include<string.h> #include<stdlib.h> int main(){ int i,j,k,n,m,x,y; char s[105],t[5]; while(1){ scanf("%d%d",&n,&m); if(n==0)break; memset(s,0,sizeof(s)); for(i=0;i<n;i++)s[i]='#'; while(m--){ scanf("%s",t); if(t[0]=='A'){ for(i=0;i<n;i++)if(s[i]=='#'){s[i]='A';break;} } else if(t[0]=='B'){ for(i=n-1;i>=0;i--){ if(s[i]=='#'){ if(i==0 && s[1]!='A'){s[0]='B';break;} else if(i==n-1 && s[i-1]!='A'){s[i]='B';break} else if(s[i-1]!='A' && s[i+1]!='A'){s[i]='B';break;} } } if(i==-1){ for(j=0;j<n;j++)if(s[j]=='#'){s[j]='B';break;} } } else if(t[0]=='C'){ for(i=1;i<n;i++)if(s[i]=='#' && s[i-1]!='#'){s[i]='C';break;} if(i==n)s[n/2]='C'; } else{ x=y=-1; for(i=0;i<n;i++){ if(s[i]=='#'){ j=1; while(1){ if(i-j>=0 && s[i-j]!='#')break; if(i+j<=n && s[i+j]!='#')break; j++; } if(j>y)x=i,y=j; } } s[x]='D'; } //printf("%s\n",s); } printf("%s\n",s); } return 0; }
main.c: In function 'main': main.c:22:94: error: expected ';' before '}' token 22 | else if(i==n-1 && s[i-1]!='A'){s[i]='B';break} | ^ | ;
s248212942
p00199
C++
include<bits/stdc++.h> using namespace std; int main(){ int n,m; while(cin>>n>>m,n){ string s; for(int i=0;i<n;i++)s+='#'; while(m--){ string p; cin>>p; if(p=="A"){ for(int i=0;i<n;i++) if(s[i]=='#'){ s[i]='A'; break; } } if(p=="B"){ int pp=0; for(int i=n-1;i>=0;i--){ if(i==n-1){if(s[i-1]!='A'&&s[i]=='#'){pp++,s[i]='B';break;}} else if(!i){if(s[i+1]!='A'&&s[i]=='#'){pp++,s[i]='B';break;}} else {if(s[i-1]!='A'&&s[i]=='#'&&s[i+1]!='A'){pp++,s[i]='B';break;}} } if(!pp)for(int i=0;i<n;i++) if(s[i]=='#'){ s[i]='B'; break; } } if(p=="C"){ int pp=0; for(int i=0;i<n;i++) if(s[i]!='#'){ if(i!=n-1){if(s[i+1]=='#'){s[i+1]='C';pp++;break;}} if(i){if(s[i-1]=='#'){s[i-1]='C';pp++;break;}} } if(!pp){ if(n%2)s[(n+1)/2-1]='C'; else s[n/2]='C'; } } else if(p=="D"){ int d[n]={},p=0,sp=0; for(int i=0;i<n;i++){ int p1=0,p2=0; if(i==n-1)p1=100; for(int j=i;j<n;j++) if(s[j]=='#')p1++; else break; for(int j=i;j>=0;j--) if(s[j]=='#')p2++; else break; p1=min(p1,p2); p=max(p,p1); d[i]=p1; } for(int i=0;i<n;i++)if(s[i]!='#')sp++; if(sp)s[0]='D'; else for(int i=0;i<n;i++) if(d[i]==p){ s[i]='D'; break; } } } cout<<s<<endl; } }
a.cc:1:1: error: 'include' does not name a type 1 | include<bits/stdc++.h> | ^~~~~~~ a.cc: In function 'int main()': a.cc:5:9: error: 'cin' was not declared in this scope 5 | while(cin>>n>>m,n){ | ^~~ a.cc:6:5: error: 'string' was not declared in this scope 6 | string s; | ^~~~~~ a.cc:7:25: error: 's' was not declared in this scope 7 | for(int i=0;i<n;i++)s+='#'; | ^ a.cc:9:13: error: expected ';' before 'p' 9 | string p; | ^~ | ; a.cc:10:12: error: 'p' was not declared in this scope 10 | cin>>p; | ^ a.cc:13:14: error: 's' was not declared in this scope 13 | if(s[i]=='#'){ | ^ a.cc:21:25: error: 's' was not declared in this scope 21 | if(i==n-1){if(s[i-1]!='A'&&s[i]=='#'){pp++,s[i]='B';break;}} | ^ a.cc:22:26: error: 's' was not declared in this scope 22 | else if(!i){if(s[i+1]!='A'&&s[i]=='#'){pp++,s[i]='B';break;}} | ^ a.cc:23:20: error: 's' was not declared in this scope 23 | else {if(s[i-1]!='A'&&s[i]=='#'&&s[i+1]!='A'){pp++,s[i]='B';break;}} | ^ a.cc:26:17: error: 's' was not declared in this scope 26 | if(s[i]=='#'){ | ^ a.cc:34:14: error: 's' was not declared in this scope 34 | if(s[i]!='#'){ | ^ a.cc:40:18: error: 's' was not declared in this scope 40 | if(n%2)s[(n+1)/2-1]='C'; | ^ a.cc:41:16: error: 's' was not declared in this scope 41 | else s[n/2]='C'; | ^ a.cc:51:16: error: 's' was not declared in this scope 51 | if(s[j]=='#')p1++; | ^ a.cc:54:16: error: 's' was not declared in this scope 54 | if(s[j]=='#')p2++; | ^ a.cc:56:14: error: 'min' was not declared in this scope; did you mean 'main'? 56 | p1=min(p1,p2); | ^~~ | main a.cc:57:13: error: 'max' was not declared in this scope 57 | p=max(p,p1); | ^~~ a.cc:60:32: error: 's' was not declared in this scope 60 | for(int i=0;i<n;i++)if(s[i]!='#')sp++; | ^ a.cc:61:15: error: 's' was not declared in this scope; did you mean 'sp'? 61 | if(sp)s[0]='D'; | ^ | sp a.cc:64:13: error: 's' was not declared in this scope 64 | s[i]='D'; | ^ a.cc:70:5: error: 'cout' was not declared in this scope 70 | cout<<s<<endl; | ^~~~ a.cc:70:11: error: 's' was not declared in this scope 70 | cout<<s<<endl; | ^ a.cc:70:14: error: 'endl' was not declared in this scope 70 | cout<<s<<endl; | ^~~~
s258912993
p00199
C++
#include<iostream> using namespace std; #define rep(i,s,e) for ( int i = s; i <= e; i++ ) #define MAX 10000 char C[MAX+2]; int n, m; void setLeft(char ch){ for ( int i = 1; ; i++ ){ if ( C[i] == '#' ) { C[i] = ch; return; } } } void setB(){ for ( int i = n; i >= 1; i-- ){ if ( C[i] == '#' && C[i-1] != 'A' && C[i+1] != 'A' ){ C[i] = 'B'; return; } } setLeft('B'); } bool isEmpty(){ rep(i,1,n) if ( C[i] != '#' ) return false; return true; } void setC(){ if ( isEmpty() ){ C[n/2+1] = 'C'; return; } rep(i,1,n){ if ( C[i] == '#' ) continue; if ( C[i+1] == '#' ) { C[i+1] = 'C'; return; } if ( C[i-1] == '#' ) { C[i-1] = 'C'; return; } } } int getDist( int p ){ int l = 0, r = 0; while( C[p+l-1] == '#' ) l--; if ( C[p+l-1] == 'X' ) l = -1000000; while( C[p+r+1] == '#' ) r++; if ( C[p+r+1] == 'X' ) r = 1000000; return min( (-1)*l, r); } void setD(){ if ( isEmpty() ){ C[1] = 'D'; return; } int d, mi, md = -1; rep(i,1,n){ if ( C[i] != '#' ) continue; d = getDist(i); if ( d > md ) { md = d; mi = i; } } C[mi] = 'D'; } main(){ char ch; while( cin >> n >> m && n && m ){ assert( n <= 100 ); rep(i,0,n+1) C[i] = '#'; C[0] = C[n+1] = 'X'; rep(i,1,m){ cin >> ch; if ( ch == 'A' ) setLeft('A'); else if ( ch == 'B' ) setB(); else if ( ch == 'C' ) setC(); else if ( ch == 'D' ) setD(); } rep(i,1,n) cout << C[i]; cout << endl; } }
a.cc:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 58 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:61:7: error: 'assert' was not declared in this scope 61 | assert( n <= 100 ); | ^~~~~~ a.cc:2:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 1 | #include<iostream> +++ |+#include <cassert> 2 | using namespace std;
s906848219
p00199
C++
#include<iostream> using namespace std; int main(){ long n,m,i,j,d[101],e[101],k,dd; char c,a[101]; while(cin>>n){ cin>>m; if(n==0)break; for(i=0;i<n;i++)a[i]='#'; for(j=0;j<m;j++){ cin>>c; if(c=='A'){ for(i=0;i<n;i++)if(a[i]=='#'){a[i]='A';break;} }else if(c=='B'){ for(i=n-1;i>=0;i--){ if(0<i&&a[i-1]!='A'&&i<n-1&&a[i+1]!='A'){a[i]='B';break;} else if(0<i&&a[i-1]!='A'){a[i]='B';break;} else if(i<n-1&&a[i+1]!='A'){a[i]='B';break;} } if(i<0){for(i=0;i<n;i++)if(a[i]=='#')a[i]='B';break} }else if(c=='C'){ for(i=0;i<n;i++){ if(a[i]!='#'){ if(i<n-1&&a[i+1]=='#'){a[i+1]='C';break;} else if(i>0&&a[i-1]=='#'){a[i-1]='C';break;} } } if(i==n)a[n/2]='C'; }else if(c=='D'){ for(i=0;i<n;i++)d[i]=-1; for(i=0;i<n;i++)if(a[i]!='#')break; if(i==n){a[0]='D';continue;} for(;i<n;i++)if(a[i]=='#')d[i]=d[i-1]+1;else d[i]=0; for(i=0;i<n;i++)e[i]=-1; for(i=n-1;i>=0;i--)if(a[i]!='#')break; for(;i>=0;i--)if(a[i]=='#')e[i]=e[i+1]+1;else e[i]=0; for(i=0;i<n;i++)if(d[i]<e[i])d[i]=e[i]; for(k=0;k<n;k++)cout<<" "<<d[k];cout<<endl; dd=d[n-1]; for(i=n-1;i>=0;i--)if(dd<=d[i]){dd=d[i];k=i;} a[k]='D'; } } a[n]=0;cout<<a<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:52: error: expected ';' before '}' token 20 | if(i<0){for(i=0;i<n;i++)if(a[i]=='#')a[i]='B';break} | ^ | ;
s479628707
p00199
C++
#include<iostream> using namespace std; int main(){ long n,m,i,j,d[101],e[101],k,dd; char c,a[101]; while(cin>>n){ cin>>m; if(n==0)break; for(i=0;i<n;i++)a[i]='#'; for(j=0;j<m;j++){ cin>>c; if(c=='A'){ for(i=0;i<n;i++)if(a[i]=='#'){a[i]='A';break;} }else if(c=='B'){ for(i=n-1;i>=0;i--){ if(0<i&&a[i-1]!='A'&&i<n-1&&a[i+1]!='A'){a[i]='B';break;} else if(0<i&&a[i-1]!='A'){a[i]='B';break;} else if(i<n-1&&a[i+1]!='A'){a[i]='B';break;} } if(i<0){for(i=0;i<n;i++)if(a[i]=='#'){a[i]='B';break} }else if(c=='C'){ for(i=0;i<n;i++){ if(a[i]!='#'){ if(i<n-1&&a[i+1]=='#'){a[i+1]='C';break;} else if(i>0&&a[i-1]=='#'){a[i-1]='C';break;} } } if(i==n)a[n/2]='C'; }else if(c=='D'){ for(i=0;i<n;i++)d[i]=-1; for(i=0;i<n;i++)if(a[i]!='#')break; if(i==n){a[0]='D';continue;} for(;i<n;i++)if(a[i]=='#')d[i]=d[i-1]+1;else d[i]=0; for(i=0;i<n;i++)e[i]=-1; for(i=n-1;i>=0;i--)if(a[i]!='#')break; for(;i>=0;i--)if(a[i]=='#')e[i]=e[i+1]+1;else e[i]=0; for(i=0;i<n;i++)if(d[i]<e[i])d[i]=e[i]; for(k=0;k<n;k++)cout<<" "<<d[k];cout<<endl; dd=d[n-1]; for(i=n-1;i>=0;i--)if(dd<=d[i]){dd=d[i];k=i;} a[k]='D'; } } a[n]=0;cout<<a<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:53: error: expected ';' before '}' token 20 | if(i<0){for(i=0;i<n;i++)if(a[i]=='#'){a[i]='B';break} | ^ | ; a.cc:47:2: error: expected '}' at end of input 47 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s105814737
p00200
Java
import java.util.*; public class GameOfStones { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); while(true) { int n = stdIn.nextInt(); int m = stdIn.nextInt(); if(n == 0 && m == 0) { break; } int[][] cost = new int[m+1][m+1]; int[][] time = new int[m+1][m+1]; for(int i = 0; i < m+1; i++) { for(int j = 0; j < m+1; j++) { cost[i][j] = 100000000; time[i][j] = 100000000; } } for(int i = 0; i < n; i++) { int a = stdIn.nextInt(); int b = stdIn.nextInt(); int costA = stdIn.nextInt(); int timeA = stdIn.nextInt(); cost[a][b] = costA; cost[b][a] = costA; time[a][b] = timeA; time[b][a] = timeA; } for(int i = 0; i < m+1; i++) { for(int j = 0; j < m+1; j++) { for(int k = 0; k < m+1; k++) { int tmp1 = cost[i][j]; int tmp2 = cost[j][k]; if(cost[i][k] > tmp1 + tmp2) { cost[i][k] = tmp1+tmp2; } tmp1 = time[i][j]; tmp2 = time[j][k]; if(time[i][k] > tmp1 + tmp2) { time[i][k] = tmp1+tmp2; } } } } int k = stdIn.nextInt(); for(int i = 0; i < k; i++) { int p = stdIn.nextInt(); int q = stdIn.nextInt(); int r = stdIn.nextInt(); if(r == 0) { System.out.println(cost[p][q]); } else { System.out.println(time[p][q]); } } } } }
Main.java:2: error: class GameOfStones is public, should be declared in a file named GameOfStones.java public class GameOfStones { ^ 1 error
s047217984
p00200
Java
import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; import lombok.Data; public class Main { public static void main(String[] args) throws IOException { new Main().run(); } private void run() throws IOException { Scanner scanner = new Scanner(System.in); while (true) { n = scanner.nextInt(); m = scanner.nextInt(); if ((n | m) == 0) break; List<List<Pair>> cost = new ArrayList<List<Pair>>(); List<List<Pair>> time = new ArrayList<List<Pair>>(); for (int i = 0; i < m; i++) { cost.add(new ArrayList<Pair>()); time.add(new ArrayList<Pair>()); } for (int i = 0; i < n; i++) { int a = scanner.nextInt() - 1; int b = scanner.nextInt() - 1; int c = scanner.nextInt(); int d = scanner.nextInt(); cost.get(a).add(new Pair(b, c)); cost.get(b).add(new Pair(a, c)); time.get(a).add(new Pair(b, d)); time.get(b).add(new Pair(a, d)); } int s = scanner.nextInt(); for (int i = 0; i < s; i++) { int a = scanner.nextInt() - 1; int b = scanner.nextInt() - 1; int c = scanner.nextInt(); if (c == 0) { slove(a, b, cost); }else{ slove(a, b, time); } } } } private void slove(int s, int g, List<List<Pair>> cost) { int[] map = new int[m]; Arrays.fill(map, 1 << 24); map[0] = 0; PriorityQueue<Pair> pq = new PriorityQueue<Pair>(); pq.add(new Pair(0, s)); while (!pq.isEmpty()) { Pair pair = pq.poll(); int a = pair.a; int b = pair.b; if(map[b]<a) continue; for (int i = 0; i < cost.get(b).size(); i++) { int v = cost.get(b).get(i).b; int o = cost.get(b).get(i).a; if (map[o] > v + a) { map[o] = v + a; pq.offer(new Pair(v + a, o)); } } } System.out.println(map[g]); } int n; int m; @Data class Pair implements Comparable<Pair> { int a; int b; public Pair(int a, int b) { super(); this.a = a; this.b = b; } @Override public int compareTo(Pair o) { return this.a - o.a; } } }
Main.java:9: error: package lombok does not exist import lombok.Data; ^ Main.java:84: error: cannot find symbol @Data ^ symbol: class Data location: class Main 2 errors
s525921546
p00200
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; line = br.readLine(); int n = Integer.valueOf(line.split(" ")[0]); int m = Integer.valueOf(line.split(" ")[1]); LinkedList<Rail> railList = new LinkedList<>(); for(int i = 1; i <= n; i++){ line = br.readLine(); String[] nums = line.split(" "); int a = Integer.valueOf(nums[0]); int b = Integer.valueOf(nums[1]); int cost = Integer.valueOf(nums[2]); int time = Integer.valueOf(nums[3]); railList.add(new Rail(a, b, cost, time)); } line = br.readLine(); int k = Integer.valueOf(line); while(true){ line = br.readLine(); if(line.equals("0 0")){ break; } String[] nums = line.split(" "); int p = Integer.valueOf(nums[0]); int p = Integer.valueOf(nums[0]); } } private static int getCost(LinkedList<Rail> railList, int p, int q){ int min = 9999; int cost = 0; LinkedList<Rail> railListTmp = new LinkedList<>(); while(!railList.isEmpty()){ Rail rail = railList.pop(); if((rail.getA() == p && rail.getB() == q) || (rail.getA() == q && rail.getB() == p)){ cost = rail.getCost(); }else if(rail.getA() == p){ LinkedList<Rail> railListTmp2 = new LinkedList<>(); railListTmp2.addAll(railList); railListTmp2.addAll(railListTmp); cost = rail.getCost() + getCost(railListTmp2, rail.getB(), q); }else if(rail.getB() == p){ LinkedList<Rail> railListTmp2 = new LinkedList<>(); railListTmp2.addAll(railList); railListTmp2.addAll(railListTmp); cost = rail.getCost() + getCost(railListTmp2, rail.getA(), q); }else{ railListTmp.push(rail); continue; } if(min > cost){ min = cost; } } return min; } private static int getTime(LinkedList<Rail> railList, int p, int q){ int min = 9999; int time = 0; LinkedList<Rail> railListTmp = new LinkedList<>(); while(!railList.isEmpty()){ Rail rail = railList.pop(); if((rail.getA() == p && rail.getB() == q) || (rail.getA() == q && rail.getB() == p)){ time = rail.getTime(); }else if(rail.getA() == p){ LinkedList<Rail> railListTmp2 = new LinkedList<>(); railListTmp2.addAll(railList); railListTmp2.addAll(railListTmp); time = rail.getTime() + getTime(railListTmp2, rail.getB(), q); }else if(rail.getB() == p){ LinkedList<Rail> railListTmp2 = new LinkedList<>(); railListTmp2.addAll(railList); railListTmp2.addAll(railListTmp); time = rail.getTime() + getTime(railListTmp2, rail.getA(), q); }else{ railListTmp.push(rail); continue; } if(min > time){ min = time; } } return min; } static class Rail { int a; int b; int cost; int time; public Rail(int a, int b, int cost, int time) { this.a = a; this.b = b; this.cost = cost; this.time = time; } public int getA() { return a; } public int getB() { return b; } public int getCost() { return cost; } public int getTime() { return time; } } }
Main.java:39: error: variable p is already defined in method main(String[]) int p = Integer.valueOf(nums[0]); ^ 1 error
s958351272
p00200
Java
import java.io.IOException; import java.util.LinkedList; import java.util.Scanner; public class Main2 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); LinkedList<Rail> railList = new LinkedList<>(); for(int i = 1; i <= n; i++){ int a = sc.nextInt(); int b = sc.nextInt(); int cost = sc.nextInt(); int time = sc.nextInt(); railList.add(new Rail(a, b, cost, time)); } int k = sc.nextInt(); for(int i = 0; i < k; i++){ int p = sc.nextInt(); int q = sc.nextInt(); int r = sc.nextInt(); LinkedList<Rail> railListTmp = new LinkedList<>(railList); if(r == 0){ System.out.println(getCost(railListTmp, p, q)); } if(r == 1){ System.out.println(getTime(railListTmp, p, q)); } } } private static int getCost(LinkedList<Rail> railList, int p, int q){ int min = 9999; int cost = 0; LinkedList<Rail> railListTmp = new LinkedList<>(); while(!railList.isEmpty()){ Rail rail = railList.pop(); if((rail.getA() == p && rail.getB() == q) || (rail.getA() == q && rail.getB() == p)){ cost = rail.getCost(); }else if(rail.getA() == p){ LinkedList<Rail> railListTmp2 = new LinkedList<>(); railListTmp2.addAll(railList); railListTmp2.addAll(railListTmp); cost = rail.getCost() + getCost(railListTmp2, rail.getB(), q); }else if(rail.getB() == p){ LinkedList<Rail> railListTmp2 = new LinkedList<>(); railListTmp2.addAll(railList); railListTmp2.addAll(railListTmp); cost = rail.getCost() + getCost(railListTmp2, rail.getA(), q); }else{ railListTmp.push(rail); continue; } if(min > cost){ min = cost; } } return min; } private static int getTime(LinkedList<Rail> railList, int p, int q){ int min = 9999; int time = 0; LinkedList<Rail> railListTmp = new LinkedList<>(); while(!railList.isEmpty()){ Rail rail = railList.pop(); if((rail.getA() == p && rail.getB() == q) || (rail.getA() == q && rail.getB() == p)){ time = rail.getTime(); }else if(rail.getA() == p){ LinkedList<Rail> railListTmp2 = new LinkedList<>(); railListTmp2.addAll(railList); railListTmp2.addAll(railListTmp); time = rail.getTime() + getTime(railListTmp2, rail.getB(), q); }else if(rail.getB() == p){ LinkedList<Rail> railListTmp2 = new LinkedList<>(); railListTmp2.addAll(railList); railListTmp2.addAll(railListTmp); time = rail.getTime() + getTime(railListTmp2, rail.getA(), q); }else{ railListTmp.push(rail); continue; } if(min > time){ min = time; } } return min; } static class Rail { int a; int b; int cost; int time; public Rail(int a, int b, int cost, int time) { this.a = a; this.b = b; this.cost = cost; this.time = time; } public int getA() { return a; } public int getB() { return b; } public int getCost() { return cost; } public int getTime() { return time; } } }
Main.java:6: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s754293148
p00200
Java
import java.util.*; import java.lang.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class P0200 { Scanner sc; long[][] time; long[][] cost; int n,m; int INF=1<<28; void run() { sc = new Scanner(System.in); while (true) { n = sc.nextInt(); m = sc.nextInt(); if (n == 0 && m == 0)break; time = new long[m][m]; cost = new long[m][m]; for(int j=0; j<m; j++){ fill(cost[j], INF); fill(time[j], INF); } for (int i=0;i<n;i++) { int s = sc.nextInt(); int e = sc.nextInt(); cost[s-1][e-1] = sc.nextInt(); time[s-1][e-1] = sc.nextInt(); cost[e-1][s-1] = cost[s-1][e-1]; time[e-1][s-1] = time[s-1][e-1]; } dijkstra(); int k = sc.nextInt(); for (int i=0;i<k;i++) { int p = sc.nextInt(); int q = sc.nextInt(); int r = sc.nextInt(); if (p == q) System.out.println(0); else if(r==1) System.out.println(time[p-1][q-1]); else System.out.println(cost[p-1][q-1]); } } } void dijkstra () { for (int i=0;i<m;i++){ for (int j=0;j<m;j++) { for (int k=0;k<m;k++) { cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]); time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]); } } } } public static void main(String[] args) { new P0200().run(); } }
Main.java:5: error: class P0200 is public, should be declared in a file named P0200.java public class P0200 { ^ 1 error
s299512184
p00200
Java
import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class P0200 { Scanner sc; long[][] time; long[][] cost; int n,m; int INF=1<<28; void run() { sc = new Scanner(System.in); while (true) { n = sc.nextInt(); m = sc.nextInt(); if (n == 0 && m == 0)break; time = new long[m][m]; cost = new long[m][m]; for(int j=0; j<m; j++){ fill(cost[j], INF); fill(time[j], INF); } for (int i=0;i<n;i++) { int s = sc.nextInt(); int e = sc.nextInt(); cost[s-1][e-1] = sc.nextInt(); time[s-1][e-1] = sc.nextInt(); cost[e-1][s-1] = cost[s-1][e-1]; time[e-1][s-1] = time[s-1][e-1]; } dijkstra(); int k = sc.nextInt(); for (int i=0;i<k;i++) { int p = sc.nextInt(); int q = sc.nextInt(); int r = sc.nextInt(); if (p == q) System.out.println(0); else if(r==1) System.out.println(time[p-1][q-1]); else System.out.println(cost[p-1][q-1]); } } } void dijkstra () { for (int i=0;i<m;i++){ for (int j=0;j<m;j++) { for (int k=0;k<m;k++) { cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]); time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]); } } } } public static void main(String[] args) { new P0200().run(); } }
Main.java:4: error: class P0200 is public, should be declared in a file named P0200.java public class P0200 { ^ 1 error
s002443373
p00200
Java
import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class P0200 { Scanner sc; long[][] time; long[][] cost; int n,m; int INF=1<<28; void run() { sc = new Scanner(System.in); while (true) { n = sc.nextInt(); m = sc.nextInt(); if (n == 0 && m == 0)break; time = new long[m][m]; cost = new long[m][m]; for(int j=0; j<m; j++){ fill(cost[j], INF); fill(time[j], INF); } for (int i=0;i<n;i++) { int s = sc.nextInt(); int e = sc.nextInt(); cost[s-1][e-1] = sc.nextInt(); time[s-1][e-1] = sc.nextInt(); cost[e-1][s-1] = cost[s-1][e-1]; time[e-1][s-1] = time[s-1][e-1]; } dijkstra(); int k = sc.nextInt(); for (int i=0;i<k;i++) { int p = sc.nextInt(); int q = sc.nextInt(); int r = sc.nextInt(); if (p == q) System.out.println(0); else if(r==1) System.out.println(time[p-1][q-1]); else System.out.println(cost[p-1][q-1]); } } } void dijkstra () { for (int i=0;i<m;i++){ for (int j=0;j<m;j++) { for (int k=0;k<m;k++) { cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]); time[i][j] = min(time[i][j], time[i][k] + time[k][j]); } } } } public static void main(String[] args) { new P0200().run(); } }
Main.java:4: error: class P0200 is public, should be declared in a file named P0200.java public class P0200 { ^ 1 error
s965477633
p00200
Java
import java.util.Arrays; import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; //Traveling Alone: One-way Ticket of Youth public class AOJ0200 { public static int n; public static int m; public static int[][] cost; public static int[][] time; public static int[] dist; public static int dijkstra(int start, int goal, int x){ Arrays.fill(dist, Integer.MAX_VALUE); dist[start] = 0; PriorityQueue<Integer> q = new PriorityQueue<Integer>(m, new Comparator<Integer>(){ public int compare(Integer o1, Integer o2) { return dist[o1]-dist[o2]; } }); q.add(start); while(!q.isEmpty()){ int u = q.poll(); if(u==goal)return dist[goal]; if(x==0){ for(int i=0;i<m;i++){ if(cost[u][i]!=Integer.MAX_VALUE && dist[u]+cost[u][i] < dist[i]){ dist[i] = dist[u] + cost[u][i]; q.remove(i); q.add(i); } } } else{ for(int i=0;i<m;i++){ if(time[u][i]!=Integer.MAX_VALUE && dist[u]+time[u][i] < dist[i]){ dist[i] = dist[u] + time[u][i]; q.remove(i); q.add(i); } } } } return -1; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true){ n = sc.nextInt(); m = sc.nextInt(); if(n==0&&m==0)break; cost = new int[m][m]; time = new int[m][m]; dist = new int[m]; int[][] dcost = new int[m][m]; int[][] dtime = new int[m][m]; for(int[] a:cost)Arrays.fill(a, Integer.MAX_VALUE); for(int[] a:time)Arrays.fill(a, Integer.MAX_VALUE); for(int[] a:dcost)Arrays.fill(a, 1000000); for(int[] a:dtime)Arrays.fill(a, 1000000); for(int i=0;i<m;i++)dcost[i][i]=dtime[i][i]=0; while(n--!=0){ int a = sc.nextInt()-1; int b = sc.nextInt()-1; int c = sc.nextInt(); int t = sc.nextInt(); // if(cost[a][b] > c) cost[a][b] = cost[b][a] = c; dcost[a][b] = dcost[b][a] = Math.min(dcost[a][b], c); // if(time[a][b] > t) time[a][b] = time[b][a] = t; dtime[a][b] = dtime[b][a] = Math.min(dtime[a][b], t); } for(int k=0;k<m;k++){ for(int i=0;i<m;i++){ for(int j=0;j<m;j++){ dcost[i][j] = Math.min(dcost[i][j], dcost[i][k]+dcost[k][j]); dtime[i][j] = Math.min(dtime[i][j], dtime[i][k]+dtime[k][j]); } } } int k = sc.nextInt(); while(k--!=0){ int s = sc.nextInt()-1; int t = sc.nextInt()-1; int x = sc.nextInt(); System.out.println(x==0?dcost[s][t]:dtime[s][t]); // System.out.println(dijkstra(s, t, x)); } } } }
Main.java:7: error: class AOJ0200 is public, should be declared in a file named AOJ0200.java public class AOJ0200 { ^ 1 error
s490434652
p00200
Java
import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; public class Main{ int num1; int state1; int price1; public TravelingAlone(int num, int state, int price){ num1 = num; state1 = state; price1 = price; } public void changecost(int cost){ num1 = cost; } public void changeprice(int price){ price1 = price; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(true){ int railNum = sc.nextInt(); int stationNum = sc.nextInt(); if(railNum == 0 && stationNum ==0){ break; } int[][] rail = new int[4][railNum]; int[][] railcost = new int[stationNum + 1][stationNum + 1]; int[][] railprice = new int[stationNum + 1][stationNum + 1]; TravelingAlone[] stationcost = new TravelingAlone[stationNum + 1]; for(int i = 0; i < stationNum + 1; i++){ for(int j = 0; j < stationNum + 1; j++){ railcost[j][i] = Integer.MAX_VALUE; railprice[j][i] = Integer.MAX_VALUE; } } for(int i = 0; i < railNum; i++){ rail[0][i] = sc.nextInt(); rail[1][i] = sc.nextInt(); rail[2][i] = sc.nextInt(); rail[3][i] = sc.nextInt(); railcost[rail[0][i]][rail[1][i]] = railcost[rail[1][i]][rail[0][i]] = rail[3][i]; railprice[rail[0][i]][rail[1][i]] = railprice[rail[1][i]][rail[0][i]] = rail[2][i]; } int toiawaseNum = sc.nextInt(); int[][] toiawase = new int[3][toiawaseNum]; for(int i = 0; i < toiawaseNum; i++){ toiawase[0][i] = sc.nextInt(); toiawase[1][i] = sc.nextInt(); toiawase[2][i] = sc.nextInt(); } PriorityQueue<TravelingAlone> queuecost = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { @Override public int compare(TravelingAlone o1, TravelingAlone o2) { return o1.num1 - o2.num1; } }); PriorityQueue<TravelingAlone> queueprice = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { @Override public int compare(TravelingAlone o1, TravelingAlone o2) { return o1.price1 - o2.price1; } }); int station; int cost; int price; int costsize; int pricesize; for(int ans = 0; ans < toiawaseNum; ans++){ for(int i = 1; i <= stationNum; i++){ stationcost[i] = new TravelingAlone(Integer.MAX_VALUE, i, Integer.MAX_VALUE); } stationcost[toiawase[0][ans]] = new TravelingAlone(0, ans + 1, 0); queuecost.clear(); queueprice.clear(); queuecost.offer(stationcost[toiawase[0][ans]]); queueprice.offer(stationcost[toiawase[0][ans]]); while(true){ costsize = queuecost.size(); pricesize = queueprice.size(); if(costsize == 0 && pricesize == 0){ break; } for(int i = 0; i < costsize; i++){ station = queuecost.peek().state1; cost = queuecost.poll().num1; for(int j = 1; j < stationNum + 1; j++){ if(railcost[j][station] != Integer.MAX_VALUE && stationcost[j].num1 > cost + railcost[j][station]){ stationcost[j].changecost(cost + railcost[j][station]); queuecost.offer(stationcost[j]); } } } for(int i = 0; i < pricesize; i++){ station = queueprice.peek().state1; price = queueprice.poll().price1; for(int j = 1; j < stationNum + 1; j++){ if(railprice[j][station] != Integer.MAX_VALUE && stationcost[j].price1 > price + railprice[j][station]){ stationcost[j].changeprice(price + railprice[j][station]); queueprice.offer(stationcost[j]); } } } } if(toiawase[2][ans] == 0){ System.out.println(stationcost[toiawase[1][ans]].price1); }else{ System.out.println(stationcost[toiawase[1][ans]].num1); } } } } }
Main.java:12: error: invalid method declaration; return type required public TravelingAlone(int num, int state, int price){ ^ 1 error
s958047409
p00200
Java
import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; public class Main{ int num1; int state1; int price1; public TravelingAlone(int num, int state, int price){ num1 = num; state1 = state; price1 = price; } public void changecost(int cost){ num1 = cost; } public void changeprice(int price){ price1 = price; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(true){ int railNum = sc.nextInt(); int stationNum = sc.nextInt(); if(railNum == 0 && stationNum ==0){ break; } int[][] rail = new int[4][railNum]; int[][] railcost = new int[stationNum + 1][stationNum + 1]; int[][] railprice = new int[stationNum + 1][stationNum + 1]; TravelingAlone[] stationcost = new TravelingAlone[stationNum + 1]; for(int i = 0; i < stationNum + 1; i++){ for(int j = 0; j < stationNum + 1; j++){ railcost[j][i] = Integer.MAX_VALUE; railprice[j][i] = Integer.MAX_VALUE; } } for(int i = 0; i < railNum; i++){ rail[0][i] = sc.nextInt(); rail[1][i] = sc.nextInt(); rail[2][i] = sc.nextInt(); rail[3][i] = sc.nextInt(); railcost[rail[0][i]][rail[1][i]] = railcost[rail[1][i]][rail[0][i]] = rail[3][i]; railprice[rail[0][i]][rail[1][i]] = railprice[rail[1][i]][rail[0][i]] = rail[2][i]; } int toiawaseNum = sc.nextInt(); int[][] toiawase = new int[3][toiawaseNum]; for(int i = 0; i < toiawaseNum; i++){ toiawase[0][i] = sc.nextInt(); toiawase[1][i] = sc.nextInt(); toiawase[2][i] = sc.nextInt(); } PriorityQueue<TravelingAlone> queuecost = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { @Override public int compare(TravelingAlone o1, TravelingAlone o2) { return o1.num1 - o2.num1; } }); PriorityQueue<TravelingAlone> queueprice = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { @Override public int compare(TravelingAlone o1, TravelingAlone o2) { return o1.price1 - o2.price1; } }); int station; int cost; int price; int costsize; int pricesize; for(int ans = 0; ans < toiawaseNum; ans++){ for(int i = 1; i <= stationNum; i++){ stationcost[i] = new TravelingAlone(Integer.MAX_VALUE, i, Integer.MAX_VALUE); } stationcost[toiawase[0][ans]] = new TravelingAlone(0, ans + 1, 0); queuecost.clear(); queueprice.clear(); queuecost.offer(stationcost[toiawase[0][ans]]); queueprice.offer(stationcost[toiawase[0][ans]]); while(true){ costsize = queuecost.size(); pricesize = queueprice.size(); if(costsize == 0 && pricesize == 0){ break; } for(int i = 0; i < costsize; i++){ station = queuecost.peek().state1; cost = queuecost.poll().num1; for(int j = 1; j < stationNum + 1; j++){ if(railcost[j][station] != Integer.MAX_VALUE && stationcost[j].num1 > cost + railcost[j][station]){ stationcost[j].changecost(cost + railcost[j][station]); queuecost.offer(stationcost[j]); } } } for(int i = 0; i < pricesize; i++){ station = queueprice.peek().state1; price = queueprice.poll().price1; for(int j = 1; j < stationNum + 1; j++){ if(railprice[j][station] != Integer.MAX_VALUE && stationcost[j].price1 > price + railprice[j][station]){ stationcost[j].changeprice(price + railprice[j][station]); queueprice.offer(stationcost[j]); } } } } if(toiawase[2][ans] == 0){ System.out.println(stationcost[toiawase[1][ans]].price1); }else{ System.out.println(stationcost[toiawase[1][ans]].num1); } } } } }
Main.java:12: error: invalid method declaration; return type required public TravelingAlone(int num, int state, int price){ ^ 1 error
s684044902
p00200
Java
import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; public class TravelingAlone{ int num1; int state1; int price1; public TravelingAlone(int num, int state, int price){ num1 = num; state1 = state; price1 = price; } public void changecost(int cost){ num1 = cost; } public void changeprice(int price){ price1 = price; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(true){ int railNum = sc.nextInt(); int stationNum = sc.nextInt(); if(railNum == 0 && stationNum ==0){ break; } int[][] rail = new int[4][railNum]; int[][] railcost = new int[stationNum + 1][stationNum + 1]; int[][] railprice = new int[stationNum + 1][stationNum + 1]; TravelingAlone[] stationcost = new TravelingAlone[stationNum + 1]; for(int i = 0; i < stationNum + 1; i++){ for(int j = 0; j < stationNum + 1; j++){ railcost[j][i] = Integer.MAX_VALUE; railprice[j][i] = Integer.MAX_VALUE; } } for(int i = 0; i < railNum; i++){ rail[0][i] = sc.nextInt(); rail[1][i] = sc.nextInt(); rail[2][i] = sc.nextInt(); rail[3][i] = sc.nextInt(); railcost[rail[0][i]][rail[1][i]] = railcost[rail[1][i]][rail[0][i]] = rail[3][i]; railprice[rail[0][i]][rail[1][i]] = railprice[rail[1][i]][rail[0][i]] = rail[2][i]; } int toiawaseNum = sc.nextInt(); int[][] toiawase = new int[3][toiawaseNum]; for(int i = 0; i < toiawaseNum; i++){ toiawase[0][i] = sc.nextInt(); toiawase[1][i] = sc.nextInt(); toiawase[2][i] = sc.nextInt(); } PriorityQueue<TravelingAlone> queuecost = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { @Override public int compare(TravelingAlone o1, TravelingAlone o2) { return o1.num1 - o2.num1; } }); PriorityQueue<TravelingAlone> queueprice = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { @Override public int compare(TravelingAlone o1, TravelingAlone o2) { return o1.price1 - o2.price1; } }); int station; int cost; int price; int costsize; int pricesize; for(int ans = 0; ans < toiawaseNum; ans++){ for(int i = 1; i <= stationNum; i++){ stationcost[i] = new TravelingAlone(Integer.MAX_VALUE, i, Integer.MAX_VALUE); } stationcost[toiawase[0][ans]] = new TravelingAlone(0, ans + 1, 0); queuecost.clear(); queueprice.clear(); queuecost.offer(stationcost[toiawase[0][ans]]); queueprice.offer(stationcost[toiawase[0][ans]]); while(true){ costsize = queuecost.size(); pricesize = queueprice.size(); if(costsize == 0 && pricesize == 0){ break; } for(int i = 0; i < costsize; i++){ station = queuecost.peek().state1; cost = queuecost.poll().num1; for(int j = 1; j < stationNum + 1; j++){ if(railcost[j][station] != Integer.MAX_VALUE && stationcost[j].num1 > cost + railcost[j][station]){ stationcost[j].changecost(cost + railcost[j][station]); queuecost.offer(stationcost[j]); } } } for(int i = 0; i < pricesize; i++){ station = queueprice.peek().state1; price = queueprice.poll().price1; for(int j = 1; j < stationNum + 1; j++){ if(railprice[j][station] != Integer.MAX_VALUE && stationcost[j].price1 > price + railprice[j][station]){ stationcost[j].changeprice(price + railprice[j][station]); queueprice.offer(stationcost[j]); } } } } if(toiawase[2][ans] == 0){ System.out.println(stationcost[toiawase[1][ans]].price1); }else{ System.out.println(stationcost[toiawase[1][ans]].num1); } } } } }
Main.java:6: error: class TravelingAlone is public, should be declared in a file named TravelingAlone.java public class TravelingAlone{ ^ 1 error
s996032553
p00200
Java
import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; public class Main{ int num1; int state1; int price1; public Main(int num, int state, int price){ num1 = num; state1 = state; price1 = price; } public void changecost(int cost){ num1 = cost; } public void changeprice(int price){ price1 = price; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(true){ int railNum = sc.nextInt(); int stationNum = sc.nextInt(); if(railNum == 0 && stationNum ==0){ break; } int[][] rail = new int[4][railNum]; int[][] railcost = new int[stationNum + 1][stationNum + 1]; int[][] railprice = new int[stationNum + 1][stationNum + 1]; TravelingAlone[] stationcost = new TravelingAlone[stationNum + 1]; for(int i = 0; i < stationNum + 1; i++){ for(int j = 0; j < stationNum + 1; j++){ railcost[j][i] = Integer.MAX_VALUE; railprice[j][i] = Integer.MAX_VALUE; } } for(int i = 0; i < railNum; i++){ rail[0][i] = sc.nextInt(); rail[1][i] = sc.nextInt(); rail[2][i] = sc.nextInt(); rail[3][i] = sc.nextInt(); railcost[rail[0][i]][rail[1][i]] = railcost[rail[1][i]][rail[0][i]] = rail[3][i]; railprice[rail[0][i]][rail[1][i]] = railprice[rail[1][i]][rail[0][i]] = rail[2][i]; } int toiawaseNum = sc.nextInt(); int[][] toiawase = new int[3][toiawaseNum]; for(int i = 0; i < toiawaseNum; i++){ toiawase[0][i] = sc.nextInt(); toiawase[1][i] = sc.nextInt(); toiawase[2][i] = sc.nextInt(); } PriorityQueue<TravelingAlone> queuecost = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { @Override public int compare(TravelingAlone o1, TravelingAlone o2) { return o1.num1 - o2.num1; } }); PriorityQueue<TravelingAlone> queueprice = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { @Override public int compare(TravelingAlone o1, TravelingAlone o2) { return o1.price1 - o2.price1; } }); int station; int cost; int price; int costsize; int pricesize; for(int ans = 0; ans < toiawaseNum; ans++){ for(int i = 1; i <= stationNum; i++){ stationcost[i] = new TravelingAlone(Integer.MAX_VALUE, i, Integer.MAX_VALUE); } stationcost[toiawase[0][ans]] = new TravelingAlone(0, ans + 1, 0); queuecost.clear(); queueprice.clear(); queuecost.offer(stationcost[toiawase[0][ans]]); queueprice.offer(stationcost[toiawase[0][ans]]); while(true){ costsize = queuecost.size(); pricesize = queueprice.size(); if(costsize == 0 && pricesize == 0){ break; } for(int i = 0; i < costsize; i++){ station = queuecost.peek().state1; cost = queuecost.poll().num1; for(int j = 1; j < stationNum + 1; j++){ if(railcost[j][station] != Integer.MAX_VALUE && stationcost[j].num1 > cost + railcost[j][station]){ stationcost[j].changecost(cost + railcost[j][station]); queuecost.offer(stationcost[j]); } } } for(int i = 0; i < pricesize; i++){ station = queueprice.peek().state1; price = queueprice.poll().price1; for(int j = 1; j < stationNum + 1; j++){ if(railprice[j][station] != Integer.MAX_VALUE && stationcost[j].price1 > price + railprice[j][station]){ stationcost[j].changeprice(price + railprice[j][station]); queueprice.offer(stationcost[j]); } } } } if(toiawase[2][ans] == 0){ System.out.println(stationcost[toiawase[1][ans]].price1); }else{ System.out.println(stationcost[toiawase[1][ans]].num1); } } } } }
Main.java:42: error: cannot find symbol TravelingAlone[] stationcost = new TravelingAlone[stationNum + 1]; ^ symbol: class TravelingAlone location: class Main Main.java:42: error: cannot find symbol TravelingAlone[] stationcost = new TravelingAlone[stationNum + 1]; ^ symbol: class TravelingAlone location: class Main Main.java:69: error: cannot find symbol PriorityQueue<TravelingAlone> queuecost = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { ^ symbol: class TravelingAlone location: class Main Main.java:69: error: cannot find symbol PriorityQueue<TravelingAlone> queuecost = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { ^ symbol: class TravelingAlone location: class Main Main.java:69: error: cannot find symbol PriorityQueue<TravelingAlone> queuecost = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { ^ symbol: class TravelingAlone location: class Main Main.java:72: error: cannot find symbol public int compare(TravelingAlone o1, TravelingAlone o2) { ^ symbol: class TravelingAlone Main.java:72: error: cannot find symbol public int compare(TravelingAlone o1, TravelingAlone o2) { ^ symbol: class TravelingAlone Main.java:77: error: cannot find symbol PriorityQueue<TravelingAlone> queueprice = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { ^ symbol: class TravelingAlone location: class Main Main.java:77: error: cannot find symbol PriorityQueue<TravelingAlone> queueprice = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { ^ symbol: class TravelingAlone location: class Main Main.java:77: error: cannot find symbol PriorityQueue<TravelingAlone> queueprice = new PriorityQueue<TravelingAlone>(stationNum, new Comparator<TravelingAlone>() { ^ symbol: class TravelingAlone location: class Main Main.java:80: error: cannot find symbol public int compare(TravelingAlone o1, TravelingAlone o2) { ^ symbol: class TravelingAlone Main.java:80: error: cannot find symbol public int compare(TravelingAlone o1, TravelingAlone o2) { ^ symbol: class TravelingAlone Main.java:94: error: cannot find symbol stationcost[i] = new TravelingAlone(Integer.MAX_VALUE, i, Integer.MAX_VALUE); ^ symbol: class TravelingAlone location: class Main Main.java:96: error: cannot find symbol stationcost[toiawase[0][ans]] = new TravelingAlone(0, ans + 1, 0); ^ symbol: class TravelingAlone location: class Main 14 errors
s718454424
p00200
Java
import java.util.LinkedList; import java.util.Scanner; public class TravelingAlone { class Main { int from, to, cost, time; public Edge(int from, int to, int cost, int time) { // TODO 自動生成されたコンストラクター・スタブ this.from = from; this.to = to; this.cost = cost; this.time = time; } } int n, m; LinkedList<Edge> edges; void solve(int p, int q, int r) { int INF = Integer.MAX_VALUE; int[] d = new int[m + 1]; // 各駅への最短距離 for (int i = 0; i < d.length; i++) d[i] = INF / 2; d[p] = 0; while (true) { boolean update = false; for (Edge e : edges) { if (d[e.from] != INF && d[e.to] > d[e.from] + (r == 0 ? e.cost : e.time)) { d[e.to] = d[e.from] + (r == 0 ? e.cost : e.time); update = true; } } if (!update) break; } System.out.println(d[q]); } int[][] warshall_floyd(int r) { int INF = Integer.MAX_VALUE / 2; int[][] d = new int[m+1][m+1]; for(int i=0; i < d.length; i++) for(int j=0; j < d[0].length; j++) d[i][j] = INF; for(Edge e : edges) d[e.from][e.to] = (r == 0 ? e.cost : e.time); for(int k=1; k < m+1; k++) for(int i=1; i < m+1; i++) for(int j=1; j < m+1; j++) d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]); return d; } void run() { Scanner scanner = new Scanner(System.in); while (true) { n = scanner.nextInt(); m = scanner.nextInt(); if (n == 0 || m == 0) break; edges = new LinkedList<Edge>(); for (int i = 0; i < n; i++) { int a = scanner.nextInt(); int b = scanner.nextInt(); int cost = scanner.nextInt(); int time = scanner.nextInt(); edges.add(new Edge(a, b, cost, time)); edges.add(new Edge(b, a, cost, time)); } int k = scanner.nextInt(); if (k == 0) return; int[][][] d = new int[2][][]; d[0] = warshall_floyd(0); d[1] = warshall_floyd(1); for (int i = 0; i < k; i++) { int p = scanner.nextInt(); int q = scanner.nextInt(); int r = scanner.nextInt(); System.out.println(d[r][p][q]); } } } public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ new Main().run(); } }
Main.java:8: error: invalid method declaration; return type required public Edge(int from, int to, int cost, int time) { ^ 1 error
s819672969
p00200
Java
import java.util.*; public class Traveling_Alone { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); int m = sc.nextInt(); if ((n | m) == 0) break; int[][] costTable = new int[m][m]; int[][] timeTable = new int[m][m]; for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) { costTable[i][j] = 0; timeTable[i][j] = 0; } for (int i = 0; i < n; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; int cost = sc.nextInt(); int time = sc.nextInt(); costTable[a][b] = cost; costTable[b][a] = cost; timeTable[a][b] = time; timeTable[b][a] = time; } int[][] mincost = new int[m][m]; int[][] mintime = new int[m][m]; for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { mincost[i][j] = Integer.MAX_VALUE; mintime[i][j] = Integer.MAX_VALUE; } PriorityQueue<Data> costQueue = new PriorityQueue<Data>(); PriorityQueue<Data> timeQueue = new PriorityQueue<Data>(); costQueue.add(new Data(0, i)); timeQueue.add(new Data(0, i)); while (!costQueue.isEmpty()) { Data d = costQueue.poll(); if (d.cost < mincost[i][d.num]) { mincost[i][d.num] = d.cost; for (int j = 0; j < m; j++) if (costTable[d.num][j] > 0) costQueue.add(new Data(d.cost + costTable[d.num][j], j)); } } while (!timeQueue.isEmpty()) { Data d = timeQueue.poll(); if (d.cost < mintime[i][d.num]) { mintime[i][d.num] = d.cost; for (int j = 0; j < m; j++) if (timeTable[d.num][j] > 0) timeQueue.add(new Data(d.cost + timeTable[d.num][j], j)); } } } int k = sc.nextInt(); for (int i = 0; i < k; i++) { int p = sc.nextInt() - 1; int q = sc.nextInt() - 1; int r = sc.nextInt(); if (r == 0) System.out.println(mincost[p][q]); if (r == 1) System.out.println(mintime[p][q]); } } sc.close(); } } class Data implements Comparable<Data> { int cost; int num; Data(int c, int n) { cost = c; num = n; } public int compareTo(Data o) { return new Integer(this.cost).compareTo(new Integer(o.cost)); } }
Main.java:3: error: class Traveling_Alone is public, should be declared in a file named Traveling_Alone.java public class Traveling_Alone { ^ Main.java:85: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal return new Integer(this.cost).compareTo(new Integer(o.cost)); ^ Main.java:85: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal return new Integer(this.cost).compareTo(new Integer(o.cost)); ^ 1 error 2 warnings
s658956289
p00200
Java
import java.util.*; public class Traveling_Alone { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); int m = sc.nextInt(); if ((n | m) == 0) break; int[][] costTable = new int[m][m]; int[][] timeTable = new int[m][m]; for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) { costTable[i][j] = 0; timeTable[i][j] = 0; } for (int i = 0; i < n; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; int cost = sc.nextInt(); int time = sc.nextInt(); costTable[a][b] = cost; costTable[b][a] = cost; timeTable[a][b] = time; timeTable[b][a] = time; } int[][] mincost = new int[m][m]; int[][] mintime = new int[m][m]; for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { mincost[i][j] = Integer.MAX_VALUE; mintime[i][j] = Integer.MAX_VALUE; } PriorityQueue<Data> costQueue = new PriorityQueue<Data>(); PriorityQueue<Data> timeQueue = new PriorityQueue<Data>(); costQueue.add(new Data(0, i)); timeQueue.add(new Data(0, i)); while (!costQueue.isEmpty()) { Data d = costQueue.poll(); if (d.cost < mincost[i][d.num]) { mincost[i][d.num] = d.cost; for (int j = 0; j < m; j++) if (costTable[d.num][j] > 0) costQueue.add(new Data(d.cost + costTable[d.num][j], j)); } } while (!timeQueue.isEmpty()) { Data d = timeQueue.poll(); if (d.cost < mintime[i][d.num]) { mintime[i][d.num] = d.cost; for (int j = i; j < m; j++) if (timeTable[d.num][j] > 0) timeQueue.add(new Data(d.cost + timeTable[d.num][j], j)); } } } int k = sc.nextInt(); for (int i = 0; i < k; i++) { int p = sc.nextInt() - 1; int q = sc.nextInt() - 1; int r = sc.nextInt(); if (r == 0) System.out.println(mincost[p][q]); if (r == 1) System.out.println(mintime[p][q]); } } sc.close(); } } class Data implements Comparable<Data> { int cost; int num; Data(int c, int n) { cost = c; num = n; } public int compareTo(Data o) { return new Integer(this.cost).compareTo(new Integer(o.cost)); } }
Main.java:3: error: class Traveling_Alone is public, should be declared in a file named Traveling_Alone.java public class Traveling_Alone { ^ Main.java:85: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal return new Integer(this.cost).compareTo(new Integer(o.cost)); ^ Main.java:85: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal return new Integer(this.cost).compareTo(new Integer(o.cost)); ^ 1 error 2 warnings
s377541866
p00200
C
for(k=0; k<m; i++){ for(i=0; i<m; i++){ for(j=0; j<m; j++){ cost[i][j]=(cost[i][j]>cost[i][k]+cost[k][j])?(cost[i][k]+cost[k][j]):cost[i][j]; cost[j][i]=cost[i][j]; time[i][j]=(time[i][j]>time[i][k]+time[k][j])?(time[i][k]+time[k][j]):time[i][j]; time[j][i]=time[i][j]; } } }
main.c:2:17: error: expected identifier or '(' before 'for' 2 | for(k=0; k<m; i++){ | ^~~ main.c:2:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 2 | for(k=0; k<m; i++){ | ^ main.c:2:32: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 2 | for(k=0; k<m; i++){ | ^~