submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s781912129 | 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++){
int x;
cin>>x;
A.at(i)=x-1;
}set<int>S;
bool ans=false;
int sum=0;
for(int i=0; ;i=A.at(i)){
sum++;
if(A.at(i)==1){
ans=true; break;
}else{
if(S.cout(A.at(i))){
break;
}else{
S.insert(A.at(i));
}
}
}if(ans)
cout<<sum<<endl;
else
cout<<-1<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:8: error: 'class std::set<int>' has no member named 'cout'; did you mean 'count'?
19 | if(S.cout(A.at(i))){
| ^~~~
| count
|
s505516120 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector <int> X(N);
for (int i=0; i < N ; i++)
cin >> X.at(i);
int a=1;
vector<int> Y(1,1)
for (int i=0;i<100000;i++){
Y.push_back X.at(a);
a=X.at(a);
if (X.at(a)==2){
cout<< i << endl;
break;
}
for(k=0; k<i-1; k++){
if (X.at(a) == X.at(k)){
cout<< "-2" << endl;
break;
}
}
}
}
| a.cc: In function 'int main()':
a.cc:12:3: error: expected ',' or ';' before 'for'
12 | for (int i=0;i<100000;i++){
| ^~~
a.cc:12:16: error: 'i' was not declared in this scope
12 | for (int i=0;i<100000;i++){
| ^
|
s536061042 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> a(N+1);
int i;
//dainyu-
for(i=1;i<N+1;i++)
cin >> a.at(i);
//search
int s=1,sum=1;
while(1){
int t;
t=s;
s=a.at(s);
a.at(t)=-1;
if(s==2)cout<<sum<<endl;break;
else if(s==-1)cout<<-1<<endl;break;
}
}
| a.cc: In function 'int main()':
a.cc:22:5: error: 'else' without a previous 'if'
22 | else if(s==-1)cout<<-1<<endl;break;
| ^~~~
|
s665871241 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
vector<int>vec(N);
for(int i=0;i<N;i++){
cin>>vec(N);
}
int Light=1;
bool flag=true;
int count=0;
for(int i=0;i<N;i++){
count=count+1;
Light=vec.at(Light-1);
if(Light==2){
flag=false;
break;
}
else{
}
}
if(flag==false){
cout<<count<<endl;
}
else{
cout<<-1<<endl;
}
}
| a.cc: In function 'int main()':
a.cc:8:13: error: no match for call to '(std::vector<int>) (int&)'
8 | cin>>vec(N);
| ~~~^~~
|
s336212827 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> Ass(N), Bss(N);
for(int i = 0;i < N;i++){
cin >> Ass.at(i);
}
bool flag = false;
int cnt = 0;
for(int j = 0;j < N+1;){
int c = Ass.at(i);
c--;
cnt++;
if(c == 1){
flag = true;
break;
}
else{
Ass.at(c)++;
}
if(Ass.at(c)>1){
flag = false;
cnt = 0;
break;
}
}
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:18:32: error: 'i' was not declared in this scope
18 | int c = Ass.at(i);
| ^
|
s088023676 | p03680 | C++ | N=int(input())
a=[int(input()) for i in range(N)]
x=1
for i in range(N):
if(x==2):
print(i)
exit()
x=a[x-1]
print("-1") | a.cc:1:1: error: 'N' does not name a type
1 | N=int(input())
| ^
|
s574523751 | p03680 | C++ | //そもそも2があるかどうか、
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i=0; i<N ; i++) {
cin >> vec.at(i);
}
int count=1;
int j=0;
for (true) {
if (vec.at(j)==2 || count==N+1)
break;
else {
j=vec.at(j);
count++;
}
}
if (count==N+1)
cout << -1 << endl;
else
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:16:12: error: expected ';' before ')' token
16 | for (true) {
| ^
| ;
a.cc:24:3: error: expected primary-expression before 'if'
24 | if (count==N+1)
| ^~
a.cc:23:4: error: expected ';' before 'if'
23 | }
| ^
| ;
24 | if (count==N+1)
| ~~
a.cc:24:3: error: expected primary-expression before 'if'
24 | if (count==N+1)
| ^~
a.cc:23:4: error: expected ')' before 'if'
23 | }
| ^
| )
24 | if (count==N+1)
| ~~
a.cc:16:7: note: to match this '('
16 | for (true) {
| ^
|
s585726484 | p03680 | C++ | //そもそも2があるかどうか、
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i=0; i<N ; i++) {
cin >> vec.at(i);
}
int count=1;
int j=0;
for (; j<N+1 ;) {
if (vec.at(j)==2 || count=N)
break;
else {
j=vec.at(j);
count++;
}
}
if (j=N)
cout << -1 << endl;
else
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:17:22: error: lvalue required as left operand of assignment
17 | if (vec.at(j)==2 || count=N)
| ~~~~~~~~~~~~~^~~~~~~~
|
s387205928 | p03680 | C++ | //そもそも2があるかどうか、
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i=0; i<N ; i++) {
cin >> vec.at(i);
}
int count=1;
int j=0;
for (; j<N+1 ;) {
if (vec.at(j)==2 && count=N)
break;
else {
j=vec.at(j);
count++;
}
}
if (j=N)
cout << -1 << endl;
else
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:17:22: error: lvalue required as left operand of assignment
17 | if (vec.at(j)==2 && count=N)
| ~~~~~~~~~~~~~^~~~~~~~
|
s959508340 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,a[110000];
cin>>n;
for(int i=1;i<n;i++) cin>>a[i];
int t=a[1],cnt=1;
for(int i=0;i<n;i++){
if(t==2){ cout<<cnt; return 0 };
t=a[t];
cnt++;
}
cout<<"-1";
}
| a.cc: In function 'int main()':
a.cc:10:34: error: expected ';' before '}' token
10 | if(t==2){ cout<<cnt; return 0 };
| ^~
| ;
|
s105846643 | 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.at(i);
}
int button = 1;
int count = 0;
for (int j=0;j < N+10;j++){
button = a.at(button - 1);
count++;
if(button == 2){
cout << count << endl;
break;
}else if(button ==){
cout << "-1" << endl;
break;
}
}
} | a.cc: In function 'int main()':
a.cc:8:9: error: 'i' was not declared in this scope
8 | for(i = 0;i < N;i++){
| ^
a.cc:19:27: error: expected primary-expression before ')' token
19 | }else if(button ==){
| ^
|
s524251832 | 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 ( )
| ^
|
s448583577 | p03680 | C++ | N = int(input())
A = [int(input()) for _ in range(N)]
now = 0
count = 0
while True:
if count >= N:
print(-1)
break
if now == 1:
print(count)
break
now = A[now] - 1
count += 1 | a.cc:1:1: error: 'N' does not name a type
1 | N = int(input())
| ^
|
s731757170 | 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 ans=1;
for(;;){
ans++;
if(a.at(a.at(0)-1)==2){
cout<<ans<<endl;
return 0;
}
else{
a.at(0)=a.at(a.at(0)-1);
if(ans>=n){
cout<<-1<<endl;
return 0;
}
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:19:15: error: 'n' was not declared in this scope
19 | if(ans>=n){
| ^
|
s271026189 | 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 sum=0;
for(int i=0;i<N;i++) {
if(a.at(1)!=1) {
sum=-1;
cout << sum << endl;}
else {if(a.at(i)!=2) {
sum+=1;}
else {
cout << sum << endl;}
}
}
}
}
| a.cc:21:1: error: expected declaration before '}' token
21 | }
| ^
|
s149743748 | p03680 | C++ | #include <bits/stdc++>
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 sum=0;
for(int i=0;i<N;i++) {
if(a.at(1)!=1) {
sum=-1;
cout << sum << endl;}
else {if(a.at(i)!=2) {
sum+=1;}
else {
cout << sum << endl;}
}
}
}
}
| a.cc:1:10: fatal error: bits/stdc++: No such file or directory
1 | #include <bits/stdc++>
| ^~~~~~~~~~~~~
compilation terminated.
|
s642178574 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n+1]={};
for(int i=1;i<n+1;i++){
cin >> a[i];
}
int num = a[1];
int count = 1;
for(int k=1;k<n+10;k++){
if(a[num]==2)[
count++;
break;
}
else{
num = a[num];
count++;
}
}
if (count>n) cout << -1 << endl;
else{
cout << count << endl;
}
} | a.cc: In function 'int main()':
a.cc:15:18: error: expected ',' before '++' token
15 | count++;
| ^~
| ,
a.cc:15:18: error: expected identifier before '++' token
15 | count++;
| ^~
a.cc:15:20: error: expected ']' before ';' token
15 | count++;
| ^
| ]
a.cc: In lambda function:
a.cc:15:20: error: expected '{' before ';' token
a.cc: In function 'int main()':
a.cc:18:9: error: 'else' without a previous 'if'
18 | else{
| ^~~~
a.cc: At global scope:
a.cc:23:5: error: expected unqualified-id before 'if'
23 | if (count>n) cout << -1 << endl;
| ^~
a.cc:24:5: error: expected unqualified-id before 'else'
24 | else{
| ^~~~
a.cc:27:1: error: expected declaration before '}' token
27 | }
| ^
|
s151251018 | 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 tmp = 1;
int cnt = 0;
while (;;) {
tmp = a.at(tmp);
cnt++;
if (tmp == 1 || tmp == 2) break;
}
if (tmp == 2) cout << cnt << endl;
else cout << -1 << endl;
} | a.cc: In function 'int main()':
a.cc:14:10: error: expected primary-expression before ';' token
14 | while (;;) {
| ^
a.cc:14:10: error: expected ')' before ';' token
14 | while (;;) {
| ~^
| )
a.cc:14:12: error: expected primary-expression before ')' token
14 | while (;;) {
| ^
|
s872947348 | p03680 | C++ | #include<bits/stdc+.h>
using namespace std;
int main(){
int n;
int count;
int light=1;
bool able=false;
vector<int> a(10000);
cin>>n;
for(int i=0;i<n;i++){
cin>>a.at(i);
}
for(int i=0;i<n;i++){
light=a.at(light-1);
if(light==2) able=true;
count=i+1;
if(able) break;
}
if(able) cout<<count<<endl;
else cout<<-1<<endl;
return 0;
} | a.cc:1:9: fatal error: bits/stdc+.h: No such file or directory
1 | #include<bits/stdc+.h>
| ^~~~~~~~~~~~~~
compilation terminated.
|
s773692793 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> light(N + 1); //最初のボタン「 1 」を含めるので要素数を +1 する
light.at(0) = 1; //最初のボタン「 1 」を要素 0番 に登録する
int SUM = 0; //ボタンを何回押したかカウントするための変数
int NEXT = 0; //次に押すボタンの番号を表す変数
int flag = 0; //ボタン「 2 」が光ったかどうかを判定するための変数
int a;
for(int i = 0; i < N; i++){
cin >> a;
light.at(i + 1) = a;
}
for(int j = 0; j < N; j++){
if(light.at(NEXT) == 2){
flag = 1;
break;
}
NEXT = light.at(NEXT);
SUM += 1;
}
if(flag == 1){
cout << SUM << endl;
}else{
cout << -1 << endl;
}
}
| a.cc:9:17: error: extended character is not valid in an identifier
9 | int SUM = 0; //ボタンを何回押したかカウントするための変数
| ^
a.cc:10:22: error: extended character is not valid in an identifier
10 | int NEXT = 0; //次に押すボタンの番号を表す変数
| ^
a.cc: In function 'int main()':
a.cc:9:17: error: '\U00003000' was not declared in this scope
9 | int SUM = 0; //ボタンを何回押したかカウントするための変数
| ^~
a.cc:10:24: error: expected ';' before 'int'
10 | int NEXT = 0; //次に押すボタンの番号を表す変数
| ^
| ;
11 | int flag = 0; //ボタン「 2 」が光ったかどうかを判定するための変数
| ~~~
a.cc:18:21: error: 'NEXT' was not declared in this scope
18 | if(light.at(NEXT) == 2){
| ^~~~
a.cc:19:17: error: 'flag' was not declared in this scope
19 | flag = 1;
| ^~~~
a.cc:22:9: error: 'NEXT' was not declared in this scope
22 | NEXT = light.at(NEXT);
| ^~~~
a.cc:25:12: error: 'flag' was not declared in this scope
25 | if(flag == 1){
| ^~~~
|
s820984143 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
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(vec.at(i) == N) cout << -1 << endl;
if(vec.at(i) == 2) break;
}
cout << i << endl; | a.cc: In function 'int main()':
a.cc:17:11: error: 'i' was not declared in this scope
17 | cout << i << endl;
| ^
a.cc:17:21: error: expected '}' at end of input
17 | cout << i << endl;
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s374964201 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, a, b;
a = 1;
b = 0;
cin >> N;
vector(int) vec(N);
for (int i = 0; i < N; i++) {
cin >> vec.at(i);
}
while (true) {
a = vec.at(a - 1);
b++;
if (a == 2) {
cout << b << endl;
break;
}
else if (b == N) {
cout << -1 << endl;
break;
}
}
} | a.cc: In function 'int main()':
a.cc:8:9: error: missing template arguments before '(' token
8 | vector(int) vec(N);
| ^
a.cc:8:10: error: expected primary-expression before 'int'
8 | vector(int) vec(N);
| ^~~
a.cc:10:12: error: 'vec' was not declared in this scope
10 | cin >> vec.at(i);
| ^~~
a.cc:13:9: error: 'vec' was not declared in this scope
13 | a = vec.at(a - 1);
| ^~~
|
s217007337 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,ans,k=1;
vector<int> vec;
cin >> N;
for(int i = 0;i < N;++i)
cin >> vec.at(i);
for(int j = 0;j < N;++j){
k = vec.at(k)
if (k == 1){
cout << j+1 << endl;
break;
}
if (j == N - 1)
cout << -1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:11:18: error: expected ';' before 'if'
11 | k = vec.at(k)
| ^
| ;
12 | if (k == 1){
| ~~
|
s142491073 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
//配列にa_iを代入
for(int i = 0; i < N; i++){
cin >> vec.at(i);
}
//判定
int x = 0;
int counter = 1;
for(int i = 0; i < N; i++){
//不可能判定
if(vec.at(x) == 1){
cout << -1 << endl;
break;
}
//成功判定
else if(vec.at(x) == 2){
cout << counter << endl;
break;
}
//ループ時判定
else if(cournter >= N){
cout << -1 << endl;
}
//継続判定
else{
counter += 1;
x = vec.at(x) - 1;
}
}
}
| a.cc: In function 'int main()':
a.cc:32:13: error: 'cournter' was not declared in this scope; did you mean 'counter'?
32 | else if(cournter >= N){
| ^~~~~~~~
| counter
|
s601030140 | 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 ( )
| ^
|
s678487344 | p03680 | C++ | include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int>v;
for (int i = 0; i < n; i++)
{
int z;
cin>>z;
z--;
v.push_back(z);
}
int now=0,c=0;
for(;;)
{
if (now==1)
{
cout<<c<<endl;
break;
}
c++;
now=v[now];
}
} | a.cc:1:1: error: 'include' does not name a type
1 | include <bits/stdc++.h>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:1: error: 'cin' was not declared in this scope
7 | cin>>n;
| ^~~
a.cc:8:1: error: 'vector' was not declared in this scope
8 | vector<int>v;
| ^~~~~~
a.cc:8:8: error: expected primary-expression before 'int'
8 | vector<int>v;
| ^~~
a.cc:14:5: error: 'v' was not declared in this scope
14 | v.push_back(z);
| ^
a.cc:21:8: error: 'cout' was not declared in this scope
21 | cout<<c<<endl;
| ^~~~
a.cc:21:17: error: 'endl' was not declared in this scope
21 | cout<<c<<endl;
| ^~~~
a.cc:25:9: error: 'v' was not declared in this scope
25 | now=v[now];
| ^
|
s057881043 | p03680 | C++ | #include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;
void Main()
{
int n;
cin >> n;
vi a(n);
rep(i,n) cin >> a[i]; a[i]--;
int now = 0;
vi seen(n,0);
seen[0] = 1;
int cnt = 0;
while(1){
now = a[now];
cnt++;
if(seen[a[now]] == 1) {
cout << -1 << endl;
return;
}else if(a[now] == 1){
cout << cnt << endl;
return;
}
}
cout << "error" << endl;
return;
}
int main()
{
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(15);
Main();
return 0;
}
| a.cc: In function 'void Main()':
a.cc:23:33: error: 'i' was not declared in this scope
23 | rep(i,n) cin >> a[i]; a[i]--;
| ^
|
s769566625 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int>a(10000);
for(int i=0; i<n; i++){
cin>>a.at(i);
}
bool check=false;
int count = 0;
int tmp = a.at(0);
for(int i=0; i<n; i++){
count++;
if(tmp==2){
check = true;
break;
}
tmp=a.at(tmp-1);
}
if(check)cout<<count<<endl;
else cout<<"-1"<<endl;
} | a.cc:23:1: error: stray '\16' in program
23 | <U+000E>
| ^~~~~~~~
|
s744487443 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,;
cin >> N;
vector<int> button(N);
for(int i = 0; i < N; i++){
cin >> button.at(i);
}
int num = 1, count = 0;
for(int i = 0; i <= N; i++){
num = button.at(num - 1);
count++;
if(num == 2){
break;
}
}
if(count > N){
count = -1;
}
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:5:9: error: expected unqualified-id before ';' token
5 | int N,;
| ^
|
s887222230 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, cnt = 0, tmp = 0;
cin >> N;
vector<int> Button(N);
for (int i = 0; i < N; i++) {
int z;
cin >> z;
z--;
Button.at(i) = Z;
}
//入力層終わり
for (;; cnt++) {
if (tmp == 1) {
cout << cnt << endl;
break;
}
if (cnt >= N) {
cout << "-1" << endl;
}
tmp = Button.at(tmp);
}
} | a.cc: In function 'int main()':
a.cc:13:24: error: 'Z' was not declared in this scope
13 | Button.at(i) = Z;
| ^
|
s670378767 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, cnt = 0;
cin >> N;
vector<int> Button(N);
for (int i = 0; i < N) {
cin >> Button.at(i);
}
for (cnt = 0; cnt < N; cnt++) {
int tmp;
if (cnt == 0) tmp = 0;
if (tmp == 1) {
cnt++;
break;
}
tmp = Button.at(tmp);
}
cout << cnt + 1 << endl;
} | a.cc: In function 'int main()':
a.cc:9:26: error: expected ';' before ')' token
9 | for (int i = 0; i < N) {
| ^
| ;
|
s667757429 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, cnt = 0;
cin >> N;
vector<int> Button(N);
for (int i = 0; i < N) {
cin >> Button.at(i);
}
for (int i = 0; i < N; i++) {
if (i == 1) {
cnt = -1;
break;
}
cnt++;
}
cout << cnt <<endl;
} | a.cc: In function 'int main()':
a.cc:9:26: error: expected ';' before ')' token
9 | for (int i = 0; i < N) {
| ^
| ;
|
s133193103 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, cnt = 0;
cin >> N;
vector<int> Button(N);
for (int i == 0; i < N) {
cin >> Button.at(i);
}
for (int i = 0; i < N; i++) {
if (i == 1) {
cnt = -1;
break;
}
cnt++;
}
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:9:15: error: expected ';' before '==' token
9 | for (int i == 0; i < N) {
| ^~~
| ;
a.cc:9:16: error: expected primary-expression before '==' token
9 | for (int i == 0; i < N) {
| ^~
|
s635687197 | p03680 | C++ | #include<bits/stdc++.h>
int main(){
int n,k=0,a[n],d=0;
cin >> n;
for(int i=0;i<n;i++){
cin >> a[i];
}
while(d<n+1){
d++;
k=a[k];
if(k==1){
cout << d;
return 0;
}
}
cout << -1;
} | a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
4 | cin >> n;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:12:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
12 | cout << d;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:16:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
16 | cout << -1;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
|
s455689250 | p03680 | C++ | #include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
int n;
cin >> n;
vector<int> a;
rep(i,n) {
cin >> a[i];
a[i]--;
}
vector<bool> did(n,false);
int now = 0;
int cnt = 0;
for {
if(now == 1) {
cout << cnt << endl;
return 0;
}
if(did[now]) {
cout << -1 << endl;
return 0;
}
did[now] = true;
cnt++;
now = a[now];
}
} | a.cc: In function 'int main()':
a.cc:20:9: error: expected '(' before '{' token
20 | for {
| ^
| (
a.cc:20:9: error: expected primary-expression before '{' token
a.cc:33:1: error: expected primary-expression before '}' token
33 | }
| ^
a.cc:32:6: error: expected ';' before '}' token
32 | }
| ^
| ;
33 | }
| ~
a.cc:33:1: error: expected primary-expression before '}' token
33 | }
| ^
a.cc:32:6: error: expected ')' before '}' token
32 | }
| ^
| )
33 | }
| ~
a.cc:20:9: note: to match this '('
20 | for {
| ^
a.cc:33:1: error: expected primary-expression before '}' token
33 | }
| ^
|
s713611733 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i=0;i<N;i++)
cin >> vec.at(i);
int p = vec.at(0);
int t=0;
int j;
for(j=0;j<N;j++){
t++;
if(p==2)
break;
else
p=vec.at(p-1)
}
if (j==N)
cout << -1 << endl;
else
cout << t << endl;
}
| a.cc: In function 'int main()':
a.cc:21:20: error: expected ';' before '}' token
21 | p=vec.at(p-1)
| ^
| ;
22 | }
| ~
|
s754190255 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i = 0;i < N;i++) {
cin >> vec.at(i);
}
int A = vec.at(0);
int B = 0;
int j;
for (j = 0;j < N;j++) {
B++;
for (A == 2) {
break;
}
A = vec.at(A - 1);
}
if (j == N) {
cout << -1 << endl;
} else {
cout << B << endl;
}
} | a.cc: In function 'int main()':
a.cc:19:16: error: expected ';' before ')' token
19 | for (A == 2) {
| ^
| ;
a.cc:23:3: error: expected primary-expression before '}' token
23 | }
| ^
a.cc:22:23: error: expected ')' before '}' token
22 | A = vec.at(A - 1);
| ^
| )
23 | }
| ~
a.cc:19:9: note: to match this '('
19 | for (A == 2) {
| ^
a.cc:23:3: error: expected primary-expression before '}' token
23 | }
| ^
|
s463878645 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i = 0; i < N;i++) {
cin >> vet.at(i);
}
int A = vec.at(0);
int B = 0;
int j;
for (j = 0;j < N - 1;j++) {
B++;
if (A == 2) {
break;
}
A = vec.at(A - 1);
}
if (j == N - 1) {
cout << -1 << endl;
} else {
cout << B << endl;
}
}
| a.cc: In function 'int main()':
a.cc:10:12: error: 'vet' was not declared in this scope; did you mean 'vec'?
10 | cin >> vet.at(i);
| ^~~
| vec
|
s372417842 | p03680 | C++ | #include <bits/stbc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i = 0; i < N;i++) {
cin >> vet.at(i);
}
int A = vec.at(0);
int B = 0;
int j;
for (j = 0;j < N - 1;j++) {
B++;
if (A == 2) {
break;
}
A = vec.at(A - 1);
}
if (j == N - 1) {
cout << -1 << endl;
} else {
cout << B << endl;
}
} | a.cc:1:10: fatal error: bits/stbc++.h: No such file or directory
1 | #include <bits/stbc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s901955041 | 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 ( )
| ^
|
s389137160 | p03680 | C++ | int main(){
long n,f(0),ans(0),a(0);
cin >> n;
long h[n];
for(int i=0;i<n;i++){
cin >> h[i];
if(h[i]==2)
f++;
}
a = h[0];
if(f==0)
cout << -1 << endl;
for(int i=0;i<n;i++){
a = h[a-1];
ans++;
if(a==2){
cout << ans+1 << endl;
return 0;
}
}
cout << -1 << endl;
} | a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
3 | cin >> n;
| ^~~
a.cc:16:9: error: 'cout' was not declared in this scope
16 | cout << -1 << endl;
| ^~~~
a.cc:16:23: error: 'endl' was not declared in this scope
16 | cout << -1 << endl;
| ^~~~
a.cc:22:13: error: 'cout' was not declared in this scope
22 | cout << ans+1 << endl;
| ^~~~
a.cc:22:30: error: 'endl' was not declared in this scope
22 | cout << ans+1 << endl;
| ^~~~
a.cc:26:5: error: 'cout' was not declared in this scope
26 | cout << -1 << endl;
| ^~~~
a.cc:26:19: error: 'endl' was not declared in this scope
26 | cout << -1 << endl;
| ^~~~
|
s666841517 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
int n;
cin >> n;
vector<int> a(n);
rep(i,n) cin >> a[i];
int ans = 0, ans = a[0];
rep(i,n){
if(a[num] == 2){
++ans;
cout << ans << endl;
return 0;
}
if(a[num] == 1){
cout << -1 << endl;
return 0;
}
num = a[num];
++ans;
}
cout << -1 << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:12:16: error: redeclaration of 'int ans'
12 | int ans = 0, ans = a[0];
| ^~~
a.cc:12:7: note: 'int ans' previously declared here
12 | int ans = 0, ans = a[0];
| ^~~
a.cc:15:10: error: 'num' was not declared in this scope; did you mean 'enum'?
15 | if(a[num] == 2){
| ^~~
| enum
a.cc:20:10: error: 'num' was not declared in this scope; did you mean 'enum'?
20 | if(a[num] == 1){
| ^~~
| enum
a.cc:24:5: error: 'num' was not declared in this scope; did you mean 'enum'?
24 | num = a[num];
| ^~~
| enum
|
s838900184 | p03680 | C++ | v#include<iostream>
#include<vector>
using namespace std;
int main(){
int tmp = 1;
int count = 0;
bool flg = false;
int N; cin >> N;
vector<int> a(N+1);
//入力
for(int i = 1; i <= N;i++){
cin >> a.at(i);
}
for(int i = 1; i <= N; i++){
count++;
if(a.at(tmp) == 2){
cout << count;
flg = true;
break;
}
tmp = a.at(tmp);
}
if(!flg)
cout << -1;
return 0;
} | a.cc:1:2: error: stray '#' in program
1 | v#include<iostream>
| ^
a.cc:1:1: error: 'v' does not name a type
1 | v#include<iostream>
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | |
s044453339 | p03680 | C++ | //B - Trained? 2017/06/24
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >>n;
int a[n];
for(int i=0;i<n;++i) cin >> a[i];
int ans=1;int cnt=0;
for(int i=1;i<=n;){
if(a[i]==2) break;
i=a[i];
++cnt;
if(cnt==n+1) {cout << -1 << endl; return 0};
++ans;
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:15:51: error: expected ';' before '}' token
15 | if(cnt==n+1) {cout << -1 << endl; return 0};
| ^
| ;
|
s953951365 | p03680 | C++ | //B - Trained? 2017/06/24
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >>n;
int a[n];
for(int i=0;i<n;++i) cin >> a[i];
int ans=1;cnt=0;
for(int i=1;i<=n;){
if(a[i]==2) break;
i=a[i];
++cnt;
if(cnt==n+1) {cout << -1 << endl; return 0};
++ans;
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:10:15: error: 'cnt' was not declared in this scope; did you mean 'int'?
10 | int ans=1;cnt=0;
| ^~~
| int
a.cc:15:51: error: expected ';' before '}' token
15 | if(cnt==n+1) {cout << -1 << endl; return 0};
| ^
| ;
|
s794367873 | p03680 | C++ | //B - Trained? 2017/06/24
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >>n;
int a[n];
for(int i=0;i<n;++i) cin >> a[i];
int ans=1;cnt=0;
for(int i=1;i<=n;){
if(a[i]==2) break;
i=a[i];
++cnt;
if(cnt==n+1) {cout << -1 << endl; return 0};
++ans;
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:10:15: error: 'cnt' was not declared in this scope; did you mean 'int'?
10 | int ans=1;cnt=0;
| ^~~
| int
a.cc:15:51: error: expected ';' before '}' token
15 | if(cnt==n+1) {cout << -1 << endl; return 0};
| ^
| ;
|
s347771002 | p03680 | C++ | #include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int N;
vector<int> a(N);
cin >> N;
rep(i, N) cin >> a.at(i);
int cnt = 0;
int tmp_a = 0;
rep(i, N) {
tmp_a = a.at(tmp_a) - 1;
++cnt;
if (tmp_a == 1) break;
}
if (x == 1) cout << cnt << endl;
else cout << -1 << endl;
}
| a.cc: In function 'int main()':
a.cc:18:7: error: 'x' was not declared in this scope
18 | if (x == 1) cout << cnt << endl;
| ^
|
s447561181 | p03680 | C++ | #include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int N;
vector<int> a(N);
cin >> N;
rep(i, N) cin >> a.at(i);
bool flag = false;
int tmp_a = 0;
rep(i, N) {
tmp_a = a.at(tmp_a) - 1;
if (tmp_a == 1) {
flag = true;
break;
}
if (tmp_a == 0) break;
}
if (flag) cout << cnt << endl;
else cout << -1 << endl;
}
| a.cc: In function 'int main()':
a.cc:21:21: error: 'cnt' was not declared in this scope; did you mean 'int'?
21 | if (flag) cout << cnt << endl;
| ^~~
| int
|
s691678387 | p03680 | C++ | #include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int N;
vector<int> a(N);
cin >> N;
rep(i, N) cin >> a.at(i);
bool flag = false;
int tmp_a = 0;
int cnt = 0;
rep(i, N) {
tmp_a = a.at(tmp_a) - 1;
++cnt;
if (tmp_a == 1) {
flag = true;
break;
}
else if (tmp_a == 0) break;
}
if (flag) cout << cnt << endl;
else cout << -1 << endl;
}
| a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
7 | vector<int> a(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:10: error: expected primary-expression before 'int'
7 | vector<int> a(N);
| ^~~
a.cc:9:20: error: 'a' was not declared in this scope
9 | rep(i, N) cin >> a.at(i);
| ^
a.cc:14:13: error: 'a' was not declared in this scope
14 | tmp_a = a.at(tmp_a) - 1;
| ^
|
s692263133 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >>N;
vector<int> bot(N);
for(int i=0;i<N;i++)
cin>>bot.at(i);
int a=1,count=0;
for(int i=0;i<N;i++){
a=bot.at(a);
count++;
if(a==2)
break!;
}
if(count==0)
count=-1;
cout<<count<<endi;
}
| a.cc: In function 'int main()':
a.cc:19:12: error: expected ';' before '!' token
19 | break!;
| ^
| ;
a.cc:19:13: error: expected primary-expression before ';' token
19 | break!;
| ^
a.cc:25:16: error: 'endi' was not declared in this scope
25 | cout<<count<<endi;
| ^~~~
|
s291884448 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >>N;
vctor<int> bot(N);
for(int i=0;i<N;i++)
cin>>bot.at(i);
int a=1,count=0;
for(int i=0;i<N;i++){
a=bot.at(a);
count++;
if(a==2)
break!;
}
if(count==0)
count=-1;
cout<<count<<endi;
}
| a.cc: In function 'int main()':
a.cc:8:3: error: 'vctor' was not declared in this scope
8 | vctor<int> bot(N);
| ^~~~~
a.cc:8:9: error: expected primary-expression before 'int'
8 | vctor<int> bot(N);
| ^~~
a.cc:11:10: error: 'bot' was not declared in this scope
11 | cin>>bot.at(i);
| ^~~
a.cc:16:7: error: 'bot' was not declared in this scope
16 | a=bot.at(a);
| ^~~
a.cc:19:12: error: expected ';' before '!' token
19 | break!;
| ^
| ;
a.cc:19:13: error: expected primary-expression before ';' token
19 | break!;
| ^
a.cc:25:16: error: 'endi' was not declared in this scope
25 | cout<<count<<endi;
| ^~~~
|
s664789586 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
vector<int> b[N];
for(int i=0; i<N; i++)
{
cin>>b[i];
}
int t=0;
int p=0;
for(int i=0; i<N; i++)
{
t++;
p=b.at(p)-1;
if(p==1)
{
cout<<t<<endl;
return 0;
}
}
cout <<-1<<endl;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
vector<int> b(N);
for(int i=0; i<N; i++)
{
cin>>b.at(i);
}
int t=0;
int p=0;
for(int i=0; i<N; i++)
{
t++;
p=b.at(p)-1;
if(p==1)
{
cout<<t<<endl;
return 0;
}
}
cout <<-1<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:8: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<int>')
11 | cin>>b[i];
| ~~~^~~~~~
| | |
| | std::vector<int>
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
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/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/include/c++/1 |
s177636173 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
vector<int> b[N];
for(int i=0; i<N; i++)
{
cin>>b[i];
}
int t=0;
int p=0;
for(int i=0; i<N; i++)
{
t++;
p=b.at(p)-1;
if(p==1)
{
cout<<t<<endl;
return 0;
}
}
cout <<-1<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:8: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<int>')
11 | cin>>b[i];
| ~~~^~~~~~
| | |
| | std::vector<int>
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
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/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/include/c++/1 |
s272621689 | p03680 | C++ | #include<iostream>using namespace std;main(void){
int n,c=0; cin>>n; int a[n]; for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){if(a[i]==2) {cout<<c;return 0;} else if(a[i]==-1){cout<<-1;return 0;}else{
i=a[i]-1; a[i]=-1; c++;
}
}
} | a.cc:1:25: warning: extra tokens at end of #include directive
1 | #include<iostream>using namespace std;main(void){
| ^~~~~~~~~
a.cc:1:9: fatal error: iostream>usin: No such file or directory
1 | #include<iostream>using namespace std;main(void){
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s914150937 | 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[i];
a[i]--;
}
bool<int> C(N,false);
int p = 0;
int count = 0;
while (!C[p]){
C[p] = true;
p = a[p];
count++;
}
if (C[2]) cout << count;
if (!C[2]) cout << -1;
} | a.cc: In function 'int main()':
a.cc:11:3: error: 'bool' is not a template
11 | bool<int> C(N,false);
| ^~~~
a.cc:11:22: error: expression list treated as compound expression in initializer [-fpermissive]
11 | bool<int> C(N,false);
| ^
a.cc:14:12: error: invalid types 'bool[int]' for array subscript
14 | while (!C[p]){
| ^
a.cc:15:6: error: invalid types 'bool[int]' for array subscript
15 | C[p] = true;
| ^
a.cc:19:8: error: invalid types 'bool[int]' for array subscript
19 | if (C[2]) cout << count;
| ^
a.cc:20:9: error: invalid types 'bool[int]' for array subscript
20 | if (!C[2]) cout << -1;
| ^
|
s322290332 | p03680 | Java | import java.util.Arrays;
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];
int i;
for(i=0;i<n;i++){
a[i] = sc.nextInt();
}
int ans = 0;
int total = 0;
for(i=0;i<n+i++){
if(a[i]==2){
total++;
ans = 1;
break;
}else{
total++;
}
}
if(ans==1){
System.out.println(-1);
}else{
System.out.println(total);
}
}
}
| Main.java:14: error: ';' expected
for(i=0;i<n+i++){
^
1 error
|
s485890717 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
#define MAX 100000;
int main(){
int N; cin >> N;
vector<int> bottom(N);
for(int i=0;i<N;i++){
cin >> bottom.at(i);
}
int num= bottom.at(0);
int count = 0;
while(true){
num = bottom.at(num);
count++;
if(num == 2){
cout << count << endl;
return 0;
}
if(count > MAX){
cout << -1 << endl;
return 0;
}
}
}
| a.cc: In function 'int main()':
a.cc:21:19: error: expected primary-expression before ')' token
21 | if(count > MAX){
| ^
|
s395484837 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n=0;
cin >> n;
vector<int> vec(n);
for (int i=0; i<n; i++) cin >> vec.at(i);
int now=0;
vector<bool> visited(n, false);
visited.at(0) = true;
int ans=0;
while (now == 1) {
if !(visited.at(vec.at(now)-1)) {
visited.at(vec.at(now)-1) = true;
now = vec.at(now)-1;
ans++;
}
else {
ans = -1;
break;
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:19:8: error: expected '(' before '!' token
19 | if !(visited.at(vec.at(now)-1)) {
| ^
| (
a.cc:24:5: error: 'else' without a previous 'if'
24 | else {
| ^~~~
|
s020091824 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n=0;
cin >> n;
vector<int> vec(n);
for (int i=0; i<n; i++) cin >> vec.at(i);
int now=0;
vector<bool> visited(n, false);
visited.at(0) = true;
int ans=0;
while (now == 1) {
if !(visited.at(vec.at(now)-1)) {
visited.at(vec.at(now)-1) = true;
now = vec.at(now)-1;
ans++;
}
else {
ans = -1;
break;
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:19:8: error: expected '(' before '!' token
19 | if !(visited.at(vec.at(now)-1)) {
| ^
| (
a.cc:24:5: error: 'else' without a previous 'if'
24 | else {
| ^~~~
|
s591264350 | p03680 | C++ | a | a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s787557676 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
vector a;
int s,d,f,c;
c = 0;
f= 1;
cin >> s;
while(s){
a.push_back(d);
s--;
}
while(1){
f = a.at(f-1);
if(f == 2)
cout << c << endl;
break;
c++;
if(c == s)
cout << "-2" << endl;
break;
}
}
| a.cc: In function 'int main()':
a.cc:4:10: error: class template argument deduction failed:
4 | vector a;
| ^
a.cc:4:10: error: no matching function for call to 'vector()'
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const _Alloc&)-> std::vector<_Tp, _Alloc>'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::vector<_Tp, _Alloc>'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::vector<_Tp, _Alloc>'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Tp&, const _Alloc&)-> std::vector<_Tp, _Alloc>'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Alloc&)-> std::vector<_Tp, _Alloc>'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const _Alloc&)-> std::vector<_Tp, _Alloc>'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: template argument deduction/substitution failed:
a.cc:4:10: note: couldn't deduce template parameter '_Tp'
4 | vector a;
| ^
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _Alloc>'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::vector(_InputIterator, _InputIterator, _Allocator)-> vector<_ValT, _Allocator>'
2033 | vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate expects 2 arguments, 0 provided
|
s780613771 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int N,ai;
cin >> N;
Vector<int> a(N,0);
for(int i = 0; i < N; i++)
{
cin >> a[i];
}
ai = a[0];
for(int i = 0; i < N; i++)
{
ai = a[ai];
if(ai == 2)
{
cout << 1 << endl;
exit(0);
}
}
cout << -1 << endl;
} | a.cc: In function 'int main()':
a.cc:9:9: error: 'Vector' was not declared in this scope
9 | Vector<int> a(N,0);
| ^~~~~~
a.cc:9:16: error: expected primary-expression before 'int'
9 | Vector<int> a(N,0);
| ^~~
a.cc:12:16: error: 'a' was not declared in this scope
12 | cin >> a[i];
| ^
a.cc:14:14: error: 'a' was not declared in this scope; did you mean 'ai'?
14 | ai = a[0];
| ^
| ai
|
s707603170 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N , a , count=1,tmp = 1;
vector<int> A(N);
for (int i = 0 ; i < N ; i++){
cin >> A[i];
}
while (A.[tmp] != 2){
count++;
A[tmp]=A[A[tmp]];
if (count > N)
cout << -1 << endl;
break;
}
cout << count <<endl;
} | a.cc: In function 'int main()':
a.cc:10:18: error: expected unqualified-id before '[' token
10 | while (A.[tmp] != 2){
| ^
|
s467753300 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N , a , count=1,tmp = 1;
vector<int> A(N);
for (int i = 0 ; i < N ; i++){
cin >> a;
A.at(i) = a;
}
for (int i = 0 ; i < N ; i++){
A.at(tmp-1) = tmp-1
if(A.at(tmp-1) == 2){
cout << count << endl;
break;
}
count++;
if(count == N)
cout << "-1" << endl;
}
} | a.cc: In function 'int main()':
a.cc:12:28: error: expected ';' before 'if'
12 | A.at(tmp-1) = tmp-1
| ^
| ;
13 | if(A.at(tmp-1) == 2){
| ~~
|
s924434616 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> A(N,0);
for(int i=0;i<N;i++){
cin >> A[i];
A[i] --;
}
int push=0,cur=0;
while(true){
push ++;
int next=A[cur];
if(next==-1){
cout << -1 << endl;
return 0;
}else if(next==1){
cout << push << endl;
return 0;
}
A[cur]=-1;
cur = next;
} | a.cc: In function 'int main()':
a.cc:25:4: error: expected '}' at end of input
25 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s262744603 | 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 light = 1;
int count = 0;
for(int i=0; i < N; i++){
if(light == 2){cout << count << endl; break;}
if(count > N){cout <<-1<< endl; break;}
count++;light = a.at(light)}
}
| a.cc: In function 'int main()':
a.cc:17:30: error: expected ';' before '}' token
17 | count++;light = a.at(light)}
| ^
| ;
|
s951653887 | 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 light = 1;
int count = 0;
for(int i=0; i < N; i++){
if(light != 2){ count++; light =a.at(light);}
else {count++; break;}}
if(count++ == N){cout << -1 << endl;}
else { cout << count << endl;}
}
| a.cc: In function 'int main()':
a.cc:9:19: error: expected ';' before '}' token
9 | cin >> a.at(i)}
| ^
| ;
|
s244663147 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int count=0;
int c=1;
int a;
int main(){
cin>>a;
vector<int> b(a);
for(int i=0;i<a;i++)cin>>b.at(i);
/* for(int i=1;i<a;i++){
if(c==2){
break;
}
count++;
c=b.at(c-1);
}*/
if(count==0)cout<<-1<<endl;
else cout<<count<<endl;
} | a.cc: In function 'int main()':
a.cc:17:6: error: reference to 'count' is ambiguous
17 | if(count==0)cout<<-1<<endl;
| ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:3:5: note: 'int count'
3 | int count=0;
| ^~~~~
a.cc:18:14: error: reference to 'count' is ambiguous
18 | else cout<<count<<endl;
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:3:5: note: 'int count'
3 | int count=0;
| ^~~~~
|
s581632808 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int count=0;
int c=1;
int a;
int main(){
cin>>a;
vector<int> b(a);
for(int i=0;i<a;i++)cin>>b.at(i);
for(int i=1;i<a;i++){
if(c==2){
break;
}
count++;
c=b.at(c-1);
}
if(count==0)cout<<-1<<endl;
else cout<<count<<endl;
} | a.cc: In function 'int main()':
a.cc:14:7: error: reference to 'count' is ambiguous
14 | count++;
| ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:3:5: note: 'int count'
3 | int count=0;
| ^~~~~
a.cc:17:6: error: reference to 'count' is ambiguous
17 | if(count==0)cout<<-1<<endl;
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:3:5: note: 'int count'
3 | int count=0;
| ^~~~~
a.cc:18:14: error: reference to 'count' is ambiguous
18 | else cout<<count<<endl;
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:3:5: note: 'int count'
3 | int count=0;
| ^~~~~
|
s117680968 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int count=0,c=1,a;
int main(){
cin>>a;
vector<int> b(a);
for(int i=0;i<a;i++)cin>>b[i];
for(int i=1;i<a;i++){
if(c==2)break;
count++;
c=b[c-1];
}
if(count)cout<<-1<<endl;
else cout<<count<<endl;
} | a.cc: In function 'int main()':
a.cc:10:5: error: reference to 'count' is ambiguous
10 | count++;
| ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:3:5: note: 'int count'
3 | int count=0,c=1,a;
| ^~~~~
a.cc:13:6: error: reference to 'count' is ambiguous
13 | if(count)cout<<-1<<endl;
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:3:5: note: 'int count'
3 | int count=0,c=1,a;
| ^~~~~
a.cc:14:14: error: reference to 'count' is ambiguous
14 | else cout<<count<<endl;
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:3:5: note: 'int count'
3 | int count=0,c=1,a;
| ^~~~~
|
s107335683 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
vector<int> vec;
for(int i=0;i<N;i++){
cin>>vec.at(i);
}
int j=0,c=0;
while(j==1){
int k=v.at(j)-1;
j=k;
c++;
if(c>=N){
cout<<-1<<endl;
break;
}
}
cout<<c<<endl;
}
| a.cc: In function 'int main()':
a.cc:13:11: error: 'v' was not declared in this scope
13 | int k=v.at(j)-1;
| ^
|
s898237422 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
vector<int> vec;
for(int i=0;i<N;i++){
cin>>vec.at(i);
}
int j=0,c=0;
while(j==1){
j=v.at(j)-1;
c++;
if(c>=N){
cout<<-1<<endl;
break;
}
}
cout<<c<<endl;
}
| a.cc: In function 'int main()':
a.cc:13:7: error: 'v' was not declared in this scope
13 | j=v.at(j)-1;
| ^
|
s033956637 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n,a,count=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>a;
count++;
if(a==2){
cout<<count;
return 0;
}
}
cout<<-1;
}
} | a.cc:18:1: error: expected declaration before '}' token
18 | }
| ^
|
s240039200 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for(int i = 0; i < N; i++){
cin >> vec.at(i);
}
int a = vec.at(0);
for(int i = 0; i < N; i++){
if(a == 2){
cout << i + 1 << endl;
break;
}
else if(i == N -1){
cout << -1 << endl;
break;
}
int b = vec.at(a) - 1
a = vec.at(b);
}
} | a.cc: In function 'int main()':
a.cc:22:5: error: expected ',' or ';' before 'a'
22 | a = vec.at(b);
| ^
|
s395557363 | p03680 | C++ | #include<iostream>
#include<vecotr>
#include<algorithm>
using namespace std;
int main(){
int n;
cin >> n;
vector<int>v(n);
for(int i = 0; i < n; i++)
cin >> v[i];
int ans = 1, tmp = 0, a = v[0];
for(int i = 0; i < n; i++){
if(a == 2) break;
tmp = a - 1;
a = v[tmp];
ans++;
if(i == n - 1) ans = -1;
}
cout << ans << endl;
return 0;
} | a.cc:2:9: fatal error: vecotr: No such file or directory
2 | #include<vecotr>
| ^~~~~~~~
compilation terminated.
|
s229414382 | p03680 | C | #include<stdio.h>
const int maxn=1e5+6;
int a[maxn],b[maxn],c[maxn];
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&b[i]);
}
for(int i=1;i<=n;i++)
{
a[i]=i;
}
int k=1,sum=1,flag=0;
c[1]=1;
while(n--)
{
c[b[k]]=1;
k=b[a[k]];
sum++;
if(k==2)
{
if(c[b[2]]==1)
{
printf("%d",sum-1);
flag=1;
break;
}
}
}
if(flag==0) printf("-1");
return 0;
} | main.c:3:5: error: variably modified 'a' at file scope
3 | int a[maxn],b[maxn],c[maxn];
| ^
main.c:3:13: error: variably modified 'b' at file scope
3 | int a[maxn],b[maxn],c[maxn];
| ^
main.c:3:21: error: variably modified 'c' at file scope
3 | int a[maxn],b[maxn],c[maxn];
| ^
|
s407547820 | p03680 | C++ | #include<iostream>
using namespace std;
int c[100005];
int time(0);
bool win(long int a,long int *b)
{
time++;
if(b[a]==2)
return true;
else
if(c[a]!=1)
{
c[a]=1;
a=b[a];
win(a,b);
}
else
return false;
}
int main()
{
int a;
long int b[100005];
cin>>a;
for(int i=1;i<=a;i++)
{
cin>>b[i];
}
if(win(1,b))
cout<<time;
else
cout<<"-1";
return 0;
} | a.cc:4:9: error: 'int time' redeclared as different kind of entity
4 | int time(0);
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
7 | time++;
| ^~~~
a.cc:7:13: error: lvalue required as increment operand
7 | time++;
| ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
|
s429608483 | p03680 | C++ | #include<iostream>
using namespace std;
int c[100005];
static int time=0;
bool win(long int a,long int *b)
{
time++;
if(b[a]==2)
return true;
else
if(c[a]!=1)
{
c[a]=1;
a=b[a];
win(a,b);
}
else
return false;
}
int main()
{
int a;
long int b[100005];
cin>>a;
for(int i=1;i<=a;i++)
{
cin>>b[i];
}
if(win(1,b))
cout<<time;
else
cout<<"-1";
return 0;
} | a.cc:4:12: error: 'int time' redeclared as different kind of entity
4 | static int time=0;
| ^~~~
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
7 | time++;
| ^~~~
a.cc:7:13: error: lvalue required as increment operand
7 | time++;
| ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
|
s073728638 | p03680 | C++ | #include<iostream>
using namespace std;
int c[100005];
int time=0;
bool win(long int a,long int *b)
{
time++;
if(b[a]==2)
return true;
else
if(c[a]!=1)
{
c[a]=1;
a=b[a];
win(a,b);
}
else
return false;
}
int main()
{
int a;
long int b[100005];
cin>>a;
for(int i=1;i<=a;i++)
{
cin>>b[i];
}
if(win(1,b))
cout<<time;
else
cout<<"-1";
return 0;
} | a.cc:4:5: error: 'int time' redeclared as different kind of entity
4 | int time=0;
| ^~~~
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
7 | time++;
| ^~~~
a.cc:7:13: error: lvalue required as increment operand
7 | time++;
| ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
|
s179294372 | p03680 | C++ | #include<iostream>
using namespace std;
int c[100005];
int time=0;
bool win(long int a,long int *b)
{
time++;
if(b[a]==2)
return true;
else
if(c[a]!=1)
{
c[a]=1;
a=b[a];
win(a,b);
}
else
return false;
}
int main()
{
int a;
long int b[100005];
cin>>a;
for(int i=1;i<=a;i++)
{
cin>>b[i];
}
if(win(1,b))
cout<<time;
else
cout<<"-1";
return 0;
} | a.cc:4:5: error: 'int time' redeclared as different kind of entity
4 | int time=0;
| ^~~~
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
7 | time++;
| ^~~~
a.cc:7:13: error: lvalue required as increment operand
7 | time++;
| ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
|
s904308435 | p03680 | C++ | #include<iostream>
using namespace std;
int c[100005];
int time=0;
bool win(long int a,long int *b)
{
time++;
if(b[a]==2)
return true;
else
if(c[a]!=1)
{
c[a]=1;
a=b[a];
win(a,b);
}
else
return false;
}
int main()
{
int a;
long int b[100005];
cin>>a;
for(int i=1;i<=a;i++)
{
cin>>b[i];
}
if(win(1,b))
cout<<time;
else
cout<<"-1";
} | a.cc:4:5: error: 'int time' redeclared as different kind of entity
4 | int time=0;
| ^~~~
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
7 | time++;
| ^~~~
a.cc:7:13: error: lvalue required as increment operand
7 | time++;
| ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
|
s313668303 | p03680 | C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_SIZE 100001
int seq[MAX_SIZE];
int main()
{
int n;
while(scanf_s("%d",&n)!=-1){
memset(seq,0,sizeof(seq));
for(int i=1;i<=n;i++){
scanf_s("%d",&seq[i]);
}
int step=1;
int num=seq[1];
int seq_n=1;
while(seq[num]!=num){
seq_n=num;
step++;
if(seq[seq_n]==2){
printf("%d\n",step);
break;
}
else{
if(seq_n==num){
printf("-1\n");
break;
}
else{
num=seq[seq_n];
}
}
}
}
return 0;
}
| main.c: In function 'main':
main.c:10:15: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
10 | while(scanf_s("%d",&n)!=-1){
| ^~~~~~~
| scanf
|
s784470286 | p03680 | C++ |
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include<set>
using namespace std;
typedef long long ll;
const int maxn=int(1e5 + 5);
int arr[maxn];
set<int>S;
int main()
{
S.clear(); int sizes = 0;
int n; cin >> n;
for (int i = 1; i <= n; i++)scanf_s("%d", &arr[i]);
int tmp = 1;
int ans = 0,k=1;
while (1) {
tmp = arr[tmp];
if (tmp == 2) { ans = k; break; }
S.insert(tmp); sizes++;
if (S.size() < sizes) { ans = -1; break; }
k++;
}
cout << ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:20:37: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
20 | for (int i = 1; i <= n; i++)scanf_s("%d", &arr[i]);
| ^~~~~~~
| scanf
|
s517649562 | p03680 | C | #include<stdio.h>
int main()
{
int const MAXV=100000;
int input=0;
do{scanf("%d",&input);}while(input<2);
int buttons[MAXV]={0};
int times=1;
for(int i=0;i<input;i++)
{
scanf("%d",&buttons[i]);
}
int i=buttons[0];
while(times<input)
{
i=buttons[i-1];
times++;
if(i==2)
break;
}
if(times<input)
printf("%d",times);
else
printf("-1");
return 0;
} | main.c: In function 'main':
main.c:7:27: error: variable-sized object may not be initialized except with an empty initializer
7 | int buttons[MAXV]={0};
| ^
|
s079273727 | p03680 | C | #include<stdio.h>
int main()
{
int N,a;
scanf_s("%d", &N);
int n[100000];
for (int i = 0; i < N; i++)
{
scanf_s("%d", &n[i]);
if (n[i] == 2)
{
printf("%d", i);
return 0;
}
}
printf("-1");
return 0;
} | main.c: In function 'main':
main.c:6:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
6 | scanf_s("%d", &N);
| ^~~~~~~
| scanf
|
s453382118 | p03680 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int main(void){
int n;
cin >> n;
int a[n];
int b,c,d;
c=1;
d=0;
for(int i=0;i<n;i++){
cin >> a[i];
}
b=a[0];
for(int i=0;i<n;i++){
if(b==2){d=c;}
else{c++;}
b=a[b];
}
if(d==0){printf("-1");}
else{printf("%d",d)}
} | a.cc: In function 'int main()':
a.cc:25:24: error: expected ';' before '}' token
25 | else{printf("%d",d)}
| ^
| ;
|
s038806375 | p03680 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int main(void){
int n;
cin >> n;
int a[n];
int b,c;
c=1;
for(int i=0;i<n;i++){
cin >> a[i];
}
b=a[0];
for(int i=0;i<n;i++){
if(b==2){printf("c")}
else if(b>n){printf("-1");}
else{c++;}
b=a[b];
}
} | a.cc: In function 'int main()':
a.cc:19:29: error: expected ';' before '}' token
19 | if(b==2){printf("c")}
| ^
| ;
|
s891959395 | p03680 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int main(void){
cin >> n;
int a[n];
int b,c;
c=1;
for(int i=0;i<n;i++){
cin >> a[i];
}
b=a[0];
for(int i=0;i<n;i++){
if(b==2){printf("c")}
else if(b>n){printf("-1");}
else{c++;}
b=a[b];
}
} | a.cc: In function 'int main()':
a.cc:8:12: error: 'n' was not declared in this scope
8 | cin >> n;
| ^
a.cc:14:16: error: 'a' was not declared in this scope
14 | cin >> a[i];
| ^
a.cc:16:7: error: 'a' was not declared in this scope
16 | b=a[0];
| ^
a.cc:18:29: error: expected ';' before '}' token
18 | if(b==2){printf("c")}
| ^
| ;
|
s405093676 | p03680 | C++ | #include<stdio.h>
#include<vector>
#include<iostream> //c++
/*
int main(){
int a=0;
char A[5];
for (int i = 0; i < 5; i++) {
scanf("%c\n", &A[i]);
}
for(int i = 0; i < 5; i++) {
if (A[i] =='A' &&A[i + 1]=='C') {
a = 1;
}
}
if (a == 1) {
printf("Yes");
}
else {
printf("No");
}
}*/
using namespace std;
int main() {
int g;
int N,Num=0;
vector<int>a;
scanf_s("%d", &N);
for (int i = 0; i < N;i++) {
cin >> g;
a.push_back(g);
}
int p=1;
while (true) {
p = a[p];
Num++;
if (p == 2) {
break;
}
}
printf("%d", Num);
} | a.cc: In function 'int main()':
a.cc:32:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
32 | scanf_s("%d", &N);
| ^~~~~~~
| scanf
|
s379706041 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int a,b;
int c=-1;
int main(){
cin>>a;
for(int i=0;i<a;i++){
cin>>b;
if(b==2){
c=i;
break;
}
cout<<c<<endl;
} | a.cc: In function 'int main()':
a.cc:14:2: error: expected '}' at end of input
14 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s935633134 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int a,b;
int c==-1;
int main(){
cin>>a;
for(int i=0;i<a;i++){
cin>>b;
if(b==2)c=i;
}
cout<<c<<endl;
} | a.cc:4:6: error: expected initializer before '==' token
4 | int c==-1;
| ^~
a.cc: In function 'int main()':
a.cc:9:13: error: 'c' was not declared in this scope
9 | if(b==2)c=i;
| ^
a.cc:11:9: error: 'c' was not declared in this scope
11 | cout<<c<<endl;
| ^
|
s713400250 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
int main()
{
int n; cin >> n;
int n[a];
rep(i,n) cin >> a[i];
int t = a[0] - 1;
int ans = 0;
rep(i,n) {
if (t == 1) {
ans++;
cout << ans << endl;
break;
}
ans++;
t = a[t] - 1;
if (i == n-1) cout << -1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:8:11: error: 'a' was not declared in this scope
8 | int n[a];
| ^
|
s866820351 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N;
int count = 0;
int temp0, temp1 = 1, 1;
cin >> N;
vector<int> a(N);
for (int i=0; i<N; i++) {
cin >> a.at(i);
}
while (temp1 != -1 || temp1 != 2) {
temp1 = a.at(temp0);
a.at(temp0) = -1;
temp0 = temp1;
count++;
if (temp1 == -1)
count = -1;
}
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:7:25: error: expected unqualified-id before numeric constant
7 | int temp0, temp1 = 1, 1;
| ^
|
s118603085 | 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 i = 1;
int cnt = 0;
bool b = false;
while(c < n){
cnt++;
i = a.at(i-1);
if (i == n-1) {
b = true;
break;
}
}
if(b) cout << cnt << endl;
else cout << -1 << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:9: error: 'c' was not declared in this scope
15 | while(c < n){
| ^
|
s208363976 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
int main() {
int N;
cin >> N;
vector<int> a(n);
for (int i = 0; i < N; i++){
cin >> a[i];
}
bool flag = true;
int cnt = 0;
int tmp = 0;
while (flag && cnt < N){
cnt++;
if (a[tmp - 1] == 2){
flag = false;
break;
}
}
if (flag) {
cout << -1 << endl;
}
else{
cout << cnt << endl;
}
}
| a.cc: In function 'int main()':
a.cc:10:19: error: 'n' was not declared in this scope
10 | vector<int> a(n);
| ^
|
s049924246 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
int main() {
int N;
cin >> N;
vector<int> a(n);
for (int i = 0; i < N; i++){
cin >> a[i];
}
bool flag = true;
int cnt = 0;
int tmp = 0;
while (flag && cnt < N){
cnt++
if (a[tmp - 1] == 2){
flag = false;
break;
}
}
if (flag) {
cout << -1 << endl;
}
else{
cout << cnt << endl;
}
}
| a.cc: In function 'int main()':
a.cc:10:19: error: 'n' was not declared in this scope
10 | vector<int> a(n);
| ^
a.cc:18:14: error: expected ';' before 'if'
18 | cnt++
| ^
| ;
19 | if (a[tmp - 1] == 2){
| ~~
|
s657252478 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N, tmp, cnt = 0;
cin >> N;
vector<int> arr(N);
for(int i = 0; i < N; i++) cin >> arr.at(i);
tmp = arr.at(0);
whlie(true){
cnt++;
if (tmp == 2) break;
if (cnt == N) {
cnt = -1;
break;
}
tmp = arr.at(tmp - 1);
}
cout << cnt << endl;
}
| a.cc: In function 'int main()':
a.cc:12:3: error: 'whlie' was not declared in this scope
12 | whlie(true){
| ^~~~~
|
s553718317 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N, tmp, cnt = 0;
cin >> N;
vector<int> arr(N);
for(int i = 0; i < N; i++) cin >> arr.at(i);
tmp = arr.at(0);
whlie(1){
cnt++;
if (tmp == 2) break;
if (cnt == N) {
cnt = -1;
break;
}
tmp = arr.at(tmp - 1);
}
cout << cnt << endl;
}
| a.cc: In function 'int main()':
a.cc:12:3: error: 'whlie' was not declared in this scope
12 | whlie(1){
| ^~~~~
|
s193342916 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N, tmp, cnt = 0;
cin >> N;
vector<int> arr(N);
for(int i = 0; i < N; i++) cin >> arr.at(i);
tmp = arr.at(0);
whlie(){
cnt++;
if (tmp == 2) break;
if (cnt == N) {
cnt = -1;
break;
}
tmp = arr.at(tmp - 1);
}
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:12:3: error: 'whlie' was not declared in this scope
12 | whlie(){
| ^~~~~
|
s410458817 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n;
cin>>n;
vector<int> l(n),r(n);
rep(i,n){
cin>>l.at(i);
}
r.at(0) = l.at(0);
if(l.at(0)==2){
cout<<2;
return 0;
}
int min=1;
for(int j=1; j<n; j++){
r.at(j) = l.at(r.at(j-1));
min++;
if(r.at(j)==2){
cout<<min;
return 0;
}
}
if(min==n){
cout<<-1;
} | a.cc: In function 'int main()':
a.cc:27:2: error: expected '}' at end of input
27 | }
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.