submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s545789896
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; vector<int> buttons(N); for (int i=0;i<N;++i){ cin>>buttons.at(i); } int on = 0; for (int i=0;i<=N;++i){ if (on == 1){ cout << i << endl; return; } on = buttons.at(on) } cout<<-1<<endl; }
a.cc: In function 'int main()': a.cc:18:13: error: return-statement with no value, in function returning 'int' [-fpermissive] 18 | return; | ^~~~~~ a.cc:20:28: error: expected ';' before '}' token 20 | on = buttons.at(on) | ^ | ; 21 | } | ~
s176446726
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> avec(N); for (int i = 0; i < N; i++) { cin >> avec.at(i); } int now = 1; cnt = 0; while(1) { if (now == 2) { cout << cnt << endl; break; } if (cnt >= n) { cout << "-1" << endl; break; } now = avec.at(now); cnt++; } return 0; }
a.cc: In function 'int main()': a.cc:12:18: error: 'cnt' was not declared in this scope; did you mean 'int'? 12 | int now = 1; cnt = 0; | ^~~ | int a.cc:18:20: error: 'n' was not declared in this scope 18 | if (cnt >= n) { | ^
s394705212
p03680
C
#include <stdio.h> int main(){ int n,count=0,point=1; scanf("%d",&n); int a[n],b[n]; for (int i=0;i<n;i++){ scanf("%d",&a[i]); b[i]=0; } while(){ if (point==2){ break; } if (b[point-1]==1){ count=-1; break; } point=a[point-1]; b[point-1]=1; count++; } printf("%d\n",count); return 0; }
main.c: In function 'main': main.c:10:12: error: expected expression before ')' token 10 | while(){ | ^
s142757612
p03680
C
#include <stdio.h> int main(){ int n,count=0,point=1; scanf("%d",&n); int a[n],b[n]; for (int i=0;i<n;i++){ scanf("%d",&a[i]); b[i]=0; } for (int i=0;i<n;i++){ if (point==2){ break; } if (point==i+1 && b[i]==1){ count=-1; break; } if (point==i+1 && b[i]==0){ point=a[i]; b[i]=1; count++ i=0; } } printf("%d\n",count); return 0; }
main.c: In function 'main': main.c:21:20: error: expected ';' before 'i' 21 | count++ | ^ | ; 22 | i=0; | ~
s100437568
p03680
C
#include<stdio.h> int main(){ int N, b[100000], push, b[100000] = {0}, count = 0; scanf("%d", &N); for (i = 0; i < N; i++){ scanf("%d", &a[i]); } push = a[0]; b[0] = 1; while(1){ count++; if(b[push - 1] == 1){ printf("-1\n"); return 0; } if(push == 2){ printf("%d\n", count); return 0; } a[push - 1] = 1; push = a[push - 1]; } }
main.c: In function 'main': main.c:4:27: error: redeclaration of 'b' with no linkage 4 | int N, b[100000], push, b[100000] = {0}, count = 0; | ^ main.c:4:10: note: previous declaration of 'b' with type 'int[100000]' 4 | int N, b[100000], push, b[100000] = {0}, count = 0; | ^ main.c:7:8: error: 'i' undeclared (first use in this function) 7 | for (i = 0; i < N; i++){ | ^ main.c:7:8: note: each undeclared identifier is reported only once for each function it appears in main.c:8:18: error: 'a' undeclared (first use in this function) 8 | scanf("%d", &a[i]); | ^
s453415836
p03680
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define repi(i, start, end) for(int i = start; i < end; i++) #define all(x) (x).begin(), (x).end() #define debug(x) cout << (x) << endl; #define INF (1e9) int dx[] = {0, 1, 0, -1}; int dy[] = {-1, 0, 1, 0}; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> buttons(n); rep(i, n) cin >> buttons[i]; int put = 0; bool flag = false; rep(i, n){ if(put == 1){ cout << i << endl; flag = true; break; } put = buttons[put] - 1; } if(!flag) cout << -1 << endl;
a.cc: In function 'int main()': a.cc:38:34: error: expected '}' at end of input 38 | if(!flag) cout << -1 << endl; | ^ a.cc:16:11: note: to match this '{' 16 | int main(){ | ^
s839229682
p03680
C++
#include <iostream> #include <algorithm> using namespace std; int main(){ int N,a[100000],b[100000],ans; cin >> N; int b[0]=1; bool X =false; for (int i=0; i<N; ++i){ b[i+1]=a[b[i]] if (b[i]==2){ ans=i; break; } } if (X) cout << ans << endl; else cout << -1 << endl; }
a.cc: In function 'int main()': a.cc:8:9: error: conflicting declaration 'int b [0]' 8 | int b[0]=1; | ^ a.cc:6:21: note: previous declaration as 'int b [100000]' 6 | int N,a[100000],b[100000],ans; | ^ a.cc:11:23: error: expected ';' before 'if' 11 | b[i+1]=a[b[i]] | ^ | ; 12 | if (b[i]==2){ | ~~
s605019158
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> buttons(N+1); for (int i = 1; i <= N; i++) { cin >> buttons.at(i); } // search all vector<bool> pushed(N+1); int i = 1; for (int x = 0; x <= N; x++) pushed.at(x) = false; int count = 0; while (true) { pushed.at(i) = true; count++; // next button i = buttons.at(i); // reached button2 ? if ( i == 2 ) { cout << count << endl; break; } å // infinite loop ? if ((pushed.at(i) || (count >= N)) { cout << -1 << endl; break; } } }
a.cc: In function 'int main()': a.cc:34:5: error: '\U000000e5' was not declared in this scope 34 | å | ^
s395176388
p03680
C++
#include <iostream> using namespace std; int N; int a[100010]; int main () { cin >> N; for (int i = 0; i < N; i++) { cin >> A[i + 1]; } int cur = 1; for (int i = 0; i < N; i++) { cur = a[cur]; if (cur == 2) { cout << i + 1 << endl; return 0; } } cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:11:16: error: 'A' was not declared in this scope 11 | cin >> A[i + 1]; | ^
s535194618
p03680
C++
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() typedef long long ll; int main(){ int n; cin>>n; int a[n+1]; int b[n+1]={}; for(int i=1,i<=n,i++)cin>>a[i]; n=1; b[n]=1; int count=0; while(n!=2){n=a[n];if(b[n]){break;cout<<-1<<endl;return 0;}b[n]=1;count++;} cout<<count<<endl; return 0; }
a.cc: In function 'int main()': a.cc:11:22: error: expected ';' before '<=' token 11 | for(int i=1,i<=n,i++)cin>>a[i]; | ^~ | ; a.cc:11:22: error: expected primary-expression before '<=' token 11 | for(int i=1,i<=n,i++)cin>>a[i]; | ^~ a.cc:11:29: error: expected ';' before ')' token 11 | for(int i=1,i<=n,i++)cin>>a[i]; | ^ | ;
s623058362
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int n,; cin >> n; vector<int> a(n); for (int i = 0; i < n; i ++) { cin >> a.at(i); } int now = 0, cnt = 0; while (true) { if (now == 1) { cout << cnt << endl; return 0; } if (cnt >= n) { cout << -1 << endl; return 0; } cnt ++; now = a.at(now); } }
a.cc: In function 'int main()': a.cc:5:9: error: expected unqualified-id before ';' token 5 | int n,; | ^
s662604505
p03680
C++
#include<iostream> using namespace std; int main(){ int n;cin>>n; int A[n];for(int i=0;i<n;i++)cin>>A[i]; int ans=0,now=0; for(;;){ if(now==1){ cout<<c<<endl; break } if(c>=n){ cout<<-1<<endl; break; } c++; now=A[now]; } }
a.cc: In function 'int main()': a.cc:10:13: error: 'c' was not declared in this scope 10 | cout<<c<<endl; | ^ a.cc:11:12: error: expected ';' before '}' token 11 | break | ^ | ; 12 | } | ~ a.cc:13:8: error: 'c' was not declared in this scope 13 | if(c>=n){ | ^ a.cc:17:5: error: 'c' was not declared in this scope 17 | c++; | ^
s128045217
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N+1); for(int i=1;i<N+1;i++){ cin >> a[i]; } int b=1; for(int i=1;i<N+1;i++){ b=a[b]; if(b==2){ cout << i << endl; return 0; break; } } cout << -1 << endl;
a.cc: In function 'int main()': a.cc:24:22: error: expected '}' at end of input 24 | cout << -1 << endl; | ^ a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s544617922
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N+1); for(int i=1;i<N+1;i++){ cin >> a[i]; } int b=1; for(int i=1;i<N+1;i++){ b=a[b]; if(b==2){ cout << i << endl; return 0; } } cout << -1 << endl;
a.cc: In function 'int main()': a.cc:23:22: error: expected '}' at end of input 23 | cout << -1 << endl; | ^ a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s001498352
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for(i=0;i<N;i++){ cin >> a[i]; } int b=0; for(i=0;i<N;i++){ b=a[b]-1; if(b==1){ cout << i+1 << endl; break; return 0; } } cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:7: error: 'i' was not declared in this scope 8 | for(i=0;i<N;i++){ | ^ a.cc:13:7: error: 'i' was not declared in this scope 13 | for(i=0;i<N;i++){ | ^
s128843914
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vectro<int> a(N); for(i=0;i<N;i++){ cin >> a[i]; } int b=0; for(i=0;i<N;i++){ b=a[b]-1; if(b==1){ cout << i+1 << endl; break; return 0; } } cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:7:3: error: 'vectro' was not declared in this scope 7 | vectro<int> a(N); | ^~~~~~ a.cc:7:10: error: expected primary-expression before 'int' 7 | vectro<int> a(N); | ^~~ a.cc:8:7: error: 'i' was not declared in this scope 8 | for(i=0;i<N;i++){ | ^ a.cc:9:12: error: 'a' was not declared in this scope 9 | cin >> a[i]; | ^ a.cc:13:7: error: 'i' was not declared in this scope 13 | for(i=0;i<N;i++){ | ^ a.cc:14:7: error: 'a' was not declared in this scope 14 | b=a[b]-1; | ^
s557532775
p03680
Java
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; a[i]--; } int k = 0; int count = 0; do{ k = a[k]; count++; }while(k != 0 && k != 1); if(k == 1) cout << count; else cout << -1; }
Main.java:1: error: illegal character: '#' #include <bits/stdc++.h> ^ Main.java:1: error: class, interface, enum, or record expected #include <bits/stdc++.h> ^ Main.java:5: error: not a statement cin >> n; ^ Main.java:6: error: not a statement vector<int> a(n); ^ Main.java:8: error: not a statement cin >> a[i]; ^ Main.java:17: error: not a statement if(k == 1) cout << count; ^ Main.java:18: error: not a statement else cout << -1; ^ Main.java:3: error: unnamed classes are a preview feature and are disabled by default. int main(){ ^ (use --enable-preview to enable unnamed classes) Main.java:6: error: ';' expected vector<int> a(n); ^ Main.java:6: error: ';' expected vector<int> a(n); ^ 10 errors
s824655961
p03680
C++
#include<stdio.h> #include<vector> #include<algorithm> using namespace std; int main ( ) { int n ; scanf ("%d" , &n ) ; vector<int>v ; for ( int i = 0 ; i < n ; i++) { int z ; scanf ("%d" , &z ) ; z−−; v.push back ( z ) ; } int now = 0 , c = 0 ; for ( ; ; ) { if ( now == 1 ) { printf ("%d\n" , c ) ; break ; } if ( c >= n ) { printf ("−1\n" ) ; break ; } c++; now = v [ now ] ; } }
a.cc:14:1: error: extended character − is not valid in an identifier 14 | z−−; | ^ a.cc:14:1: error: extended character − is not valid in an identifier a.cc: In function 'int main()': a.cc:14:1: error: 'z\U00002212\U00002212' was not declared in this scope 14 | z−−; | ^~~ a.cc:15:3: error: 'class std::vector<int>' has no member named 'push' 15 | v.push back ( z ) ; | ^~~~
s119093565
p03680
C++
#include<stdio.h> #include<vector> #include<algorithm> using namespace std; int main ( ) { int n ; scanf (”%d ” , &n ) ; vector<int>v ; for ( int i = 0 ; i < n ; i++) { int z ; scanf (”%d ” , &z ) ; z−−; v.push back ( z ) ; } int now = 0 , c = 0 ; for ( ; ; ) { if ( now == 1 ) { printf (”%d\n ” , c ) ; break ; } if ( c >= n ) { printf (”−1\n ” ) ; break ; } c++; now = v [ now ] ; } }
a.cc:8:8: error: extended character ” is not valid in an identifier 8 | scanf (”%d ” , &n ) ; | ^ a.cc:8:12: error: extended character ” is not valid in an identifier 8 | scanf (”%d ” , &n ) ; | ^ a.cc:13:8: error: extended character ” is not valid in an identifier 13 | scanf (”%d ” , &z ) ; | ^ a.cc:13:12: error: extended character ” is not valid in an identifier 13 | scanf (”%d ” , &z ) ; | ^ a.cc:14:1: error: extended character − is not valid in an identifier 14 | z−−; | ^ a.cc:14:1: error: extended character − is not valid in an identifier a.cc:22:9: error: extended character ” is not valid in an identifier 22 | printf (”%d\n ” , c ) ; | ^ a.cc:22:12: error: stray '\' in program 22 | printf (”%d\n ” , c ) ; | ^ a.cc:22:15: error: extended character ” is not valid in an identifier 22 | printf (”%d\n ” , c ) ; | ^ a.cc:27:9: error: extended character ” is not valid in an identifier 27 | printf (”−1\n ” ) ; | ^ a.cc:27:9: error: extended character − is not valid in an identifier a.cc:27:12: error: stray '\' in program 27 | printf (”−1\n ” ) ; | ^ a.cc:27:15: error: extended character ” is not valid in an identifier 27 | printf (”−1\n ” ) ; | ^ a.cc: In function 'int main()': a.cc:8:8: error: '\U0000201d' was not declared in this scope 8 | scanf (”%d ” , &n ) ; | ^ a.cc:8:10: error: 'd' was not declared in this scope 8 | scanf (”%d ” , &n ) ; | ^ a.cc:14:1: error: 'z\U00002212\U00002212' was not declared in this scope 14 | z−−; | ^~~ a.cc:15:3: error: 'class std::vector<int>' has no member named 'push' 15 | v.push back ( z ) ; | ^~~~ a.cc:27:9: error: '\U0000201d\U000022121' was not declared in this scope 27 | printf (”−1\n ” ) ; | ^~~
s391084244
p03680
C++
#i n cl u d e <s t d i o . h> #i n cl u d e <v e c t o r> #i n cl u d e <al g o ri thm> u si n g namespace s t d ; i n t main ( ) { i n t n ; s c a n f (”%d ” , &n ) ; v e c t o r<i n t>v ; f o r ( i n t i = 0 ; i < n ; i++) { i n t z ; s c a n f (”%d ” , &z ) ; z−−; v . push back ( z ) ; } i n t now = 0 , c = 0 ; f o r ( ; ; ) { i f ( now == 1 ) { p r i n t f (”%d\n ” , c ) ; break ; } i f ( c >= n ) { p r i n t f (”−1\n ” ) ; break ; } c++; now = v [ now ] ; } }
a.cc:1:2: error: invalid preprocessing directive #i; did you mean #if? 1 | #i n cl u d e <s t d i o . h> | ^ | if a.cc:2:2: error: invalid preprocessing directive #i; did you mean #if? 2 | #i n cl u d e <v e c t o r> | ^ | if a.cc:3:2: error: invalid preprocessing directive #i; did you mean #if? 3 | #i n cl u d e <al g o ri thm> | ^ | if a.cc:8:12: error: extended character ” is not valid in an identifier 8 | s c a n f (”%d ” , &n ) ; | ^ a.cc:8:16: error: extended character ” is not valid in an identifier 8 | s c a n f (”%d ” , &n ) ; | ^ a.cc:13:12: error: extended character ” is not valid in an identifier 13 | s c a n f (”%d ” , &z ) ; | ^ a.cc:13:16: error: extended character ” is not valid in an identifier 13 | s c a n f (”%d ” , &z ) ; | ^ a.cc:14:1: error: extended character − is not valid in an identifier 14 | z−−; | ^ a.cc:14:1: error: extended character − is not valid in an identifier a.cc:22:14: error: extended character ” is not valid in an identifier 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:22:17: error: stray '\' in program 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:22:20: error: extended character ” is not valid in an identifier 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:27:14: error: extended character ” is not valid in an identifier 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:27:14: error: extended character − is not valid in an identifier a.cc:27:17: error: stray '\' in program 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:27:20: error: extended character ” is not valid in an identifier 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:4:1: error: 'u' does not name a type 4 | u si n g namespace s t d ; | ^ a.cc:5:1: error: 'i' does not name a type 5 | i n t main ( ) | ^
s982452043
p03680
C++
#i n cl u d e <s t d i o . h> #i n cl u d e <v e c t o r> #i n cl u d e <al g o ri thm> u si n g namespace s t d ; i n t main ( ) { i n t n ; s c a n f (”%d ” , &n ) ; v e c t o r<i n t>v ; f o r ( i n t i = 0 ; i < n ; i++) { i n t z ; s c a n f (”%d ” , &z ) ; z−−; v . push back ( z ) ; } i n t now = 0 , c = 0 ; f o r ( ; ; ) { i f ( now == 1 ) { p r i n t f (”%d\n ” , c ) ; break ; } i f ( c >= n ) { p r i n t f (”−1\n ” ) ; break ; } c++; now = v [ now ] ; } }
a.cc:1:2: error: invalid preprocessing directive #i; did you mean #if? 1 | #i n cl u d e <s t d i o . h> | ^ | if a.cc:2:2: error: invalid preprocessing directive #i; did you mean #if? 2 | #i n cl u d e <v e c t o r> | ^ | if a.cc:3:2: error: invalid preprocessing directive #i; did you mean #if? 3 | #i n cl u d e <al g o ri thm> | ^ | if a.cc:8:12: error: extended character ” is not valid in an identifier 8 | s c a n f (”%d ” , &n ) ; | ^ a.cc:8:16: error: extended character ” is not valid in an identifier 8 | s c a n f (”%d ” , &n ) ; | ^ a.cc:13:12: error: extended character ” is not valid in an identifier 13 | s c a n f (”%d ” , &z ) ; | ^ a.cc:13:16: error: extended character ” is not valid in an identifier 13 | s c a n f (”%d ” , &z ) ; | ^ a.cc:14:1: error: extended character − is not valid in an identifier 14 | z−−; | ^ a.cc:14:1: error: extended character − is not valid in an identifier a.cc:22:14: error: extended character ” is not valid in an identifier 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:22:17: error: stray '\' in program 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:22:20: error: extended character ” is not valid in an identifier 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:27:14: error: extended character ” is not valid in an identifier 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:27:14: error: extended character − is not valid in an identifier a.cc:27:17: error: stray '\' in program 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:27:20: error: extended character ” is not valid in an identifier 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:4:1: error: 'u' does not name a type 4 | u si n g namespace s t d ; | ^ a.cc:5:1: error: 'i' does not name a type 5 | i n t main ( ) | ^
s040957603
p03680
C
#include<stdio.h> #include<string.h> int a[100001][2]; int main(void) { int n; int i; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i][0]); a[i][1] = 1; } //ループのiに数列の値を代入してみる// j = 0; for (i = 0; i < n; i = a[i][0] - 1) { if (a[i][0] == 1) { printf("-1\n"); return 0; } if (a[i][0] == 2) { printf("%d", j+1); return 0; } if (a[i][1] == 0) { printf("-1\n"); return 0; } j++; a[i][1] = 0; } printf("-1\n"); return 0; }
main.c: In function 'main': main.c:20:9: error: 'j' undeclared (first use in this function) 20 | j = 0; | ^ main.c:20:9: note: each undeclared identifier is reported only once for each function it appears in
s789911561
p03680
C++
#include <bits/stdc++.h> using namespace std; const int maxx = 1e5 + 7; int n; int a[maxx]; map <int, int> mp; bool flg; bool vis[maxx]; int main() { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) mp[a[i]] = i; int p = 1; while(p != 2) { if(flg) break; if(vis[p]) flg = 1; vis[p] = 1; p = mp[p]; cnt++; } if(flg) puts("-1"); else cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:20:17: error: 'cnt' was not declared in this scope; did you mean 'int'? 20 | cnt++; | ^~~ | int a.cc:23:22: error: 'cnt' was not declared in this scope; did you mean 'int'? 23 | else cout << cnt << endl; | ^~~ | int
s811040981
p03680
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n;cin >> n; vector<int> a(n+1); for(int i=1;i<=n;i++){ cin >> a.at(i); } vector<bool> b(n+1,false); int ans=0; int i=1 while(1){ ans++; b.at(i)=true; i = a.at(i); if(i==2){ cout << ans << endl; return 0; } if(b.at(i)) break; } cout << -1 << endl; }
a.cc: In function 'int main()': a.cc:13:5: error: expected ',' or ';' before 'while' 13 | while(1){ | ^~~~~
s388359486
p03680
C++
#include <bits/stdc++.h> #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define INF 1000000000 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; int dy[]={0, 0, 1, -1, 0}; int dx[]={1, -1, 0, 0, 0}; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> a(N),flag(N); REP(i,N) cin >> a[i]; int button=1,ans=0; while(1){ button = a[button-1]; ans++; flag[button-1]++; if(button==c) break; if(flag[button-1]>1){ ans=-1; break; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:32:16: error: 'c' was not declared in this scope 32 | if(button==c) break; | ^
s122465255
p03680
C++
#include <iostream> #include <vector> int main() { std::cin >> N; std::vector<int> a(N); for (int i = 0; i < N; ++i) { std::cin >> a[i]; } int now = a[0]; int cnt = 0; while(cnt < N) { int tmp = a[now]; now = a[tmp]; ++cnt; if ( now == 2 ) break; } if ( cnt < N ) std::cout << cnt << std::endl; else std::cout << -1 << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:5:15: error: 'N' was not declared in this scope 5 | std::cin >> N; | ^
s380709310
p03680
C++
#include <string> #include <algorithm> #include <utility> #define INF 1000000000 #define MOD 1000000007 using namespace std; int main() { int n; int ans = 0; int a[100005]; int v[100005] = {}; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } int now = 1; while (now != 2 && v[now] == 0) { v[now] = 1; now = a[now]; ans++; } if (now != 2) { cout << -1 << endl; } else { cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:16:5: error: 'cin' was not declared in this scope 16 | cin >> n; | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include <utility> +++ |+#include <iostream> 4 | #define INF 1000000000 a.cc:30:9: error: 'cout' was not declared in this scope 30 | cout << -1 << endl; | ^~~~ a.cc:30:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:30:23: error: 'endl' was not declared in this scope 30 | cout << -1 << endl; | ^~~~ a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 3 | #include <utility> +++ |+#include <ostream> 4 | #define INF 1000000000 a.cc:32:9: error: 'cout' was not declared in this scope 32 | cout << ans << endl; | ^~~~ a.cc:32:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:32:24: error: 'endl' was not declared in this scope 32 | cout << ans << endl; | ^~~~ a.cc:32:24: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s270777404
p03680
C++
#include<iostream> #include<algorithm> #include<string> #include<functional> #include<utility> #include<stack> #include<queue> #include<cmath> #include<list> #include<cstdint> #include<vector> #include<map> #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define rep(i,rept) for(ll i = 0; i<rept;i++) typedef long long ll; using namespace std; ll nCr(ll n, ll r) { if (r > n) { return 0; } if (r * 2 > n) r = n - r; ll dividend = 1; ll divisor = 1; for (ll i = 1; i <= r; ++i) { dividend *= (n - i + 1); divisor *= i; } return dividend / divisor; } ll sumdigit(ll n) { ll dig = 0, sum = 0; while (n) { dig = n % 10; sum = sum + dig; n = n / 10; } return sum; } int main() { int n; cin >> n; for (int i = 0; i <= n; i++) { cin >> a[i]; a[i]--; } int x = 0; for (int i = 0; i<100010; i++) { if (x == 1) { cout << i << endl; return 0; } x = a[x]; } cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:47:24: error: 'a' was not declared in this scope 47 | cin >> a[i]; | ^ a.cc:56:21: error: 'a' was not declared in this scope 56 | x = a[x]; | ^
s542780839
p03680
C++
#include<bits/stdc++.h> using namespace std; int a[100010]; bool f[100010]; int ans; void dfs(int i,int c){ if(i==2)ans=c; if(f[a[i]]){ return; }else{ dfs(a[i]); } } int main(){ int n;cin>>n; ans=1000000; for(int i=1;i<=n;i++)cin>>a[i]; dfs(1); if(ans<1000000){ cout<<ans<<endl; }else{ cout<<-1<<endl; } }
a.cc: In function 'void dfs(int, int)': a.cc:11:8: error: too few arguments to function 'void dfs(int, int)' 11 | dfs(a[i]); | ~~~^~~~~~ a.cc:6:6: note: declared here 6 | void dfs(int i,int c){ | ^~~ a.cc: In function 'int main()': a.cc:18:8: error: too few arguments to function 'void dfs(int, int)' 18 | dfs(1); | ~~~^~~ a.cc:6:6: note: declared here 6 | void dfs(int i,int c){ | ^~~
s273461601
p03680
C++
#include<stdio.h> #include<vector> #include<algorithm> using namespace std ; int main (){ int n ; scanf ("%d" , &n ) ; vector<int>v ; for(int i=0;i<n;i++){ intz; scanf("%d",&z); z--; v.push_back(z); } int now=0,c=0; for(;;){ if(now==1){ printf("%d\n",c); break; }if(c>=n){ printf("-1\n"); break; } c++; now=v[now]; }}
a.cc: In function 'int main()': a.cc:10:5: error: 'intz' was not declared in this scope; did you mean 'int'? 10 | intz; | ^~~~ | int a.cc:11:17: error: 'z' was not declared in this scope 11 | scanf("%d",&z); | ^
s678293401
p03680
C++
#include<stdio . h> #include<vector> #include<algorithm> using namespace std ; int main (){ int n ; scanf ("%d" , &n ) ; vector<int>v ; for(int i=0;i<n;i++){ intz; scanf("%d",&z); z--; v.push_back(z); } int now=0,c=0; for(;;){ if(now==1){ printf("%d\n",c); break; }if(c>=n){ printf("-1\n"); break; } c++; now=v[now]; }}
a.cc:1:9: fatal error: stdio . h: No such file or directory 1 | #include<stdio . h> | ^~~~~~~~~~~ compilation terminated.
s521820833
p03680
C++
n = gets.chomp.to_i a = readlines.map{|a| a.to_i} if a.index(2).nil? puts "-1" exit end a.unshift(0) count = Array.new(n+1){0} idx = a[1] count[1] += 1 while idx != 2 && count.inject(&:+) != n prv_idx = idx idx = a[idx] if prv_idx == a[idx] puts "-1" exit end count[prv_idx] += 1 end if count.inject(&:+) == n puts "-1" exit end puts count.inject(&:+)
a.cc:1:1: error: 'n' does not name a type 1 | n = gets.chomp.to_i | ^ a.cc:4:1: error: expected unqualified-id before 'if' 4 | if a.index(2).nil? | ^~ a.cc:12:1: error: 'idx' does not name a type 12 | idx = a[1] | ^~~
s340005618
p03680
C++
n = gets(chomp:true).to_i a = readlines.map{|a| a.to_i} if a.index(2).nil? puts "-1" exit end a.unshift(0) count = Array.new(n+1){0} idx = a[1] count[1] += 1 while idx != 2 && count.inject(&:+) != n prv_idx = idx idx = a[idx] if prv_idx == a[idx] puts "-1" exit end count[prv_idx] += 1 end if count.inject(&:+) == n puts "-1" exit end puts count.inject(&:+)
a.cc:1:1: error: 'n' does not name a type 1 | n = gets(chomp:true).to_i | ^ a.cc:4:1: error: expected unqualified-id before 'if' 4 | if a.index(2).nil? | ^~ a.cc:12:1: error: 'idx' does not name a type 12 | idx = a[1] | ^~~
s845936988
p03680
C++
#include <algorithm> #include <cassert> // #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <memory> #include <queue> // #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> /* unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count(); mt19937 g1.seed(seed1); */ using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<pii, pii> ppiipii; typedef pair<int, ppiipii> pippiipii; typedef pair<int, pii> pipii; typedef pair<pii, int> ppiii; typedef pair<int, ppiii> pippiii; typedef pair<int, ll> pill; typedef pair<int, double> pid; typedef pair<string, string> pss; // note to self, the below two triggers someone typedef pair<ll, ll> pll; typedef pair<ll, int> plli; typedef long double ld; int to[100005]; int main() { int n; scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%d", &l[i]); } int curr = 1; int ret = 0; while(curr != 2 && ret < 1000000) { curr = to[curr]; ret++; } if(curr != 2) ret = -1; printf("%d\n", ret); }
a.cc: In function 'int main()': a.cc:49:18: error: 'l' was not declared in this scope 49 | scanf("%d", &l[i]); | ^
s111688096
p03680
C++
#include <bits/stdc++.h> using namespace std; int main(){ int i,array[100001],n[100001]={},c=0,a cin>>a; for(i=0;i<a;i++){ cin>>array[i]; } for(i=0;;){ if(i==2){ cout<<c<<endl; return 0; } if(n[i]==-1){ cout<<n[i]<<endl; return 0; } i=array[i]; n[i]--; c++; } }
a.cc: In function 'int main()': a.cc:6:3: error: expected initializer before 'cin' 6 | cin>>a; | ^~~ a.cc:7:13: error: 'a' was not declared in this scope 7 | for(i=0;i<a;i++){ | ^
s122550926
p03680
C++
#include <iostream> #include <vector> using namespace std; int main(){ int N; cin >> N; vector<int> a(200000); for(int i=1;i<=N;i++){ cin >> a.at(i); } for(
a.cc: In function 'int main()': a.cc:12:7: error: expected primary-expression at end of input 12 | for( | ^ a.cc:12:7: error: expected primary-expression at end of input a.cc:12:7: error: expected ';' at end of input 12 | for( | ^ | ; a.cc:12:7: error: expected primary-expression at end of input a.cc:12:7: error: expected ')' at end of input 12 | for( | ~^ | ) a.cc:12:7: error: expected statement at end of input a.cc:12:7: error: expected '}' at end of input a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s033055787
p03680
C++
#include "bits/stdc++.h" using namespace std; #define MOD 1000000007 #define FOR(i,a,b) for(long long i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; typedef long long ll; typedef pair<ll,ll> P; typedef vector<vector<P>> Graph; int main(){ int n; cin >> n; int lamp[n]; REP(i,n){ cin >> lamp[i]; } int ans = 0,l = 0; while(ans <= n){ l = lamp[i] -1; ans++; if(l == 1) { cout << ans << endl; return 0; } } cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:26:14: error: 'i' was not declared in this scope 26 | l = lamp[i] -1; | ^
s379241933
p03680
C++
#include <iostream> using namespace std; int main() { int n,a=1,b=vec.at(1),x=0; cin>>n; vector<int>vec(n); for(int i=0;i<n;i++){ cin>>vec.at(i); } for(int i=0;i<n;i++){ if(b==2){ break; } a=b; b=vec.at(a); x++ } if(x==n){ cout<<-1<<endl; } else{ cout<<x+1<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:5:21: error: 'vec' was not declared in this scope 5 | int n,a=1,b=vec.at(1),x=0; | ^~~ a.cc:7:9: error: 'vector' was not declared in this scope 7 | vector<int>vec(n); | ^~~~~~ a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 1 | #include <iostream> +++ |+#include <vector> 2 | using namespace std; a.cc:7:16: error: expected primary-expression before 'int' 7 | vector<int>vec(n); | ^~~ a.cc:19:13: error: 'x' was not declared in this scope 19 | x++ | ^ a.cc:22:12: error: 'x' was not declared in this scope 22 | if(x==n){ | ^
s066261905
p03680
C++
#include <iostream> //#include <vector> using namespace std; int search(int* arr, int len){ int flag = 0; if(len > 0){ for(int i = 0; i < len; i++){ if(arr[len] == arr[i]){ flag = 1; break; } } } return flag; } int main(){ int N; int a[110000]; cin >> N; for(int i = 0; i < N; i++) cin >> a[i]; //for(int i = 0; i < N; i++) cout << a[i]; //cout << endl; int passed[110000] = {}; int now = 1; int cnt = 0; passed[0] = now; while(num != 2){ //if(cnt > 10) break; if(num == 2) break; cnt ++; now = a[now-1]; passed[cnt] = now; //cout << "cnt: " << cnt << " now: " << now << endl; if(search(passed, cnt)){ cnt = -1; break; } } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:9: error: 'num' was not declared in this scope; did you mean 'enum'? 36 | while(num != 2){ | ^~~ | enum
s819020839
p03680
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1e9+7 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long using namespace std; int main(){ int n;cin>>n; bool used[n+10]={}; vector<int>bo(n+10) for(int i=1;i<=n;i++){ cin>>bo[i]; } int cnt=0; int now=1; bool flag=true; while(1){ if(used[now]){flag=false;break;} used[now]=true; now=bo[now]; cnt++; if(now==2)break; } if(flag)cout<<cnt<<endl; else cout<<-1<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:3: error: expected ',' or ';' before 'for' 16 | for(int i=1;i<=n;i++){ | ^~~ a.cc:16:15: error: 'i' was not declared in this scope 16 | for(int i=1;i<=n;i++){ | ^
s010283741
p03680
C++
#include<cstdio> int a[100001],ans,n; int dispo=1; bool c[100001]; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<=n;i++){ if(dispo==2){ printf("%d",ans); return 0; }else if(c[dispo]&1){ printf("-1"); return 0; } ++c[dispo]; dispo=a[dispo]; ++ans; } }
a.cc: In function 'int main()': a.cc:8:5: error: 'cin' was not declared in this scope 8 | cin>>n; | ^~~ a.cc:20:18: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17 20 | ++c[dispo]; | ~~~~~~~^
s254919909
p03680
C++
#include <algorithm> #include <cmath> #include <iostream> #include <string> using namespace std; int main(void) { int pus, n, count = 0, times = 0; cin >> n; int buton[n]; for (int i = 0; i < n; i++) { cin >> buton[i]; } pus = buton[0]; count = times = 1; if (pus == 2) { cout << count << endl; return; } while (true) { if (buton[pus - 1] == 2) { cout << count + 1 << endl; return 0; } pus = buton[pus - 1]; count++; times++; if (times > n * 2) { cout << -1 << endl; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:18:5: error: return-statement with no value, in function returning 'int' [-fpermissive] 18 | return; | ^~~~~~
s022112828
p03680
C++
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >>n; int a[1000001]; for(int i=1;i<=n;i++) { cin >> a[i]; } int now=1; int sum=0; while(ans==0) { sum +=1; if(a[now]==2) { cout << sum <<endl;break; } else if(sum > n) { cout << -1 <<endl; break; } else if(a[now]==now) { ans=-1;break; } else { now=a[now]; continue; } } }
a.cc: In function 'int main()': a.cc:13:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 13 | while(ans==0) { | ^~~ | abs
s319305561
p03680
C++
#include <iostream> #include <vector> using namespace std; int main() { int n, c = 0; vector <int> v[n]; cin >> n; for (int i = 0; i < n; i++) { cin >> v[i]; } int a = v[0]; for (int j = 0; j < n; j++) { if (v[a] == 2) { cout << c << endl; break; } else { a = v[a]; c++; } } cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:21: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<int>') 10 | cin >> v[i]; | ~~~ ^~ ~~~~ | | | | | std::vector<int> | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool&' 170 | operator>>(bool& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'short int&' 174 | operator>>(short& __n); | ~~~~~~~^~~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'short unsigned int&' 177 | operator>>(unsigned short& __n) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'int&' 181 | operator>>(int& __n); | ~~~~~^~~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'unsigned int&' 184 | operator>>(unsigned int& __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'long int&' 188 | operator>>(long& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from 'std::vector<int>' to 'long unsigned int&' 192 | operator>>(unsigned long& __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long int&' 199 | operator>>(long long& __n) | ~~~~~~~~~~~^~~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long unsigned int&' 203 | operator>>(unsigned long long& __n) | ~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'float&' 219 | operator>>(float& __f) | ~~~~~~~^~~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'double&' 223 | operator>>(double& __f) | ~~~~~~~~^~~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'std::vector<int>' to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::ios_base& (*)(std::ios_base&)' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]' 352 | operator>>(__streambuf_type* __sb); | ^~~~~~~~ /usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'} 352 | operator>>(__streambuf_type* __sb); | ~~~~~~~~~~~~~~~~~~^~~~ In file included from /usr/include/c++/14/string:55, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/in
s803147342
p03680
C++
#include <iostream> #include <vector> using namespace std; int main() { int n, c = 0; vector <int> v[n]; cin >> n; for (int i = 0; i < n; i++) { cin >> v[i]; } int a = v[0]; for (int j = 0; j < n; j++) { if (v[a] == 2) { cout << 0 << endl; break; } else { a = v[a]; c++; } } cout << "-1" << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:21: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<int>') 10 | cin >> v[i]; | ~~~ ^~ ~~~~ | | | | | std::vector<int> | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool&' 170 | operator>>(bool& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'short int&' 174 | operator>>(short& __n); | ~~~~~~~^~~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'short unsigned int&' 177 | operator>>(unsigned short& __n) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'int&' 181 | operator>>(int& __n); | ~~~~~^~~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'unsigned int&' 184 | operator>>(unsigned int& __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'long int&' 188 | operator>>(long& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from 'std::vector<int>' to 'long unsigned int&' 192 | operator>>(unsigned long& __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long int&' 199 | operator>>(long long& __n) | ~~~~~~~~~~~^~~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long unsigned int&' 203 | operator>>(unsigned long long& __n) | ~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'float&' 219 | operator>>(float& __f) | ~~~~~~~^~~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'double&' 223 | operator>>(double& __f) | ~~~~~~~~^~~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'std::vector<int>' to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::ios_base& (*)(std::ios_base&)' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]' 352 | operator>>(__streambuf_type* __sb); | ^~~~~~~~ /usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'} 352 | operator>>(__streambuf_type* __sb); | ~~~~~~~~~~~~~~~~~~^~~~ In file included from /usr/include/c++/14/string:55, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/in
s840225806
p03680
C++
#include <iostream> using namespace std; int main() { int N; cin >> N; int a[110000]; for(int i = 0; i < N; i++) cin >> a[i]; int cur_pos = 0; int count = 0; bool reachable = true; int prev_pos1 = 0; int prev_pos2 = 0; bool reachable2 = false: for(int i= 0; i < N; i++) { if(a[i] == 2) { reachable2 = true; } } if(!reachable2) { cout << "-1" << endl; return 0; } while(1){ if(a[cur_pos] == 2) { //到達できた場合 break; } if(count > 2) { if(prev_pos2 == cur_pos || prev_pos1 == cur_pos) { //ループしてる場合 reachable = false; break; } } prev_pos2 = prev_pos1; prev_pos1 = cur_pos; cur_pos = a[cur_pos]; count++; } if(!reachable) { cout << "-1" << endl; } else { cout << count << endl; } return 0; }
a.cc: In function 'int main()': a.cc:18:28: error: expected ',' or ';' before ':' token 18 | bool reachable2 = false: | ^ a.cc:19:19: error: 'i' was not declared in this scope 19 | for(int i= 0; i < N; i++) { | ^
s865393337
p03680
C++
#include <algorithm> #include <cmath> using namespace std; int main(){ int N; int a[200000]; bool b[200000]; bool clear = false; int pos = 0; int count = 1; cin >> N; for(int i=0;i<N;++i){ cin >> a[i]; b[i] = true; } for(int i=0;i<N;++i){ if(a[pos]-1 == 1){ clear = true; break; }else if(b[pos]){ b[pos] = false; pos = a[pos]-1; count++; }else{ break; } } if(clear){ cout << count << endl; }else{ cout << -1 << endl; } }
a.cc: In function 'int main()': a.cc:13:3: error: 'cin' was not declared in this scope 13 | cin >> N; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include <cmath> +++ |+#include <iostream> 3 | using namespace std; a.cc:33:5: error: 'cout' was not declared in this scope 33 | cout << count << endl; | ^~~~ a.cc:33:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:33:22: error: 'endl' was not declared in this scope 33 | cout << count << endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include <cmath> +++ |+#include <ostream> 3 | using namespace std; a.cc:35:5: error: 'cout' was not declared in this scope 35 | cout << -1 << endl; | ^~~~ a.cc:35:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:35:19: error: 'endl' was not declared in this scope 35 | cout << -1 << endl; | ^~~~ a.cc:35:19: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s748182475
p03680
C++
#include <bits/stdc++.h> using namespace std; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) //repetition //------------------------------------------ #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) //conversion //------------------------------------------ inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; //math //------------------------------------------- template<class T> inline T sqr(T x) {return x*x;} typedef long long LL; const LL mod=1000000007; #define MAX 10000 #define NIL -1 const double PI = acos(-1.0); const int INF = 1e9 + 7; //------------------------------------------- int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, a[MAX], cnt = 0; cin >> N; bool flag = false; for (int i = 1; i <= N; i++){ cin >> a[i]; } for( int i = 1; ; ){ cnt++; if( a[i] == 2){ flag = true; break; } i = a[i]; if (cnt > N){ break; } if (flag){ cout << cnt << endl;} else{ cout << -1 << endl;} return 0; }
a.cc: In function 'int main()': a.cc:67:2: error: expected '}' at end of input 67 | } | ^ a.cc:38:11: note: to match this '{' 38 | int main(){ | ^
s883987994
p03680
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] a = new int[N]; for(int i = 0;i < N;i++)a[i] = sc.nextInt(); int b = 0; int c = 0; for(int i = 0;;i++){ if(a[b] == 2){ System.out.println(i+1); break; } else if(a[b] == 1){ System.out.println("-1"); break; } c = a[b]; else b = c-1; } }}
Main.java:20: error: 'else' without 'if' else b = c-1; ^ 1 error
s363777330
p03680
C++
#include <iostream> using namespace std; int main(){ int N; cin >> N; int a[N]; for(int i=0; i<N; i++) cin >> a[i]; Light=a[0]; while(Light!=1){ Light=a[Light-1]; if(Light==2){ break; } } if(Light==1) cout << "No" << endl; if(Light==2) cout << "Yes" << endl; }
a.cc: In function 'int main()': a.cc:10:9: error: 'Light' was not declared in this scope 10 | Light=a[0]; | ^~~~~
s001879036
p03680
C++
#include<iostream> #include<math.h> #include<string> #include<algorithm> using namespace std; #define rep0(n) for(int i=0;i<n;i++) #define rep(n) for(int i=1;i<=n;i++) double const pi=3.1415926535; int printint(int n){ cout<<n<<endl; return 0; } int prints(string s){ cout<<s<<endl; return 0; } int main(){ int n; cin>>n; int a[114514]; rep(n)cin>>a[i]; bool a[114514]; rep(n)a[i]=false; int index=1; int ans=0; while(true){ if(a[index]==true){ cout<<-1<<endl; return 0; } ans++; a[index]=true; index=a[index]; if(index==2){ cout<<ans<<endl; return 0; } } }
a.cc: In function 'int main()': a.cc:27:14: error: conflicting declaration 'bool a [114514]' 27 | bool a[114514]; | ^ a.cc:25:13: note: previous declaration as 'int a [114514]' 25 | int a[114514]; | ^
s582089016
p03680
C++
#include<iostream> using namespace std; const int max = 100010; int main() { int N; int an[max]; int count = 1; int index = 0; bool check = false; cin >> N; for (int i = 0; i < N; i++) { cin >> an[i]; } for (int i = 0; i < N; i++) { if (an[index] == 2) { check = true; break; } count++; index = an[index] - 1; } if (check) cout << count << endl; else cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:7:16: error: reference to 'max' is ambiguous 7 | int an[max]; | ^~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:3:11: note: 'const int max' 3 | const int max = 100010; | ^~~ a.cc:15:24: error: 'an' was not declared in this scope 15 | cin >> an[i]; | ^~ a.cc:19:21: error: 'an' was not declared in this scope 19 | if (an[index] == 2) { | ^~ a.cc:24:25: error: 'an' was not declared in this scope 24 | index = an[index] - 1; | ^~
s280529004
p03680
C++
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <sstream> #include <functional> #include <map> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <deque> #include <set> #include <list> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> P; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const ll INF = 1LL<<29; const ll mod = 1e9+7; #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i)) #define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d)) #define all(v) (v).begin(), (v).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset((m),(v),sizeof(m)) #define chmin(x,y) (x=min(x,y)) #define chmax(x,y) (x=max(x,y)) #define fst first #define snd second #define UNIQUE(x) (x).erase(unique(all(x)),(x).end()) template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;} int main(){ cin>>n; vector<int> a(n); rep(i, n) cin>>a[i], a[i]--; for(int i = 0, j = 0; i < 2*n; i++){ if(j==1){ cout<<i<<endl; return 0; } j = a[i]; } cout<<-1<<endl; return 0; }
a.cc: In function 'int main()': a.cc:42:14: error: 'n' was not declared in this scope; did you mean 'yn'? 42 | cin>>n; | ^ | yn
s269690664
p03680
C++
if __name__ == "__main__": N = int(input()) A = [] for x in range(N): y = int(input()) y -= 1 A.append(y) pos = 0 cnt = 0 visited = set() while (cnt <= N + 1): visited.add(pos) if (pos == 1): print (cnt) exit() pos = A[pos] cnt += 1 if pos in visited: break print (-1)
a.cc:1:1: error: expected unqualified-id before 'if' 1 | if __name__ == "__main__": | ^~
s097705694
p03680
C++
//abc065_b Trained? #include <bits/stdc++.h> using namespace std; namespace { bool bFlag[ 100010 ]; int a[ 100010 ]; } int main() { int i; int N; int iCnt; cin >> N; for( i = 1; i <= N; i++ ) { cin >> a[ i ]; } iCnt = 1; i = 1; while( ! bFlag[ i ] ) { bFlag[ i ] = true; if( i == 2 ) { cout << iCnt << endl; return 0; } iCnt++; i = a[ i ] } cout << - 1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:38:27: error: expected ';' before '}' token 38 | i = a[ i ] | ^ | ; 39 | } | ~
s493749225
p03680
C++
button = $stdin.read.split("\n") button.map! do |element| element.to_i end button.shift() current = 0 cnt = 0 while true if current == 1 print("#{cnt}\n") break elsif cnt >= button.size print("-1\n") break end cnt += 1 current = button[current-1] end
a.cc:1:1: error: 'button' does not name a type 1 | button = $stdin.read.split("\n") | ^~~~~~
s249300559
p03680
C
#include <stdio.h> #define MAX 10000 int main(void){ int N, c, now, a[MAX]; scanf("%d", &N); for(i=0;i<N;i++){ scanf("%d", &(a[i])); a[i]--; } c = 0; now = 0; while(1){ if(now == 1){ printf("%d\n", c); break; } if(c >= N){ printf("-1\n"); break; } c++; now = a[now]; } return 0; }
main.c: In function 'main': main.c:7:7: error: 'i' undeclared (first use in this function) 7 | for(i=0;i<N;i++){ | ^ main.c:7:7: note: each undeclared identifier is reported only once for each function it appears in
s631676875
p03680
C++
#include <stdio.h> #include <vector> #include <algorithm> using namespace std; int main(){ int n; cin>>n; vector<int> a(n); for(int i=0; i<n; i++){ cin>>a[i]; } int index=0; int i=0; while(i<=n){ if(a[index]==2){ cout<<index+1<<endl; break; } index=a[index]-1; i++; } }
a.cc: In function 'int main()': a.cc:9:5: error: 'cin' was not declared in this scope 9 | cin>>n; | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include <algorithm> +++ |+#include <iostream> 4 | a.cc:19:13: error: 'cout' was not declared in this scope 19 | cout<<index+1<<endl; | ^~~~ a.cc:19:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:19:28: error: 'endl' was not declared in this scope 19 | cout<<index+1<<endl; | ^~~~ a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 3 | #include <algorithm> +++ |+#include <ostream> 4 |
s451752422
p03680
C++
int main(void) { int a; scanf("%d", &a); int A[a]; for (int i = 0; i < a; i++ ) { scanf("%d", &A[i]); } int light; int count = 1; for (light = A[0]; light != 2; count++) { if (count >= a ) { printf("-1"); break; } light = A[light-1]; } if (light == 2 ) { printf("%d\n", count); } return 0; }
a.cc: In function 'int main()': a.cc:3:4: error: 'scanf' was not declared in this scope 3 | scanf("%d", &a); | ^~~~~ a.cc:12:10: error: 'printf' was not declared in this scope 12 | printf("-1"); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main(void) { a.cc:18:7: error: 'printf' was not declared in this scope 18 | printf("%d\n", count); | ^~~~~~ a.cc:18:7: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s099293361
p03680
C++
#include <iostream> using namespace std; #define Nmax 100000 int main() { int N; int a; int start; int Nnum[Nmax]; scanf("%d", &N); for (int i = 1; i < N + 1; i++) { scanf("%d", &a); Nnum[i] = a; } int next = 1; int count = 0; while (count<N) { next = Nnum[next]; count++; if (next == 2) break; } if (next == 2) printf("%d\n", count); else printf("%d\n", -1);
a.cc: In function 'int main()': a.cc:26:36: error: expected '}' at end of input 26 | printf("%d\n", -1); | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s610691508
p03680
C++
#i n cl u d e <s t d i o . h> #i n cl u d e <v e c t o r> #i n cl u d e <al g o ri thm> u si n g namespace s t d ; i n t main ( ) { i n t n ; s c a n f (”%d ” , &n ) ; v e c t o r<i n t>v ; f o r ( i n t i = 0 ; i < n ; i++) { i n t z ; s c a n f (”%d ” , &z ) ; z−−; v . push back ( z ) ; } i n t now = 0 , c = 0 ; f o r ( ; ; ) { i f ( now == 1 ) { p r i n t f (”%d\n ” , c ) ; break ; } i f ( c >= n ) { p r i n t f (”−1\n ” ) ; break ; } c++; now = v [ now ] ; } }
a.cc:1:2: error: invalid preprocessing directive #i; did you mean #if? 1 | #i n cl u d e <s t d i o . h> | ^ | if a.cc:2:2: error: invalid preprocessing directive #i; did you mean #if? 2 | #i n cl u d e <v e c t o r> | ^ | if a.cc:3:2: error: invalid preprocessing directive #i; did you mean #if? 3 | #i n cl u d e <al g o ri thm> | ^ | if a.cc:8:12: error: extended character ” is not valid in an identifier 8 | s c a n f (”%d ” , &n ) ; | ^ a.cc:8:16: error: extended character ” is not valid in an identifier 8 | s c a n f (”%d ” , &n ) ; | ^ a.cc:13:12: error: extended character ” is not valid in an identifier 13 | s c a n f (”%d ” , &z ) ; | ^ a.cc:13:16: error: extended character ” is not valid in an identifier 13 | s c a n f (”%d ” , &z ) ; | ^ a.cc:14:1: error: extended character − is not valid in an identifier 14 | z−−; | ^ a.cc:14:1: error: extended character − is not valid in an identifier a.cc:22:14: error: extended character ” is not valid in an identifier 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:22:17: error: stray '\' in program 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:22:20: error: extended character ” is not valid in an identifier 22 | p r i n t f (”%d\n ” , c ) ; | ^ a.cc:27:14: error: extended character ” is not valid in an identifier 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:27:14: error: extended character − is not valid in an identifier a.cc:27:17: error: stray '\' in program 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:27:20: error: extended character ” is not valid in an identifier 27 | p r i n t f (”−1\n ” ) ; | ^ a.cc:4:1: error: 'u' does not name a type 4 | u si n g namespace s t d ; | ^ a.cc:5:1: error: 'i' does not name a type 5 | i n t main ( ) | ^
s861083524
p03680
C++
#include <iostream> using namespace std; int main() { int n, i, j, k, x, y, z, c=0; cin. tie(0); for (i = 1; i <= n; i++) cin>> A[i]; x = 1; c = 0; mark[1] = 1; while (x != 2) { c++; x=A[x]; if (mark[x]) break; mark[x] = 1; } if(x == 2) cout << c << endl; else cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:7:32: error: 'A' was not declared in this scope 7 | for (i = 1; i <= n; i++) cin>> A[i]; | ^ a.cc:10:1: error: 'mark' was not declared in this scope 10 | mark[1] = 1; | ^~~~ a.cc:13:13: error: 'A' was not declared in this scope 13 | x=A[x]; | ^
s778736217
p03680
C++
#include <iostream> using namespace std; int main() { int n,i,j,k,x,y,z,c=0; cin>>n; for(i=1;i<=n;++i)cin>>A[i]; x=1; c=0; mark[1]=1; while(x!=2) { c++; x=A[x];if(mark[x])break; mark[x]=1; } if(x==2)cout<<e<<endl; else cout<<-1<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:31: error: 'A' was not declared in this scope 7 | for(i=1;i<=n;++i)cin>>A[i]; | ^ a.cc:10:9: error: 'mark' was not declared in this scope 10 | mark[1]=1; | ^~~~ a.cc:14:11: error: 'A' was not declared in this scope 14 | x=A[x];if(mark[x])break; | ^ a.cc:17:19: error: 'e' was not declared in this scope 17 | if(x==2)cout<<e<<endl; | ^
s385541285
p03680
C++
#include<iostream> using namespace std; int mark[100001],A[100001] int main() { ios_base::sync_with_stdio(false) cin.tie(0); int n,i,j,k,x,y,z,c=0; cin>>n; for(i=1;i<=n;++1)cin>>A[i] x=1; c=0; mark[1]=1; while(x!=2){ c++; x=A[x]; if(mark[x])break; mark[x]=1; } if(x==2)cout<<c<<end; else cout<<-1<<endl; return 0; }
a.cc:4:1: error: expected initializer before 'int' 4 | int main() | ^~~
s808514937
p03680
C++
#include <iostream> #include <utility> #include <cstdlib> #include <cstdio> #include <vector> #include <queue> #include <cmath> #include <map> #include <set> #include <stdio.h> #include <algorithm> #include <iomanip> #include <string> #include <cctype> #include <string.h> #include <ctime> #include <windows.h> using namespace std; int mark[100001],a[100001]; int main() { int x,c,n,i,j,k,y,z; cin>>n; for (i=1;i<=n;i++) cin>>a[i]; x=1; c=0; while (x!=2) { c++; x=a[x]; if (mark[x]) break; mark[x]=1; } if (x==2) cout<<c<<endl; else cout<<"-1"<<endl; return 0; }
a.cc:17:10: fatal error: windows.h: No such file or directory 17 | #include <windows.h> | ^~~~~~~~~~~ compilation terminated.
s060374397
p03680
C++
#include <iostream> #include <utility> #include <cstdlib> #include <cstdio> #include <vector> #include <queue> #include <cmath> #include <map> #include <set> #include <stdio.h> #include <algorithm> #include <iomanip> #include <string> #include <cctype> #include <string.h> #include <ctime> #include <conio.h> #include <windows.h> using namespace std; int mark[100001],a[100001]; int main() { int x,c,n,i,j,k,y,z; cin>>n; for (i=1;i<=n;i++) cin>>a[i]; x=1; c=0; while (x!=2) { c++; x=a[x]; if (mark[x]) break; mark[x]=1; } if (x==2) cout<<c<<endl; else cout<<"-1"<<endl; return 0; }
a.cc:17:10: fatal error: conio.h: No such file or directory 17 | #include <conio.h> | ^~~~~~~~~ compilation terminated.
s893704843
p03680
C++
#include <iostream> #include <utility> #include <cstdlib> #include <cstdio> #include <vector> #include <queue> #include <cmath> #include <map> #include <set> #include <stdio.h> #include <algorithm> #include <iomanip> #include <string> #include <cctype> #include <string.h> #include <ctime> #include <conio.h> #include <windows.h> using namespace std; int a[100005],b[100005]; int main() { int n,s=0; cin>>n; for (int i=1;i<=n;i++){ cin>>a[i]; } for (int i=1;i<=100005;) { b[i]=1; i=a[i]; s++; if (i==2) { cout<<s<<endl; return 0; } else if (b[i]==1) { cout<<"-1"<<endl; return 0; } } return 0; }
a.cc:17:10: fatal error: conio.h: No such file or directory 17 | #include <conio.h> | ^~~~~~~~~ compilation terminated.
s054700205
p03680
C++
#include<iostream> #include<Cstring> using namespace std; int main(){ int N; int j=0; int b=1; int c[100000]; int d=0; int a[100000]; cin>>N; for(int i=1;i<=N;i++){ cin>>a[i]; } while(b!=2){ c[j]=b; for(int k=0;k<=j;k++){ if(c[k]==b) d=1; } if(d==1) break; else { j++; b=a[b]; } } if(d==0) cout<<j<<endl; else cout<<"-1"<<endl; }
a.cc:2:9: fatal error: Cstring: No such file or directory 2 | #include<Cstring> | ^~~~~~~~~ compilation terminated.
s978855219
p03680
C++
// 170613_test.cpp : メイン プロジェクト ファイルです。 #include "stdio.h" #include "stdafx.h" using namespace System; int main() { int n; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } int f = 0; int tmp = 1; for (int j = 0; j < n; j++) { tmp = a[tmp - 1]; if (tmp = 2) { printf(j); break; f = 1; } } if (f == 0) { printf("-1"); } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s602400947
p03680
Java
package atcoder; import java.util.Scanner; import java.io.PrintWriter; public class TaskB { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); int[]arr = new int[n+1]; for(int i = 1; i <= n; ++i) { arr[i] = in.nextInt(); } boolean[] vis = new boolean[n+1]; int cur = 1; int ans = 0; while(cur != 2 && !vis[cur]) { vis[cur] = true; cur = arr[cur]; ++ans; } out.println(cur != 2 ? -1 : ans); } }
Main.java:6: error: class TaskB is public, should be declared in a file named TaskB.java public class TaskB { ^ 1 error
s911419249
p03680
C++
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> using namespace std; int vals[100001]; int vis[100001]; int main() { int N; scanf("%d",&N); for (int i = 1; i <= N; i++) { scanf("%d", &vals[i]); } memset(vis, 0, sizeof vis); bool good = false; int counter = 0; int cur = 1; while (true) { if (vis[cur]) { break; } vis[cur] = 1; cur = vals[cur]; counter++; if (cur == 2) { good = true; break; } } if (good) { printf("%d", counter); } else { printf("-1"); } return 0; }
a.cc: In function 'int main()': a.cc:13:9: error: 'memset' was not declared in this scope 13 | memset(vis, 0, sizeof vis); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <cstdio> +++ |+#include <cstring> 4 | using namespace std;
s925223238
p03680
C++
#include<iostream> using namespace std; int main(){ int n,b=1,count=0,d; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } while(a[b-1]!=0 && a[b-1]!=2){ d=b; b=a[b-1]; a[d-1]=0; count=count+1; } if(a[b-1]==2){ cout<<count+1<<<endl; } else{ cout<<"-1"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:32: error: expected primary-expression before '<' token 17 | cout<<count+1<<<endl; | ^
s623382247
p03680
C++
#include<iostream> using namespace std; int main(){ int n,b=1,countnt=0,d; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } while(a[b-1]!=0 && a[b-1]!=2){ d=b; b=a[b-1]; a[d-1]=0; count=count+1; } if(a[b-1]==2){ cout<<count+1<<<endl; } else{ cout<<"-1"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'count' was not declared in this scope; did you mean 'countnt'? 14 | count=count+1; | ^~~~~ | countnt a.cc:17:23: error: 'count' was not declared in this scope; did you mean 'countnt'? 17 | cout<<count+1<<<endl; | ^~~~~ | countnt a.cc:17:32: error: expected primary-expression before '<' token 17 | cout<<count+1<<<endl; | ^
s131111122
p03680
C++
#include<iostream> using namespace std; int main(){ int n,b=1,c=0,d; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } while(a[b-1]!=0 && a[b-1]!=2){ d=b; b=a[b-1]; a[d-1]=0; count=count+1; } if(a[b-1]==2){ cout<<count+1<<<endl; } else{ cout<<"-1"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'count' was not declared in this scope 14 | count=count+1; | ^~~~~ a.cc:17:23: error: 'count' was not declared in this scope 17 | cout<<count+1<<<endl; | ^~~~~ a.cc:17:32: error: expected primary-expression before '<' token 17 | cout<<count+1<<<endl; | ^
s190446347
p03680
C++
#include<iostream> using namespace std; int main(){ int n,b=1,c=0,d; cin>>n; int a[n]; for(int i=0;i<nli++){ cin>>a[i]; } while(a[b-1]!=0 && a[b-1]!=2){ d=b; b=a[b-1]; a[d-1]=0; count=count+1; } if(a[b-1]==2){ cout<<count+1<<<endl; } else{ cout<<"-1"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:7:23: error: 'nli' was not declared in this scope 7 | for(int i=0;i<nli++){ | ^~~ a.cc:7:28: error: expected ';' before ')' token 7 | for(int i=0;i<nli++){ | ^ | ; a.cc:14:17: error: 'count' was not declared in this scope 14 | count=count+1; | ^~~~~ a.cc:17:23: error: 'count' was not declared in this scope 17 | cout<<count+1<<<endl; | ^~~~~ a.cc:17:32: error: expected primary-expression before '<' token 17 | cout<<count+1<<<endl; | ^
s257727272
p03680
C++
#include <iostream> using namespace std; int main() { int n,k=0,i; bool m1 = true;4 cin >> n; int *a = new int[n]; for (i = 0; i < n; i++) { cin >> a[i]; } i = 0; while (m1) { k++; if (a[i] == 2) { m1 = false;} else { i = a[i]; if (k > n) { m1 = false; k = -1; } } } cout << k; return 0; }
a.cc: In function 'int main()': a.cc:7:25: error: expected ';' before 'cin' 7 | bool m1 = true;4 | ^ | ; 8 | 9 | cin >> n; | ~~~
s302314017
p03680
C++
#include <iostream> using namespace std; int a[123456]; int main(){ int n;cin>>n; for(int i=0;i<n;++i){cin>>a[i];a[i]--;} int inf = 200000; int mi=inf; int pos=0; for (int i=0;i<inf;++i){ if(pos==1) mi = min(mi, i); pos=a[pos]; } cout<<(mi==inf?-1:mi) << endl;
a.cc: In function 'int main()': a.cc:14:31: error: expected '}' at end of input 14 | cout<<(mi==inf?-1:mi) << endl; | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s749935849
p03680
C++
N=int(raw_input()) a=[-1] for _ in range(N): a.append(int(raw_input())) i=1 c=0 while(1): if i==2: print c break elif c>=N: print -1 break c+=1 i=a[i]
a.cc:1:1: error: 'N' does not name a type 1 | N=int(raw_input()) | ^
s220661152
p03680
C++
from collections import defaultdict,deque dic=defaultdict(list) n=int(input()) for i in range(1,n+1): num=int(input()) dic[num].append(i) que=deque() que.append(2) co=0 while que: key=que.popleft() co+=1 if co>n: print(str(-1)) break if key==2: print(n) break for i in dic[key]: que.append(i) else: print(-1) break
a.cc:1:1: error: 'from' does not name a type 1 | from collections import defaultdict,deque | ^~~~
s872251071
p03680
Java
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = Integer.valueOf(sc.nextInt()); int a[] = new int[N]; int i; for(i=0; i<N; i++){ a[i] = sc.nextInt(); } int judge=0; i = 0; int count=0; while(judge != 2){ judge = a[i]; count++; i = judge-1; if(count > N) break; } if(count<N){ System.out.println(count); } else{ System.out.println(-1); } } }
Main.java:3: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s402074211
p03680
Java
import java.io.IOException; import java.util.Scanner; public class PB { public static int searchId(int n, int[] a, int id) throws IOException { for (int i = 0; i < n; i++) { if (a[i] == id) return i + 1; } return -1; } public static void solve() throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } int cnt = 1; int id = searchId(n, a, 2); if (id == 1) { System.out.println(cnt); } else if (id == -1) { System.out.println(-1); } else { for (int i = 0; i < n; i++) { cnt++; id = searchId(n, a, id); if (id == 1) { System.out.println(cnt); break; } else if (id == -1) { System.out.println(-1); break; } } } if (id != 1 && id != -1 && cnt == n + 1) System.out.println(-1); sc.close(); } public static void main(String[] args) { try { solve(); } catch (IOException e) { e.printStackTrace(); } } }
Main.java:4: error: class PB is public, should be declared in a file named PB.java public class PB { ^ 1 error
s620711616
p03680
C++
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; int n, ans; int a[100005]; int flag; int main() { flag = 0; ans = 0; memset(a, 0, sizeof(a)); scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%d", &a[i]); } int p = a[1]; a[1] = 0; while(true) { if(ans > 1000000 || a[o] == 0) {flag = 1; break;} if(p == 2) break; ans++; int o = p; p = a[p]; a[o] = 0; } if(flag == 1) printf("-1\n"); else printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:24:39: error: 'o' was not declared in this scope 24 | if(ans > 1000000 || a[o] == 0) {flag = 1; break;} | ^
s236293746
p03680
C++
v
a.cc:1:1: error: 'v' does not name a type 1 | v | ^
s243926926
p03680
C++
#include <iostream> #include <vector> #include <alglorithm> using namespace std; int main(){ long n; vector<long> a[100000], res; cin >> n; for (long i = 0;i<n;i++) { long ai; cin >> ai; a[(ai-1)].push_back(i); } res = a[1]; if (find(res.begin(), res.end(), (long)0)!=res.end()) { cout << 1 << endl; return 0; } res = a[1]; for (long i=0;i<=n;i++) { vector<long> tmp; for (auto it=res.begin();it!=res.end();it++) { tmp.insert(tmp.end(), a[(*it)].begin(), a[(*it)].end()); } res = tmp; if (find(tmp.begin(), tmp.end(), (long)0)!=tmp.end()) { cout << (i+2) << endl; return 0; } } cout << -1 << endl; return 1; }
a.cc:3:10: fatal error: alglorithm: No such file or directory 3 | #include <alglorithm> | ^~~~~~~~~~~~ compilation terminated.
s787423600
p03680
C++
#include <iostream> #include <vector> using namespace std; int main(){ long n; vector<long> a[100000], res; cin >> n; for (long i = 0;i<n;i++) { long ai; cin >> ai; a[(ai-1)].push_back(i); } res = a[1]; if (find(res.begin(), res.end(), (long)0)!=res.end()) { cout << 1 << endl; return 0; } res = a[1]; for (long i=0;i<=n;i++) { vector<long> tmp; for (auto it=res.begin();it!=res.end();it++) { tmp.insert(tmp.end(), a[(*it)].begin(), a[(*it)].end()); } res = tmp; if (find(tmp.begin(), tmp.end(), (long)0)!=tmp.end()) { cout << (i+2) << endl; return 0; } } cout << -1 << endl; return 1; }
a.cc: In function 'int main()': a.cc:18:11: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, long int)' 18 | if (find(res.begin(), res.end(), (long)0)!=res.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:18:11: note: '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 18 | if (find(res.begin(), res.end(), (long)0)!=res.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:29:13: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, long int)' 29 | if (find(tmp.begin(), tmp.end(), (long)0)!=tmp.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:29:13: note: '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 29 | if (find(tmp.begin(), tmp.end(), (long)0)!=tmp.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s775485521
p03680
C++
#include <bits/stdc++.h> using namespace std; #define forn(i, s, f) for(int i = (s); i <= (f); ++i) #define for1(i, f, s) for(int i = (f); i >= (s); --i) #define fora(i, x) for (auto i : x) #define show(x) cout << #x << " = " << x << " "; #define skip continue; #define pb push_back #define _1 first #define _2 second typedef long long ll; const int N3 = 1e3 + 5; const int N4 = 1e4 + 5; const int N5 = 1e5 + 5; const int N6 = 1e6 + 5; const int N7 = 1e7 + 5; const int N8 = 1e8 + 5; const int N9 = 1e9 + 5; const int mod = N9 + 2; int ans, n, x; vector < int > g[N5]; dfs (int v, int h) { ++ans; // cout << v << " "; if (v == 2) { cout << ans - 1; exit(0); } if (h == 1 && v == 1) { cout << -1; exit(0); } fora (to, g[v]) dfs(to, 1); } int main() { cin >> n; forn (i, 1, n) { cin >> x; g[i].pb(x); } dfs(1, -1); cout << ans - 1; }
a.cc:29:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive] 29 | dfs (int v, int h) | ^~~ a.cc: In function 'int dfs(int, int)': a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type] 45 | } | ^
s844211619
p03680
C++
言 2017/6/24 21:10:57 #include <stdio.h> #define MAX 100000 int main() { int n,num=0; int a[MAX]; int i; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); i=1; while(1) { num++; if(a[i]==2) { printf("%d",num); break; } i=a[i]; if(num>n) { printf("-1"); break; } } }
a.cc:2:1: error: '\U00008a00' does not name a type 2 | 言 2017/6/24 21:10:57 | ^~ a.cc: In function 'int main()': a.cc:10:9: error: 'scanf' was not declared in this scope 10 | scanf("%d",&n); | ^~~~~ a.cc:19:25: error: 'printf' was not declared in this scope 19 | printf("%d",num); | ^~~~~~ a.cc:4:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 3 | #include <stdio.h> +++ |+#include <cstdio> 4 | #define MAX 100000 a.cc:25:25: error: 'printf' was not declared in this scope 25 | printf("-1"); | ^~~~~~ a.cc:25:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s234434061
p03680
C++
#include <bits/stdc++.h> using namespace std; #define forn(i, s, f) for(int i = (s); i <= (f); ++i) #define for1(i, f, s) for(int i = (f); i >= (s); --i) #define fora(i, x) for (auto i : x) #define show(x) cout << #x << " = " << x << " "; #define skip continue; #define pb push_back #define _1 first #define _2 second typedef long long ll; const int N3 = 1e3 + 5; const int N4 = 1e4 + 5; const int N5 = 1e5 + 5; const int N6 = 1e6 + 5; const int N7 = 1e7 + 5; const int N8 = 1e8 + 5; const int N9 = 1e9 + 5; const int mod = N9 + 2; int ans, n, x; vector < int > g[N5]; dfs (int v, int h = -1) { ++ans; // cout << v << " "; if (v == 2) { cout << ans - 1; exit(0); } if (h == 1 && v == 1) { cout << -1; exit(0); } fora (to, g[v]) dfs(to, 1); } int main() { cin >> n; forn (i, 1, n) { cin >> x; g[i].pb(x); } dfs(1); cout << ans - 1; }
a.cc:29:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive] 29 | dfs (int v, int h = -1) | ^~~ a.cc: In function 'int dfs(int, int)': a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type] 45 | } | ^
s736371674
p03680
C++
#include <iostream> #include <vector> using namespace std; int main(){ long n; vector<long> a[100000], res; cin >> n; for (long i = 0;i<n;i++) { long ai; cin >> ai; a[(ai-1)].push_back(i); } // res.insert(res.end(), a[2].begin(), a[2].end()); res = a[1]; if (find(res.begin(), res.end(), 0)!=res.end()) { cout << 1 << endl; return 0; } res = a[1]; for (long i=0;i<=n;i++) { vector<long> tmp; for (auto it=res.begin();it!=res.end();it++) { tmp.insert(tmp.end(), a[(*it)].begin(), a[(*it)].end()); } res = tmp; if (find(tmp.begin(), tmp.end(), 0)!=tmp.end()) { cout << (i+2) << endl; return 0; } } cout << -1 << endl; return 1; }
a.cc: In function 'int main()': a.cc:19:11: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, int)' 19 | if (find(res.begin(), res.end(), 0)!=res.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:19:11: note: '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 19 | if (find(res.begin(), res.end(), 0)!=res.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:30:13: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, int)' 30 | if (find(tmp.begin(), tmp.end(), 0)!=tmp.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:30:13: note: '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 30 | if (find(tmp.begin(), tmp.end(), 0)!=tmp.end()) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
s263087394
p03680
C++
#include <bits/stdc++.h> using namespace std; #define forn(i, s, f) for(int i = (s); i <= (f); ++i) #define for1(i, f, s) for(int i = (f); i >= (s); --i) #define fora(i, x) for (auto i : x) #define show(x) cout << #x << " = " << x << " "; #define skip continue; #define pb push_back #define _1 first #define _2 second typedef long long ll; const int N3 = 1e3 + 5; const int N4 = 1e4 + 5; const int N5 = 1e5 + 5; const int N6 = 1e6 + 5; const int N7 = 1e7 + 5; const int N8 = 1e8 + 5; const int N9 = 1e9 + 5; const int mod = N9 + 2; int ans, n, x; vector < int > g[N5]; dfs (int v, int h = -1) { ++ans; // cout << v << " "; if (v == 2) { cout << ans; exit(0); } if (h == 1 && v == 1) { cout << -1; exit(0); } fora (to, g[v]) dfs(to, 1); } int main() { cin >> n; forn (i, 1, n) { cin >> x; g[x].pb(i); } dfs(1); cout << ans; }
a.cc:29:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive] 29 | dfs (int v, int h = -1) | ^~~ a.cc: In function 'int dfs(int, int)': a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type] 45 | } | ^
s701575037
p03680
C++
#include<stdio.h> #define MAX 100000 int main() { int n,num=0; int a[MAX]; int i ; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); i=1; while(1) { num++; if(a[i]==2) { printf("%d\n",num); break; i=a[i]; if(num>n) { printf("-1\n"); break; }} return 0; }
a.cc: In function 'int main()': a.cc:27:2: error: expected '}' at end of input 27 | } | ^ a.cc:4:1: note: to match this '{' 4 | { | ^
s492884170
p03680
C++
5 3 3 4 2 4
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 | ^
s245295424
p03680
Java
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class B { public static void Main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] buttons = new int[n]; for(int i=0;i<n;i++){ buttons[i] = sc.nextInt(); } sc.close(); int glowinBtn = 1; Set<Integer> pshdBtn = new HashSet<Integer>(); do{ pshdBtn.add(glowinBtn); glowinBtn = buttons[glowinBtn-1]; }while(!(glowinBtn==2 || pshdBtn.contains(glowinBtn))); int result = -1; if(glowinBtn==2){ result = pshdBtn.size(); } System.out.print(result); return; } }
Main.java:5: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s267193122
p03680
C++
#include <iostream> using namespace std; int z; int n; int x[100005]; int now ; int counter = 0; int a; int main() { cin >> n; for(int i = 0 ; i <= n - 1 ; i ++) { cin >> x[i]; } now = x[0] - 1; while(1) { if(x[now] == 0) { counter = -1; break; } a = x[now] - 1; x[now] = 0; now = a; if(now == 2) { couter --; break; } counter ++; } cout << counter << endl; return 0; }
a.cc: In function 'int main()': a.cc:32:25: error: 'couter' was not declared in this scope; did you mean 'counter'? 32 | couter --; | ^~~~~~ | counter
s169016424
p03680
Java
public class Main{ public static void main(String args[] ) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] array = new int[n]; boolean[] b = new boolean[n]; b[0] = true; for (int i = 1; i < n; i++) b[i] = false; for (int i = 0; i < n; i++) { array[i] = sc.nextInt(); } int count = 0; for (int i = 0; i < n; i++) { if (b[1] == true) break; if (i == n - 1) { count = -1; break; } for (int j = 0; j < n; j++) { if (b[j] == true) { b[j] = false; b[array[j] - 1] = true; count++; } } } System.out.println(count); } }
Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s515465028
p03680
Java
import java.util.Scanner; public class Maiin { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] num = new int[n]; for (int i = 0; i < num.length; i++) { num[i] = scanner.nextInt(); } boolean[] check = new boolean[n]; int i = 0; int count = 0; while (!check[i]) { //System.out.println(i); count++; check[i] = true; i = num[i] - 1; if (i == 1) { System.out.println(count); System.exit(0); } } System.out.println("-1"); scanner.close(); } }
Main.java:3: error: class Maiin is public, should be declared in a file named Maiin.java public class Maiin { ^ 1 error
s599419302
p03680
Java
import java.util.*; import java.io.*; public class abc065_b { public static void main(String[] args) { InputReader s = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); /*My code starts here.*/ int n = s.nextInt(); boolean arr[] = new boolean[n+1]; int inp[] = new int[n+1]; for(int i=1;i<=n;i++) inp[i] = s.nextInt(); int flg=0,count=0; int i=1; while(true){ int k = inp[i]; if(arr[k]){ flg = -1; break; } arr[i] = true; count++; if(inp[i]==2){ break; } i = inp[i]; } if(flg==-1) out.println("-1"); else out.println(count); /*My code ends here.*/ out.close(); } static class Node implements Comparable<Node> { int num, freq, idx; public Node(int u, int v, int idx) { this.num = u; this.freq = v; this.idx = idx; } public int compareTo(Node n) { if (this.freq == n.freq) return Integer.compare(this.num, n.num); return Integer.compare(-this.freq, -n.freq); } } static void preCalcComb() { comb = new long[MAXN][MAXN]; comb[0][0] = 1; for (int i = 1; i < MAXN; i++) { comb[i][0] = 1; for (int j = 1; j <= i; j++) { comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % mod; } } } static long PowerMod(long a, long b, long m) { long tempo; if (b == 0) tempo = 1; else if (b == 1) tempo = a; else { long temp = PowerMod(a, b / 2, m); if (b % 2 == 0) tempo = (temp * temp) % m; else tempo = ((temp * temp) % m) * a % m; } return tempo; } long no_of_primes(long m, long n, long k) { long count = 0, i, j; int primes[] = new int[(int) (n - m + 2)]; if (m == 1) primes[0] = 1; for (i = 2; i <= Math.sqrt(n); i++) { j = (m / i); j *= i; if (j < m) j += i; for (; j <= n; j += i) { if (j != i) primes[(int) (j - m)] = 1; } } for (i = 0; i <= n - m; i++) if (primes[(int) i] == 0 && (i - 1) % k == 0) count++; return count; } static void shortestPaths(List<Edge>[] edges, int s, int[] prio, int[] pred) { Arrays.fill(pred, -1); Arrays.fill(prio, Integer.MAX_VALUE); prio[s] = 0; PriorityQueue<Long> q = new PriorityQueue<>(); q.add((long) s); while (!q.isEmpty()) { long cur = q.remove(); int curu = (int) cur; if (cur >>> 32 != prio[curu]) continue; for (Edge e : edges[curu]) { int v = e.t; int nprio = prio[curu] + e.cost; if (prio[v] > nprio) { prio[v] = nprio; pred[v] = curu; q.add(((long) nprio << 32) + v); } } } } static class Edge { int t, cost; public Edge(int t, int cost) { this.t = t; this.cost = cost; } } static class InputReader { private InputStream stream; private byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int snext() { if (snumChars == -1) throw new InputMismatchException(); if (curChar >= snumChars) { curChar = 0; try { snumChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (snumChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = snext(); while (isSpaceChar(c)) c = snext(); int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = snext(); while (isSpaceChar(c)) c = snext(); int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public int[] nextIntArray(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public String readString() { int c = snext(); while (isSpaceChar(c)) c = snext(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
Main.java:5: error: class abc065_b is public, should be declared in a file named abc065_b.java public class abc065_b { ^ Main.java:56: error: cannot find symbol comb = new long[MAXN][MAXN]; ^ symbol: variable comb location: class abc065_b Main.java:56: error: cannot find symbol comb = new long[MAXN][MAXN]; ^ symbol: variable MAXN location: class abc065_b Main.java:56: error: cannot find symbol comb = new long[MAXN][MAXN]; ^ symbol: variable MAXN location: class abc065_b Main.java:57: error: cannot find symbol comb[0][0] = 1; ^ symbol: variable comb location: class abc065_b Main.java:58: error: cannot find symbol for (int i = 1; i < MAXN; i++) { ^ symbol: variable MAXN location: class abc065_b Main.java:59: error: cannot find symbol comb[i][0] = 1; ^ symbol: variable comb location: class abc065_b Main.java:61: error: cannot find symbol comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % mod; ^ symbol: variable comb location: class abc065_b Main.java:61: error: cannot find symbol comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % mod; ^ symbol: variable comb location: class abc065_b Main.java:61: error: cannot find symbol comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % mod; ^ symbol: variable comb location: class abc065_b Main.java:61: error: cannot find symbol comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % mod; ^ symbol: variable mod location: class abc065_b 11 errors
s177266512
p03680
C++
/* ID: 5ak0 PROG: LANG: C++11 */ #include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mpr make_pair #define long long int using namespace std; typedef long long ll; typedef pair<int, int> pii; const int INF = 1e9 + 7, MAXN = 1e5 + 10; int n, a[MAXN], u[MAXN], d[MAXN]; void dfs(int v){ if (u[v] == 1) return; d[a[v]] = d[v] + 1; u[v] = 1; dfs(a[v]); } main(){ #ifndef SAKO //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); #endif // SAKO ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; dfs(1); cout << (u[2] == 0 ? -1 : d[2]); return 0; }
a.cc:12:19: error: two or more data types in declaration of 'll' 12 | #define long long int | ^~~ a.cc:16:9: note: in expansion of macro 'long' 16 | typedef long long ll; | ^~~~ a.cc:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 30 | main(){ | ^~~~
s096865361
p03680
C++
#define N 100000 int n; int a[N]; int color[N + 1]; int main() { cin >> n; for ( int i = 0; i <= N; i++ ) { a[i] = -1; } for ( int i = 1; i <= n; i++ ) { cin >> a[i]; } for ( int i = 1, j = 1; i < n; i++ ) { if ( a[j] == -1 ) { cout << -1 << endl; return 0; } else if ( a[j] == 2 ){ cout << i << endl; return 0; } else { j = a[j]; } } cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: 'cin' was not declared in this scope 8 | cin >> n; | ^~~ a.cc:19:13: error: 'cout' was not declared in this scope 19 | cout << -1 << endl; | ^~~~ a.cc:19:27: error: 'endl' was not declared in this scope 19 | cout << -1 << endl; | ^~~~ a.cc:22:13: error: 'cout' was not declared in this scope 22 | cout << i << endl; | ^~~~ a.cc:22:26: error: 'endl' was not declared in this scope 22 | cout << i << endl; | ^~~~ a.cc:29:5: error: 'cout' was not declared in this scope 29 | cout << -1 << endl; | ^~~~ a.cc:29:19: error: 'endl' was not declared in this scope 29 | cout << -1 << endl; | ^~~~
s138717178
p03681
C++
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0; i < n; i++) #define REP(i, n) for(ll i = 1; i < n + 1; i++) #define PI 3.14159265359 #define EPS 0.0000000001 #define MOD 1000000007 //cout << std::fixed << std::setprecision(15) << y << endl; // 階乗mod ll fmod(ll n){ ll ans = 1; for(ll i = 1; i <= n; i++){ ans *= i; ans %= MOD; } return ans; } int main(){ ll N, M; cin >> N >> M; ll if(N == M){ cout << (2 * fmod(N) % MOD) * fmod(M) % MOD << endl; }else if(abs(N - M) == 1){ if(N < M){ swap(N, M); } cout << fmod(N) * fmod(M) % MOD << endl; }else{ cout << 0 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:41:5: error: expected unqualified-id before 'if' 41 | if(N == M){ | ^~ a.cc:43:6: error: 'else' without a previous 'if' 43 | }else if(abs(N - M) == 1){ | ^~~~