submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s694719782 | p03680 | C++ | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a[100010];
for(int i = 0; i < n; ++i) cin >> a[i];
int counter = 1;
while(a[i] != 2) {
int i = 0;
if(a[i] == 1) {
counter = -1;
break;
}
i = a[i] - 1;
++counter;
}
cout << counter << endl;
}
| a.cc: In function 'int main()':
a.cc:11:13: error: 'i' was not declared in this scope
11 | while(a[i] != 2) {
| ^
|
s903686049 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int N,s;
cin >> N;
vector<int> button(N+1,0);
button.at(0) = 1;
for(int i=0;i<N;i++){
cin >> s;
if(button.at(i) == 1){
button.at(i) = 0;
button.at(s-1) = 1;
button.at(N)++;
}
if(button.at(1) == 1){
cout << button.at(N) <<endl;
break;
}
}
if(button.at(1) != 1){
button.at(N) = -1;
cout <<button.at(N)<<endl;
}
| a.cc: In function 'int main()':
a.cc:28:2: error: expected '}' at end of input
28 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s572404710 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int N,s,result=0;
cin >> N;
vector<int> button(N,0);
button.at(0) = 1;
for(int i=0;i<N;i++){
cin >> s;
if(button.at(i) == 1){
button.at(i) = 0;
button.at(s-1) = 1;
result++;
}
}
if(button.at(1) == 1){
cout << result <<endl;
break;
}
if(button.at(1) != 1)
cout <<-1 << endl;
}
| a.cc: In function 'int main()':
a.cc:23:7: error: break statement not within loop or switch
23 | break;
| ^~~~~
|
s380078905 | 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 i=0;
while (int a != 2) {
a = vec.at(a);
++i;
if (i>N) {
break;
}
}
if (i <= N-1) {
cout << i << endl;
}else{
cout << -1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:12:16: error: expected initializer before '!=' token
12 | while (int a != 2) {
| ^~
a.cc:12:15: error: expected ')' before '!=' token
12 | while (int a != 2) {
| ~ ^~~
| )
a.cc:12:16: error: expected primary-expression before '!=' token
12 | while (int a != 2) {
| ^~
|
s998215561 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++) {
cin>>a[i];
a[i]--;
}
int vis[n]{};
int p=0;
int cnt=0;
while (1) {
if (vis[i]) {
cout<<-1<<endl;
return 0;
}
vis[p]=1;
p=a[p];
cnt++;
if (p==1) {
cout<<cnt<<endl;
return 0;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:17:17: error: 'i' was not declared in this scope
17 | if (vis[i]) {
| ^
|
s020711670 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,now,ans;
ans=0;
cin >> n;
vector<int> bot(n);
for(int i=0;i<n;i++){
cin>>(bot[i]-1);
}
for(;;){
if(now==1){
break;
}
if(ans>n){
ans=-1;
break;
}
ans++;
now=bot[now];
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:10:10: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
10 | cin>>(bot[i]-1);
| ~~~^~~~~~~~~~~~
| | |
| | __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka 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>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
/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>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'void*' [-fpermissive]
10 | cin>>(bot[i]-1);
| ~~~~~~~^~~
| |
| __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
a.cc:10:19: error: cannot bind rvalue '(void*)((long int)(bot.std::vector<int>::operator[](((std::vector<int>::size_type)i)) - 1))' to 'void*&'
/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>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:19: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::basic_istream<char>::__istream_type& (*)(s |
s408992559 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,now,ans;
ans=0;
cin >> n;
vector<int> bot(n);
for(int i=0;i<n;i++){
cin>>bot[i]-1;
}
for(;;){
if(now==1){
break;
}
if(ans>n){
ans=-1;
break;
}
ans++;
now=bot[now];
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:10:10: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
10 | cin>>bot[i]-1;
| ~~~^~
| |
| 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>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
10 | cin>>bot[i]-1;
/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>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'void*' [-fpermissive]
10 | cin>>bot[i]-1;
a.cc:10:18: error: cannot bind rvalue '(void*)((long int)(bot.std::vector<int>::operator[](((std::vector<int>::size_type)i)) - 1))' to 'void*&'
/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>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
10 | cin>>bot[i]-1;
/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>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed:
a.cc:10:18: er |
s082873838 | p03680 | C++ | #include <iostream>
using namespace std;
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<int> a(N);
for (int i = 0; i < N; i++)
{
cin >> a.at(i);
}
int j = 1;
int count = 0;
for (int i = 0; i < N; i++)
{
j = a.at(j - 1);
count++;
if (j == 2)
break;
}
if (count == N)
{
cout << -1 << "\n";
}
else
{
cout << count << "\n";
}
} | a.cc: In function 'int main()':
a.cc:11:5: error: 'vector' was not declared in this scope
11 | 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:11:12: error: expected primary-expression before 'int'
11 | vector<int> a(N);
| ^~~
a.cc:14:16: error: 'a' was not declared in this scope
14 | cin >> a.at(i);
| ^
a.cc:20:13: error: 'a' was not declared in this scope
20 | j = a.at(j - 1);
| ^
|
s352336409 | p03680 | C++ | #include <iostream>
#include <vector>
using namespace std;
int visit(int cnt, int idx, vector<int> &a, vector<bool> &v){
if(cnt >= N) return -1;
else if(v[a[idx]]) return -1;
else if(a[idx] == 2) return cnt;
else{
v[idx] = true;
return visit(cnt + 1, a[idx], a, v);
}
}
int main(void) {
int N;
cin >> N;
vector<int> a(N);
vector<bool> v(N);
for(int i = 0; i < N; i++) cin >> a[i];
cout << visit(1, a[0], a, v);
} | a.cc: In function 'int visit(int, int, std::vector<int>&, std::vector<bool>&)':
a.cc:8:13: error: 'N' was not declared in this scope
8 | if(cnt >= N) return -1;
| ^
a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type]
15 | }
| ^
|
s369104354 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main () {
int N, c = 1;
bool b = false;
cin >> N;
vector<int> vec(N);
for (int i = 0; i < N; i++) {
cin >> vec.at(i);
}
int p = vec.at(0);
if (p == 2) {
cout << 1;
}
else {
for (int i = 0; i < N - 1; i++) {
p = vec.at(p);
c++;
if (p == 2) {
cout << c;
b = true;
break;
}
}
if (!b){
cout << -1;
}
} | a.cc: In function 'int main()':
a.cc:29:2: error: expected '}' at end of input
29 | }
| ^
a.cc:4:13: note: to match this '{'
4 | int main () {
| ^
|
s596442787 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,sum,vek; cin >> N;
sum=0; vek=1;
vector<int> vec(N);
for(int i=0;i<N;i++){
cin >> vec.at(i);
}
if(sum<=N){
if(int i=0; ;i++){
if(vek!=2){
vek=vec.at(vek);
sum++;
}
else{
cout << sum << endl;
break;
}
}
}
else{
cout << -1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:13:19: error: expected primary-expression before ';' token
13 | if(int i=0; ;i++){
| ^
a.cc:13:18: error: expected ')' before ';' token
13 | if(int i=0; ;i++){
| ~ ^~
| )
a.cc:13:20: error: 'i' was not declared in this scope
13 | if(int i=0; ;i++){
| ^
|
s818581459 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,sum,vek; cin >> N;
sum=0; vek=1;
vector<int> vec(N);
for(int i=0;i<N;i++){
cin >> vec.at(i);
}
if(sum<=N){
if(int i=0;;i++){
if(vek!=2){
vek=vec.at(vek);
sum++;
}
else{
cout << sum << endl;
break;
}
}
}
else{
cout << -1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:13:18: error: expected primary-expression before ';' token
13 | if(int i=0;;i++){
| ^
a.cc:13:18: error: expected ')' before ';' token
13 | if(int i=0;;i++){
| ~ ^
| )
a.cc:13:19: error: 'i' was not declared in this scope
13 | if(int i=0;;i++){
| ^
|
s250192036 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,sum,vek; cin >> N;
sum=0; vek=1;
vector<int> vec(N);
for(int i=0;i<N;i++){
cin >> vec.at(i);
}
if(sum<=N){
if( ; ; ){
if(vek!=2){
vek=vec.at(vek);
sum++;
}
else{
cout << sum << endl;
break;
}
}
}
else{
cout << -1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:13:13: error: expected primary-expression before ';' token
13 | if( ; ; ){
| ^
a.cc:13:12: error: expected ')' before ';' token
13 | if( ; ; ){
| ~ ^~
| )
a.cc:13:15: error: expected primary-expression before ')' token
13 | if( ; ; ){
| ^
|
s152296841 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007
int main(){
int N;
cin >> N;
vector<int> a(N+1);
vector<int> flag(N+1);
rep(i,N){
cin >> a[i+1];
}
int cnt = 0;
flag[1] = 1;
for(int i=1;i<=N;i++){
cnt++;
if(flag(a[i])){
cout << -1 << endl;
return 0;
}
if(a[i]==2){
cout << cnt << endl;
return 0;
}
flag(a[i])=1;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:20:16: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
20 | if(flag(a[i])){
| ~~~~^~~~~~
a.cc:28:13: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
28 | flag(a[i])=1;
| ~~~~^~~~~~
|
s112782912 | p03680 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> a(N), b;
for(int i = 0; i < N; i++){
cin >> a[i];
}
int light_on = 0, cnt = 0;
while(cnt < 10**6){
light_on = a[light_on];
cnt += 1
if(light_on == 0){
cout << -1;
else if(light_on == 1);
cout << cnt;
}
}
} | a.cc: In function 'int main()':
a.cc:13:18: error: invalid type argument of unary '*' (have 'int')
13 | while(cnt < 10**6){
| ^~
a.cc:15:13: error: expected ';' before 'if'
15 | cnt += 1
| ^
| ;
16 | if(light_on == 0){
| ~~
|
s009475259 | 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 count=0, first=1;
while (true){
count++;
first = vec.at(first-1)
if (first==2){
cout<<count<<endl;
}
if (first==vec.at(0)){
cout << -1<<endl;
break;
}
}
} | a.cc: In function 'int main()':
a.cc:14:28: error: expected ';' before 'if'
14 | first = vec.at(first-1)
| ^
| ;
15 | if (first==2){
| ~~
|
s813636604 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,x,c_point=0,count=0;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a.at(i)-1;
}
while(c_point!=1){
if(a.at(c_point)==n){
count=-1;
c_point=1;
}
else{
x=c_point;
c_point=a.at(c_point);
a.at(x)=n;
count++;
}
}
cout<<count<<endl;
} | a.cc: In function 'int main()':
a.cc:9:8: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
9 | cin>>a.at(i)-1;
| ~~~^~~~~~~~~~~
| | |
| | __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka 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>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
/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>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'void*' [-fpermissive]
9 | cin>>a.at(i)-1;
| ~~~~~~~^~
| |
| __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
a.cc:9:17: error: cannot bind rvalue '(void*)((long int)(a.std::vector<int>::at(((std::vector<int>::size_type)i)) - 1))' to 'void*&'
/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>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:9:17: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive |
s427093165 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,c_point=1,end=0,count=0;
cin>>n;
vector<int> a(n+1);
for(int i=1;i<=n;i++)cin>>a.at(i);
while(c_point!=2&&c_point!=0)){
int x=c_point;
c_point=a.at(c_point);
a.at(x)=0;
count++;
}
if(c_point==2)cout<<count<<"/n";
if(c_point==0)cout<<-1<<"/n";
} | a.cc: In function 'int main()':
a.cc:9:32: error: expected primary-expression before ')' token
9 | while(c_point!=2&&c_point!=0)){
| ^
|
s899662008 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,c_point=1,end=0,count=0;
cin>>n;
vector<int> a(n+1);
for(int i=1;i<=n;i++)cin>>a.at(i);
while(!(c_point==2||c_point==0);){
int x=c_point;
c_point=a.at(c_point);
a.at(x)=0;
count++;
}
if(c_point==2)cout<<count<<"/n";
if(c_point==0)cout<<-1<<"/n";
} | a.cc: In function 'int main()':
a.cc:9:34: error: expected ')' before ';' token
9 | while(!(c_point==2||c_point==0);){
| ~ ^
| )
a.cc:9:35: error: expected primary-expression before ')' token
9 | while(!(c_point==2||c_point==0);){
| ^
|
s967812887 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N,cnt;
cin >> N;
vector<int> std(N,0);
for(int i = 0;i < N ;i++)
{
cin >> std.at(i);
}
int sv = 0;
for(int j = 0;j < N;j++)
{
cnt++;
sv = std.at(sv)
if(sv == 2)
{
cout << cnt << endl;
break;
}
else if(j == N - 1){
cout << -1 << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:16:24: error: expected ';' before 'if'
16 | sv = std.at(sv)
| ^
| ;
17 | if(sv == 2)
| ~~
a.cc:22:17: error: 'else' without a previous 'if'
22 | else if(j == N - 1){
| ^~~~
|
s423030434 | p03680 | C++ | #include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = n; i > 0; i--)
#define rep3(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep4(i, s, e) for (int i = (e); i < (int)(s); i--)
int main() {
int n;
cin >> n;
int count = 0;
int now = 1;
vector<int> count(n);
rep(i, n){
cin >> count.at(i);
}
while (now != 2 && count < n) {
now = count.at(now);
count++;
if (now == 2) {
break;
}
}
if (now != 2) {
count = -1;
}
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:14:17: error: conflicting declaration 'std::vector<int> count'
14 | vector<int> count(n);
| ^~~~~
a.cc:12:9: note: previous declaration as 'int count'
12 | int count = 0;
| ^~~~~
a.cc:17:22: error: request for member 'at' in 'count', which is of non-class type 'int'
17 | cin >> count.at(i);
| ^~
a.cc:21:21: error: request for member 'at' in 'count', which is of non-class type 'int'
21 | now = count.at(now);
| ^~
|
s590017518 | p03680 | C++ | #include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = n; i > 0; i--)
#define rep3(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep4(i, s, e) for (int i = (e); i < (int)(s); i--)
int main() {
int n;
int count = 0;
int now = 1;
vector<int> count(n);
rep(i, n){
cin >> count.at(i);
}
while (now != 2 && count < n) {
now = count.at(now);
count++;
if (now == 2) {
break;
}
}
if (now != 2) {
count = -1;
}
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:13:17: error: conflicting declaration 'std::vector<int> count'
13 | vector<int> count(n);
| ^~~~~
a.cc:11:9: note: previous declaration as 'int count'
11 | int count = 0;
| ^~~~~
a.cc:16:22: error: request for member 'at' in 'count', which is of non-class type 'int'
16 | cin >> count.at(i);
| ^~
a.cc:20:21: error: request for member 'at' in 'count', which is of non-class type 'int'
20 | now = count.at(now);
| ^~
|
s696760742 | p03680 | C++ | #include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = n; i > 0; i--)
#define rep3(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep4(i, s, e) for (int i = (e); i < (int)(s); i--)
int main() {
int n;
int count = 0;
int now = 1;
vector<int> count(n);
rep(i, n){
cin >> count.at(i);
}
while (now != 2 && count < n) {
now = count.at(now);
count++;
if (now == 2) {
break;
}
if (now != 2) {
count = -1;
}
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:13:17: error: conflicting declaration 'std::vector<int> count'
13 | vector<int> count(n);
| ^~~~~
a.cc:11:9: note: previous declaration as 'int count'
11 | int count = 0;
| ^~~~~
a.cc:16:22: error: request for member 'at' in 'count', which is of non-class type 'int'
16 | cin >> count.at(i);
| ^~
a.cc:20:21: error: request for member 'at' in 'count', which is of non-class type 'int'
20 | now = count.at(now);
| ^~
a.cc:30:2: error: expected '}' at end of input
30 | }
| ^
a.cc:9:12: note: to match this '{'
9 | int main() {
| ^
|
s500594727 | p03680 | C++ | #include <iostream>
#include <string>
using namespace std;
int main(){
int a, b, c, d, f, m;
cin>> a;
int a1[a];
for (int i = 0; i< a; i++){
cin>> a1[i];
}
f = 0;
b1 = false;
m = 0;
for (int i = 0; i< a; i++){
if (a1[f] == 2){
m++;
b1 = true;
break;
}
f = a1[f] -1;
m++;
}
if (b1 == true){
cout << m;
}
else if (b1 == false){
cout << "-1";
}
}
| a.cc: In function 'int main()':
a.cc:12:5: error: 'b1' was not declared in this scope; did you mean 'a1'?
12 | b1 = false;
| ^~
| a1
|
s480777516 | p03680 | C++ | #include <iostream>
#include <string>
using namespace std;
int main(){
cin>> a;
int a1[a];
for (int i = 0; i< a; i++){
cin>> a1[i];
}
f = 0;
b1 = false;
m = 0;
for (int i = 0; i< a; i++){
if (a1[f] == 2){
m++;
b1 = true;
break;
}
f = a1[f] -1;
m++;
}
if (b1 == true){
cout << m;
}
else if (b1 == false){
cout << "-1";
}
}
| a.cc: In function 'int main()':
a.cc:5:11: error: 'a' was not declared in this scope
5 | cin>> a;
| ^
a.cc:8:15: error: 'a1' was not declared in this scope
8 | cin>> a1[i];
| ^~
a.cc:10:5: error: 'f' was not declared in this scope
10 | f = 0;
| ^
a.cc:11:5: error: 'b1' was not declared in this scope
11 | b1 = false;
| ^~
a.cc:12:5: error: 'm' was not declared in this scope; did you mean 'tm'?
12 | m = 0;
| ^
| tm
a.cc:15:13: error: 'a1' was not declared in this scope
15 | if (a1[f] == 2){
| ^~
a.cc:20:13: error: 'a1' was not declared in this scope
20 | f = a1[f] -1;
| ^~
|
s837227137 | p03680 | C++ | cin>> a;
int a1[a];
for (int i = 0; i< a; i++){
cin>> a1[i];
}
f = 0;
b1 = false;
m = 0;
for (int i = 0; i< a; i++){
if (a1[f] == 2){
m++;
b1 = true;
break;
}
f = a1[f] -1;
m++;
}
if (b1 == true){
cout << m;
}
else if (b1 == false){
cout << "-1";
} | a.cc:1:5: error: 'cin' does not name a type
1 | cin>> a;
| ^~~
a.cc:2:12: error: 'a' was not declared in this scope
2 | int a1[a];
| ^
a.cc:3:5: error: expected unqualified-id before 'for'
3 | for (int i = 0; i< a; i++){
| ^~~
a.cc:3:21: error: 'i' does not name a type
3 | for (int i = 0; i< a; i++){
| ^
a.cc:3:27: error: 'i' does not name a type
3 | for (int i = 0; i< a; i++){
| ^
a.cc:6:5: error: 'f' does not name a type
6 | f = 0;
| ^
a.cc:7:5: error: 'b1' does not name a type
7 | b1 = false;
| ^~
a.cc:8:5: error: 'm' does not name a type
8 | m = 0;
| ^
a.cc:9:5: error: expected unqualified-id before 'for'
9 | for (int i = 0; i< a; i++){
| ^~~
a.cc:9:21: error: 'i' does not name a type
9 | for (int i = 0; i< a; i++){
| ^
a.cc:9:27: error: 'i' does not name a type
9 | for (int i = 0; i< a; i++){
| ^
a.cc:19:5: error: expected unqualified-id before 'if'
19 | if (b1 == true){
| ^~
a.cc:22:5: error: expected unqualified-id before 'else'
22 | else if (b1 == false){
| ^~~~
|
s224008323 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,pos;
cin >> n;
vector<int> data(n);
for(int i = 0;i < n;i++){
cin >> data.at(i);
}
for(int count = 0;count < n;count++){
if(count == 0){
pos = data.at(0)-1;
}
else{
pos = data.at(pos)-1;
}
if(pos == 1){
cout << count << endl;
return 0;
}
else if(couont == n-1){
cout << -1 << endl;
return 0;
}
count++;
}
}
| a.cc: In function 'int main()':
a.cc:22:13: error: 'couont' was not declared in this scope; did you mean 'count'?
22 | else if(couont == n-1){
| ^~~~~~
| count
|
s779184444 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
int n;
cin>>n;
vector<int>a(n);
rep(i,n)cin>>a[i];
int cnt=0;int i=0;
for(j=0;j<n;j++){
if(a[i]!=2){
i=a[i]-1;
cnt++;
}
else if(a[i]==2) {
cout<<cnt<<endl;
return 0;
}
else {
if(a[0]==2){
cout<<0<<endl;
return 0;
}
}
}
cout<<-1<<endl;
} | a.cc: In function 'int main()':
a.cc:19:7: error: 'j' was not declared in this scope
19 | for(j=0;j<n;j++){
| ^
|
s017218373 | p03680 | C++ | #pragma GCC optimize "-O3"
#pragma GCC target ("CMOV")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順
using namespace std;
const int mod=1e9+7;
int ans=0;
signed main(){
SPEED;
int n;
cin >> n;
vector<pair<int,bool>> a(n*2);
rep(i,n)
{
cin >> a[i].fi;
a[i].se = false;
}
int ans = 0;
int now = 0;
while(a[1].se == false)
{
if(a[now].fi == true)
{
cout << -1 << endl;
return 0;
}
a[now].se = true;
++ans;
now = a[now].fi - 1;
}
cout << ans << endl;
return 0;
}
| cc1plus: error: attribute 'target' argument 'CMOV' is unknown
cc1plus: error: attribute 'target' argument 'CMOV' is unknown
|
s964738714 | p03680 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n = 0;
cin >> n;
vector<int> in(n);
vector<bool> check(n, false);
for (int i=0; i<n; i++) {
cin >> in.at(i);
in.at(i)--;
}
int count = 0;
int now = 0;
check.at(0) = true;
while (true) {
now = a.at(now);
count++;
if (now == 1) {
cout << count << endl;
return 0;
}
else if (check.at(now)) {
cout << -1 << endl;
return 0;
}
check.at(now) = true;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:19:15: error: 'a' was not declared in this scope
19 | now = a.at(now);
| ^
|
s560146101 | p03680 | C++ | #include <iostream>
#include <vector>
int main() {
int n = 0;
cin >> n;
vector<int> in(n);
vector<bool> check(n, false);
for (int i=0; i<n; i++) {
cin >> in.at(i);
in.at(i)--;
}
int count = 0;
int now = 0;
check.at(0) = true;
while (true) {
now = a.at(now);
count++;
if (now == 1) {
cout << count << endl;
return 0;
}
else if (check.at(now)) {
cout << -1 << endl;
return 0;
}
check.at(now) = true;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
6 | cin >> n;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:7:3: error: 'vector' was not declared in this scope
7 | vector<int> in(n);
| ^~~~~~
a.cc:7:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/vector:93:13: note: 'std::pmr::vector'
93 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
7 | vector<int> in(n);
| ^~~
a.cc:8:10: error: expected primary-expression before 'bool'
8 | vector<bool> check(n, false);
| ^~~~
a.cc:10:12: error: 'in' was not declared in this scope; did you mean 'i'?
10 | cin >> in.at(i);
| ^~
| i
a.cc:15:3: error: 'check' was not declared in this scope
15 | check.at(0) = true;
| ^~~~~
a.cc:17:15: error: 'a' was not declared in this scope
17 | now = a.at(now);
| ^
a.cc:20:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
20 | cout << count << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:20:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
20 | cout << count << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
a.cc:24:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
24 | cout << -1 << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:24:21: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
24 | cout << -1 << endl;
| ^~~~
| std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s221592491 | p03680 | C++ | #include <iostream>
#include<vector>
using namespace std;
int main(void)
{
// Your code here!
int a;
cin >> a;
vector<int> data(a);
for (int i = 0; i < a; i++)
{
int suuzi;
cin >> suuzi;
data[i] = suuzi - 1;
}
int box = data[0];
int cnt = 1;
while (cnt <= a)
{
box = data[box];
cnt++;
if (box == 1)
{
cout << cnt << endl;
break;
}
if (cnt > a)
{
cout << -1 << endl;
break;
}
} | a.cc: In function 'int main()':
a.cc:33:10: error: expected '}' at end of input
33 | }
| ^
a.cc:5:1: note: to match this '{'
5 | {
| ^
|
s959096335 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
vector<int> a(N);
vector<int> flag(N+1);
int count=1;
int i;
for(i=0; i<N; i++){
cin >> a.at(i);
}
int current=1;
flag.at(1)=1;
while(1){
current=a.at(current);
count++;
flag.at(current)++;
if(flag.at(current)==2){
cout << -1 << endl;
break;
}
if(current==2){
cout << count << endl;
break;
}
} | a.cc: In function 'int main()':
a.cc:28:4: error: expected '}' at end of input
28 | }
| ^
a.cc:4:1: note: to match this '{'
4 | {
| ^
|
s451833578 | p03680 | C++ | #include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define NMAX 100010
using namespace std;
int used[NMAX] = {};
bool tmp = false;
int cnt =0;
void dfs(vector<int> a,int loc){
used[loc] = true;
cnt++;
if(loc == 2){
tmp = true;
return;
}else if(!used[a[loc]]){
dfs(a,a[loc]);
}else{
return;
}
}
int main(){
int N;
cin >> N;
vector<int> a(N+1);
rep(i,0,N){
cin >> a[i+1];
}
dfs(a,1);
if(!tmp){
cout << "-1" << endl;
return 0;
}
cout << cnt-1 << endl;
}
| a.cc:12:6: error: variable or field 'dfs' declared void
12 | void dfs(vector<int> a,int loc){
| ^~~
a.cc:12:10: error: 'vector' was not declared in this scope
12 | void dfs(vector<int> a,int loc){
| ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
2 | #include <utility>
+++ |+#include <vector>
3 | #define ll long long int
a.cc:12:17: error: expected primary-expression before 'int'
12 | void dfs(vector<int> a,int loc){
| ^~~
a.cc:12:24: error: expected primary-expression before 'int'
12 | void dfs(vector<int> a,int loc){
| ^~~
a.cc: In function 'int main()':
a.cc:27:9: error: 'cin' was not declared in this scope
27 | cin >> N;
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include <utility>
+++ |+#include <iostream>
3 | #define ll long long int
a.cc:28:9: error: 'vector' was not declared in this scope
28 | vector<int> a(N+1);
| ^~~~~~
a.cc:28:9: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:28:16: error: expected primary-expression before 'int'
28 | vector<int> a(N+1);
| ^~~
a.cc:30:24: error: 'a' was not declared in this scope
30 | cin >> a[i+1];
| ^
a.cc:32:13: error: 'a' was not declared in this scope
32 | dfs(a,1);
| ^
a.cc:32:9: error: 'dfs' was not declared in this scope
32 | dfs(a,1);
| ^~~
a.cc:36:17: error: 'cout' was not declared in this scope
36 | cout << "-1" << endl;
| ^~~~
a.cc:36:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:9: error: 'cout' was not declared in this scope
39 | cout << cnt-1 << endl;
| ^~~~
a.cc:39:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s981073691 | p03680 | C++ | #include <iostream>
#include <vector>
using namespace std;
//https://atcoder.jp/contests/abc065/tasks/abc065_b
int main(){
int N;
cin >> N;
vector<int> a(N);
for(int i=0;i<N;i++){
cin >> a.at(i);
}
int light = 1; //最初は1のライトが光ってる
int count = 0;
for(int i=0;i<N;i++){
if(light == 2) break; //2が光ったら終了
light = a.at(light-1) ;
count++;
}
if(light !=2) count = -1;
cout << count << endl;
return 0;
} | a.cc:22:30: error: extended character is not valid in an identifier
22 | if(light == 2) break; //2が光ったら終了
| ^
a.cc: In function 'int main()':
a.cc:22:30: error: '\U00003000' was not declared in this scope
22 | if(light == 2) break; //2が光ったら終了
| ^~
|
s141432216 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,x=1,b=0;cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
for(int j=0;j<n;j++){
x=a.at(x-1);
if(x==2){
b=i+1;
break;
}
}
if(b>0)cout<<b<<endl;
else cout<<-1<<endl;
} | a.cc: In function 'int main()':
a.cc:10:9: error: 'i' was not declared in this scope
10 | b=i+1;
| ^
|
s286124203 | p03680 | C++ | #include <iostream>
using namespace std;
int main(){
int N; cin >> N;
int count_lst[N]={0}; count_lst[0] = 1;
int a_lst[N];
for(int i=0; i<N; i++) cin >> a[i];
int num=1;
int count=0;
for(int i=0; i<N; i++){
num = a_lst[num-1];
count++;
if(count_lst[num-1] == 1){
count = -1;
break;
}else if(num=2) break;
count_lst[num-1] = 1;
}
cout << count << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:10:33: error: 'a' was not declared in this scope
10 | for(int i=0; i<N; i++) cin >> a[i];
| ^
|
s688951358 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
}
int now = 0, c = 0;
for (;;) {
if (now == 2) {
cout << c << endl;
break;
}
if (c >= N) {
cout << -1 << endl;
break;
}
c++;
now = a.at(now - 1);
} | a.cc: In function 'int main()':
a.cc:26:2: error: expected '}' at end of input
26 | }
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s230444744 | p03680 | C++ | #include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
vector<int>v;
for(int i=0;i<n;i++){
int tmp;
scanf("%d",&tmp);
tmp−−;
v.push_back(tmp);
}
int now = 0,c=0;
for ( ; ; ){
if(now == 1){
printf("%d\n",c);
break;
}
if( c >= n ){
printf("−1\n");
break;
}
c++;
now = v[now];
}
} | a.cc:13:17: error: extended character − is not valid in an identifier
13 | tmp−−;
| ^
a.cc:13:17: error: extended character − is not valid in an identifier
a.cc: In function 'int main()':
a.cc:13:17: error: 'tmp\U00002212\U00002212' was not declared in this scope
13 | tmp−−;
| ^~~~~
|
s264359428 | p03680 | C++ | #include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
vector<int>v;
for(int i=0;i<n;i++){
int tmp;
scanf("%d",&tmp);
tmp−−;
v.push_back(tmp);
}
int now = 0,c=0;
for ( ; ; ){
if(now == 1){
printf(”%d\n”,c);
break;
}
if( c >= n ){
printf(”−1\n”);
break;
}
c++;
now = v[now];
}
} | a.cc:13:17: error: extended character − is not valid in an identifier
13 | tmp−−;
| ^
a.cc:13:17: error: extended character − is not valid in an identifier
a.cc:19:24: error: extended character ” is not valid in an identifier
19 | printf(”%d\n”,c);
| ^
a.cc:19:27: error: stray '\' in program
19 | printf(”%d\n”,c);
| ^
a.cc:19:28: error: extended character ” is not valid in an identifier
19 | printf(”%d\n”,c);
| ^
a.cc:23:32: error: extended character ” is not valid in an identifier
23 | printf(”−1\n”);
| ^
a.cc:23:32: error: extended character − is not valid in an identifier
a.cc:23:35: error: stray '\' in program
23 | printf(”−1\n”);
| ^
a.cc:23:36: error: extended character ” is not valid in an identifier
23 | printf(”−1\n”);
| ^
a.cc: In function 'int main()':
a.cc:13:17: error: 'tmp\U00002212\U00002212' was not declared in this scope
13 | tmp−−;
| ^~~~~
a.cc:19:24: error: '\U0000201d' was not declared in this scope
19 | printf(”%d\n”,c);
| ^
a.cc:19:26: error: 'd' was not declared in this scope
19 | printf(”%d\n”,c);
| ^
a.cc:23:32: error: '\U0000201d\U000022121' was not declared in this scope
23 | printf(”−1\n”);
| ^~~
|
s230425884 | p03680 | C++ | #include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n;
scanf(”%d”,&n);
vector<int>v;
for(int i=0;i<n;i++){
int tmp;
scanf(”%d”,&tmp);
tmp−−;
v.push_back(tmp);
}
int now = 0,c=0;
for ( ; ; ){
if(now == 1){
printf(”%d\n”,c);
break;
}
if( c >= n ){
printf(”−1\n”);
break;
}
c++;
now = v[now];
}
}
| a.cc:8:15: error: extended character ” is not valid in an identifier
8 | scanf(”%d”,&n);
| ^
a.cc:8:17: error: extended character ” is not valid in an identifier
8 | scanf(”%d”,&n);
| ^
a.cc:12:23: error: extended character ” is not valid in an identifier
12 | scanf(”%d”,&tmp);
| ^
a.cc:12:25: error: extended character ” is not valid in an identifier
12 | scanf(”%d”,&tmp);
| ^
a.cc:13:17: error: extended character − is not valid in an identifier
13 | tmp−−;
| ^
a.cc:13:17: error: extended character − is not valid in an identifier
a.cc:19:24: error: extended character ” is not valid in an identifier
19 | printf(”%d\n”,c);
| ^
a.cc:19:27: error: stray '\' in program
19 | printf(”%d\n”,c);
| ^
a.cc:19:28: error: extended character ” is not valid in an identifier
19 | printf(”%d\n”,c);
| ^
a.cc:23:32: error: extended character ” is not valid in an identifier
23 | printf(”−1\n”);
| ^
a.cc:23:32: error: extended character − is not valid in an identifier
a.cc:23:35: error: stray '\' in program
23 | printf(”−1\n”);
| ^
a.cc:23:36: error: extended character ” is not valid in an identifier
23 | printf(”−1\n”);
| ^
a.cc: In function 'int main()':
a.cc:8:15: error: '\U0000201d' was not declared in this scope
8 | scanf(”%d”,&n);
| ^
a.cc:8:17: error: 'd\U0000201d' was not declared in this scope
8 | scanf(”%d”,&n);
| ^~
a.cc:13:17: error: 'tmp\U00002212\U00002212' was not declared in this scope
13 | tmp−−;
| ^~~~~
a.cc:19:26: error: 'd' was not declared in this scope
19 | printf(”%d\n”,c);
| ^
a.cc:23:32: error: '\U0000201d\U000022121' was not declared in this scope
23 | printf(”−1\n”);
| ^~~
|
s483219217 | p03680 | C++ | #include<iostream>
#include<vector>
int main(){
int a; cin >> a;
int cur = 1;
vector<int> v(a+1);
for(int i = 1; i <= a; ++i) cin >> v[i];
for(int i = 0; i < 100009; ++i){
cur = v[cur];
if(cur == 2){
cout << i+1;
return 0;
}
}
cout << -1;
return 0;
}
| a.cc: In function 'int main()':
a.cc:6:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
6 | int a; cin >> a;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:8:3: error: 'vector' was not declared in this scope
8 | vector<int> v(a+1);
| ^~~~~~
a.cc:8:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/vector:93:13: note: 'std::pmr::vector'
93 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
a.cc:8:10: error: expected primary-expression before 'int'
8 | vector<int> v(a+1);
| ^~~
a.cc:9:38: error: 'v' was not declared in this scope
9 | for(int i = 1; i <= a; ++i) cin >> v[i];
| ^
a.cc:12:11: error: 'v' was not declared in this scope
12 | cur = v[cur];
| ^
a.cc:14:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
14 | cout << i+1;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:20:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
20 | cout << -1;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
|
s699220324 | p03680 | C++ | #include<iostream>
int main(){
int a; cin >> a;
int cur = 1;
vector<int> v(a+1);
for(int i = 1; i <= a; ++i) cin >> v[i];
for(int i = 0; i < 100009; ++i){
cur = v[cur];
if(cur == 2){
cout << i+1;
return 0;
}
}
cout << -1;
return 0;
}
| a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
5 | int a; cin >> a;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:7:3: error: 'vector' was not declared in this scope
7 | vector<int> v(a+1);
| ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
7 | vector<int> v(a+1);
| ^~~
a.cc:8:38: error: 'v' was not declared in this scope
8 | for(int i = 1; i <= a; ++i) cin >> v[i];
| ^
a.cc:11:11: error: 'v' was not declared in this scope
11 | cur = v[cur];
| ^
a.cc:13:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
13 | cout << i+1;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:19:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
19 | cout << -1;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
|
s555598092 | p03680 | C++ | #include<iostream.h>
int main(){
int a; cin >> a;
int cur = 1;
vector<int> v(a+1);
for(int i = 1; i <= a; ++i) cin >> v[i];
for(int i = 0; i < 100009; ++i){
cur = v[cur];
if(cur == 2){
cout << i+1;
return 0;
}
}
cout << -1;
return 0;
}
| a.cc:1:9: fatal error: iostream.h: No such file or directory
1 | #include<iostream.h>
| ^~~~~~~~~~~~
compilation terminated.
|
s369944704 | p03680 | C++ | #include<stdio.h>
int main(){
int a; cin >> a;
int cur = 1;
vector<int> v(a+1);
for(int i = 1; i <= a; ++i) cin >> v[i];
for(int i = 0; i < 100009; ++i){
cur = v[cur];
if(cur == 2){
cout << i+1;
return 0;
}
}
cout << -1;
return 0;
} | a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope
5 | int a; cin >> a;
| ^~~
a.cc:7:3: error: 'vector' was not declared in this scope
7 | vector<int> v(a+1);
| ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
7 | vector<int> v(a+1);
| ^~~
a.cc:8:38: error: 'v' was not declared in this scope
8 | for(int i = 1; i <= a; ++i) cin >> v[i];
| ^
a.cc:11:11: error: 'v' was not declared in this scope
11 | cur = v[cur];
| ^
a.cc:13:7: error: 'cout' was not declared in this scope
13 | cout << i+1;
| ^~~~
a.cc:19:3: error: 'cout' was not declared in this scope
19 | cout << -1;
| ^~~~
|
s069532316 | p03680 | C++ | #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int N;
cin >> N;
int a[N];
for(int i = 0; i < N; i++) {
cin >> a[i];
}
int b[N];
b[0] = a[0];
int ans = 0;
for(int i = 0; i < N; i++) {
if(b[i] == 1) {
ans = -1;
break;
}
else if(b[i] == 2) {
ans = i+1;
break;
}
else {
b[i+1] = a[a[i]];
}
}
if(i == N) {
ans = -1;
}
cout << ans;
cout << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:8: error: 'i' was not declared in this scope
35 | if(i == N) {
| ^
|
s000749790 | p03680 | C++ | using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int N;
cin>>N;
int A[N];
rep(i,N)
cin>>A[i];
bool B[N];
rep(i,N)
B[i]=false;
B[0]=true;
int nex=0;
int cnt=0;
rep(i,N){
tmp=nex;
nex=A[tmp];
cnt++;
if(B[nex]){
cout<<-1<<endl;
return 0;
}
if(nex==2){
cout<<cnt<<endl;
return 0;
}
}
}
| a.cc: In function 'int main()':
a.cc:35:5: error: 'tmp' was not declared in this scope; did you mean 'tm'?
35 | tmp=nex;
| ^~~
| tm
|
s906443288 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
vector<int> btn(n);
int k=1;
for(int i=0;i<n;i++){
cin>>btn[i];
}
for(int j=0;j<n+1;j++){
if(btn[k-1]==2)cout<<j+1<<endl; break;
else k=btn[k-1];
if(j==n)cout<<-1<<endl;
}
} | a.cc: In function 'int main()':
a.cc:12:5: error: 'else' without a previous 'if'
12 | else k=btn[k-1];
| ^~~~
|
s069226375 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int count = 1;
array<int,10000> a = {};
for (int i = 0; i < n; i++) cin >> ai;
array<bool, 10000> check = {};
for (int i = 0; a[i] != 2; i = a[i]-1)
{
if (check[i])
{
count = -1;
break;
}
count++;
check[i] = true;
}
cout << count << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:44: error: 'ai' was not declared in this scope; did you mean 'i'?
11 | for (int i = 0; i < n; i++) cin >> ai;
| ^~
| i
|
s014315715 | p03680 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for(int i - 0;i < N;i++) {
cin >> vec.at(i);
}
bool A = false;
int N = 0;
int answer;
for(int j = 0;j < N;j++) {
N = vec.at(N);
if(N == 1) {
A = true;
answer = j + 1;
break;
}
}
if(A == true) {
cout << answer << endl;
}
else {
cout << "-1" << endl;
}
} | a.cc: In function 'int main()':
a.cc:9:12: error: expected ';' before '-' token
9 | for(int i - 0;i < N;i++) {
| ^~
| ;
a.cc:9:22: error: expected ')' before ';' token
9 | for(int i - 0;i < N;i++) {
| ~ ^
| )
a.cc:9:23: error: 'i' was not declared in this scope
9 | for(int i - 0;i < N;i++) {
| ^
a.cc:13:7: error: redeclaration of 'int N'
13 | int N = 0;
| ^
a.cc:6:7: note: 'int N' previously declared here
6 | int N;
| ^
|
s770457924 | 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 count = 0;
int target = 0;
while(a.at(target) == 2){
target = a.at(target) - 1;
count++;
if(count > N){
count = -1;
break;
}
}
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:9:9: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
9 | cin << a.at(i);
| ~~~ ^~ ~~~~~~~
| | |
| | __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
| std::istream {aka std::basic_istream<char>}
a.cc:9:9: note: candidate: 'operator<<(int, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int})' (built-in)
9 | cin << a.at(i);
| ~~~~^~~~~~~~~~
a.cc:9:9: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1715:5: note: candidate: 'template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const sub_match<_Bi_iter>&)'
1715 | operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1715:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)'
125 | operator<<(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed:
a.cc:9:5: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte'
9 | cin << a.at(i);
| ^~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)'
763 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
/usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4077 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
/usr/include/c++/14/bitset:1687:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const bitset<_Nb>&)'
1687 | operator<<(std::basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bitset:1687:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
In file included from /usr/include/c++/14/bits/ios_base.h:46,
from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)'
339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
| ^~~~~~~~
/usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
In file included from /usr/include/c++/14/memory:80,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56:
/usr/include/c++/14/bits/shared_ptr.h:70:5: note: candidate: 'template<class _Ch, class _Tr, class _Tp, __gnu_cxx::_Lock_policy _Lp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __shared_ptr<_Tp, _Lp>&)'
70 | operator<<(std::basic_ostream<_Ch, _Tr>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/shared_ptr.h:70:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)'
563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
/usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)'
573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
/usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)'
579 | operator<<(basic_ostream<char, _Traits>& __out, char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
9 | cin << a.at(i);
| ^
/usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)'
590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
9 | cin << a.at(i);
| ^
/usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)'
595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
9 | cin << a.at(i);
| ^
/usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)'
654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)'
307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
| ^~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed:
a.cc:9:18: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
9 | cin << a.at(i);
| ^
/usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)'
671 | operator<<(basic_ostream<char, _Traits>& __out, co |
s269312574 | p03680 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(void){
int N;
cin >> N;
vector<int>btn(N,0);
for(int i=0;i<N;i++){
cin >> btn[i];
}
int now_btn = 0;
int ans = 0;
while(1){
now_btn = btn[now_btn] - 1;
ans++;
if(now_btn == 1)
break;
else if(now_btn == 0){
ans = -1;
break;
}
}
cout << ans << endl;
return 0;
| a.cc: In function 'int main()':
a.cc:30:12: error: expected '}' at end of input
30 | return 0;
| ^
a.cc:4:15: note: to match this '{'
4 | int main(void){
| ^
|
s071996204 | p03680 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#ifdef _MSC_VER
int getchar_unlocked() { return getchar(); }
#endif
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
#define qp(f) [](auto i){return f;}
using LL=long long;
using VI=vector<int>;
using VL=vector<LL>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL MOD = 1000000007;
const double pi = acos(-1.0);
const string Snum = "0123456789";
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
template<class T>T Sort(T& a) { sort(a.begin(), a.end()); return a; }
template<class T>T ReSort(T& a) { sort(a.rbegin(), a.rend()); return a; }
template<class T>T Reverse(T& a) { reverse(a.begin(), a.end()); return a; }
template<class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template<class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template<class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template<class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }
template<class T, class U>U Sum(T a, U init = 0) { return accumulate(a.begin(), a.end(), init); }
template<class T>T Age(T a, T b) { return (a + b - 1) / b; }
template<class T>T gcd(T n, T m) { return m == 0 ? n : gcd(m, n % m); }
template<class T>T lcm(T n, T m) { return n / gcd(n, m) * m; }
/* RANGE */
namespace RangeNameSpace {
template<class T>class Range {
const T start_, stop_, step_;
public:
Range(const T& start, const T& stop, const T& step) : start_{ start }, stop_{ stop }, step_{ step } {assert(!(step_ == 0 || (start_ > stop_ && step_ > 0) || (start_ < stop_ && step_ < 0))); }
class iterator {
T value_; const T start_, stop_, step_;
public:
using value_type = T;
iterator(T value, T step, T start, T stop) : value_{ value }, step_{ step }, start_{ start }, stop_{ stop } {}
iterator operator++() { value_ = std::min(std::max(start_, stop_), std::max(std::min(start_, stop_), value_ + step_)); return *this; }
iterator operator--() { value_ = std::min(std::max(start_, stop_), std::max(std::min(start_, stop_), value_ - step_)); return *this; }
T& operator*() { return value_; }
const T* operator->() { return &value_; }
bool operator==(const iterator& rhs) { return value_ == rhs.value_; }bool operator!=(const iterator& rhs) { return value_ != rhs.value_; }
};
T operator[](size_t i) { return start_ + i * step_; }
size_t size() { return (max(stop_, start_) - min(stop_, start_)) / abs(step_); }
iterator begin() const { return iterator(start_, step_, start_, stop_); }
iterator end() const { return iterator(stop_, step_, start_, stop_); }
explicit operator vector<T>() const { vector<T>t; for (T i = start_; i < stop_; i += step_)t.push_back(i); return t; }
};
template <class T, class Func, class FuncType>class Range2 {
using Itr = class T::iterator; Itr begin_, end_; Func f_;
public:
Range2(T v, Func f) : begin_{ v.begin() }, end_{ v.end() }, f_{ f } {}
class iterator {
public:
typedef forward_iterator_tag iterator_category; iterator(Itr itr, Func f) : itr_{ itr }, f_{ f } {}
iterator operator++() { ++itr_; return *this; }
iterator operator--() { --itr_; return *this; }
FuncType operator*() { return f_(*itr_); }
bool operator==(iterator rhs) { return rhs.itr_ == itr_; }bool operator!=(iterator rhs) { return rhs.itr_ != itr_; }
private:Itr itr_; Func f_;
};
size_t size() { return begin_.size(); }
iterator begin() const { return iterator(begin_, f_); }
iterator end() const { return iterator(end_, f_); }
operator vector<FuncType>() const { vector<FuncType>t; for (Itr i = begin_; i != end_; ++i)t.push_back(f_(*i)); return t; }
};
}
template<class T> RangeNameSpace::Range<T> range(const T& stop) { return RangeNameSpace::Range<T>(T{ 0 }, stop, T{ 1 }); }
template<class T> RangeNameSpace::Range<T> range(const T& start, const T& stop) { return RangeNameSpace::Range<T>(start, stop, T{ 1 }); }
template<class T> RangeNameSpace::Range<T> range(const T& start, const T& stop, const T& step) { return RangeNameSpace::Range<T>(start, stop, step); }
template<class _T> ostream& operator << (ostream& ostr, const vector<_T>& v) { if (v.size() == 0) { ostr << ""; return ostr; }ostr << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++)ostr << " " << *itr; return ostr; }
template<class T> ostream& operator << (ostream& ostr, const RangeNameSpace::Range<T>& r) { ostr << vector<T>(r); return ostr; }
template<class T, class Func, class FuncType> ostream& operator << (ostream& ostr, const RangeNameSpace::Range2<T, Func, FuncType>& r) { ostr << vector<FuncType>(r); return ostr; }
template<class T, class Func> auto operator | (T v, Func f) { RangeNameSpace::Range2<T, Func, decltype(f(*v.begin()))>r(v, f); return r; }
/* INPUT */
struct inputter_Str {
vector<string> inputbuffer;
string operator [](int n) {
while (inputbuffer.size() <= n) {
string s; //cin >> s;
char c = getchar_unlocked();
while (c != '\0' && c != '\n' && c != '\t' && c != ' ') {
s.push_back(c);
c = getchar_unlocked();
}inputbuffer.push_back(s);
}
return inputbuffer[n];
}
operator string() {
string s;
char c = getchar_unlocked();
while (c != '\0' && c != '\n' && c != '\t' && c != ' ') {
s.push_back(c);
c = getchar_unlocked();
}inputbuffer.push_back(s);
return s;
}
}in;
struct inputter_Int {
int operator [](int n) {
while (in.inputbuffer.size() <= n) {
string s;
int num = 0;
bool neg = false;
char c = getchar_unlocked();
if (c == '-') {
neg = true;
c = getchar_unlocked();
}
while ('0' <= c && c <= '57') {
num = num * 10 + (c - '0');
c = getchar_unlocked();
s.push_back(c);
}
in.inputbuffer.push_back(s);
}
return stoi(inputbuffer[n]);
//string s; //cin >> s;
//return stoi(in[n]);
}
operator int() { return stoi(string(in)); }
}ini;
struct inputter_Int_Fast {
int get() {
int num = 0;
bool neg = false;
char c = getchar_unlocked();
if (c == '-') {
neg = true;
c = getchar_unlocked();
}
while ('0' <= c && c <= '57') {
num = num * 10 + (c - '0');
c = getchar_unlocked();
}
return neg ? -num : num;
}
operator int() { return get(); }
}inif;
struct inputter_LL {
long long operator [](int n) { return stoll(in[n]); }
operator long long() { return stoll(string(in)); }
}inl;
struct inputter_Double {
double operator [](int n) { return stod(in[n]); }
operator double() { return stold(string(in)); }
}ind;
vector<int> invi(int n, int m) { vector<int> v(m); for (int i = 0; i < m; ++i)v[i] = ini[n + i]; return v; }
vector<long long> invl(int n, int m) { vector<long long> v(m); for (int i = 0; i < m; ++i)v[i] = inl[n + i]; return v; }
vector<string> invs(int n, int m) { vector<string> v(m); for (int i = 0; i < m; ++i)v[i] = in[n + i]; return v; }
int Suminvi(int n, int m) { return Sum(invi(n, m), 0); }long long Suminvl(int n, int m) { return Sum(invl(n, m), 0LL); }
int Maxinvi(int n, int m) { return Max(invi(n, m)); } long long Maxinvl(int n, int m) { return Max(invl(n, m)); }
int Mininvi(int n, int m) { return Min(invi(n, m)); } long long Mininvl(int n, int m) { return Min(invl(n, m)); }
vector<int>invif(int n) {
vector<int> v(n);
for (int i = 0; i < n; ++i) {
int num = 0;
bool neg = false;
char c = getchar_unlocked();
if (c == '-') {
neg = true;
c = getchar_unlocked();
}
while ('0' <= c && c <= '57') {
num = num * 10 + (c - '0');
c = getchar_unlocked();
}
v[i] = neg ? -num : num;
}
return v;
}
ostream& operator << (ostream& ostr, inputter_Str i) { ostr << string(i); return ostr; }
/* OUTPUT */
struct boolswitch { string t, f; boolswitch(string tr, string fa) :t(tr), f(fa) {} }yes("yes", "no"), Yes("Yes", "No"), YES("YES", "NO"), Yay("Yay!", ":(");
struct divizer { string s; divizer(string s_) :s(s_) {} }spc(" "), nosp(""), comma(",");
struct outputter {
bool flag = false; boolswitch bs; divizer di;
outputter(bool f, boolswitch b, divizer d) :flag(f), bs(b), di(d) {}
template<class T>outputter operator ,(T o) {
if (flag)cout << di.s; cout << o;
outputter t(true, bs, di); return t;
}
outputter operator ,(double o) {
if (flag)cout << di.s; printf("%.20f", o);
outputter t(true, bs, di); return t;
}
outputter operator ,(bool o) {
if (flag)cout << di.s; cout << (o ? bs.t : bs.f);
outputter t(true, bs, di); return t;
}
template<class T> outputter operator ,(vector<T> o) {
if (flag)cout << di.s;
for (int i = 0; i < (int)o.size(); ++i)cout << o[i] << (i == (int)o.size() - 1 ? "" : di.s);
outputter t(true, bs, di); return t;
}
template<class T, class U> outputter operator ,(pair<T, U> o) {
if (flag)cout << di.s;
cout << "[" << o.first, ", " << o.second << "]";
outputter t(true, bs, di); return t;
}
outputter operator ,(outputter o) { cout << '\n'; return o; }
outputter operator ,(boolswitch b) { outputter t(flag, b, di); return t; }
outputter operator ,(divizer d) { outputter t(flag, bs, d); return t; }
}out(false, Yes, spc);
/* ANSWER */
struct Answer {
int mini = INT_MAX, maxi = INT_MIN, sumi = 0;
long long minl = LLONG_MAX, maxl = LLONG_MIN, suml = 0LL;
double mind = DBL_MAX, maxd = DBL_MIN, sumd = 0.;
int count = 0;
void operator =(int n) { mini = min(mini, n); maxi = max(maxi, n); sumi += n; count++; }
void operator =(long long n) { minl = min(minl, n); maxl = max(maxl, n); suml += n; count++; }
void operator =(double n) { mind = min(mind, n); maxd = max(maxd, n); sumd += n; count++; }
}ans;
/* SLICE */
struct IntNone {
int val = 0; bool none = true;
IntNone() :val(0), none(true) {};
IntNone(int v) :val(v), none(false) {};
operator int() { return val; }
}None;
struct Slicer {
IntNone from_, to_, step_;
Slicer(IntNone from, IntNone to, IntNone step) :from_(from), to_(to), step_(step) {}
};
Slicer sp(int from, int to, int step = 1) { return Slicer(from, to, step); }
Slicer sp(int from, IntNone to, int step = 1) { return Slicer(from, to, step); }
Slicer sp(IntNone from, int to, int step = 1) { return Slicer(from, to, step); }
Slicer sp(IntNone from, IntNone to, int step = 1) { return Slicer(from, to, step); }
template<class T>decltype(auto) operator |(T v, Slicer s) {
typedef typename T::iterator::value_type Ty;
vector<Ty> ret; int size = (int)v.size();
if (s.step_ > 0) {
if (s.from_.none)s.from_ = 0;
if (s.from_ < 0)s.from_ = size + s.from_;
if (s.to_ < 0)s.to_ = size + s.to_;
}
else if (s.step_ < 0) {
if (s.from_.none)s.from_ = size;
if (s.from_ < 0)s.from_ = size + s.from_;
if (s.to_ < 0)s.to_ = size + s.to_;
}
if (s.step_ > 0)
for (int i = max(s.from_.val, 0); (s.to_.none ? true : (i < s.to_)) && i < size && i >= 0; i += s.step_)ret.push_back(v[i]);
else for (int i = min(s.from_.val, size - 1); (s.to_.none ? true : (i > s.to_)) && i >= 0; i += s.step_)ret.push_back(v[i]);
return ret;
}
/* MOD */
long long modpow(long long a, long long n, long long _MOD = MOD) {
long long re = 1;
while (n > 0) {
if (n & 1)re = re * a % _MOD;
a = a * a % _MOD; n >>= 1;
}
return re;
}
long long modinv(long long n, long long _MOD = MOD) {
return modpow(n, _MOD - 2, _MOD);
}
struct Modl {
long long val = 0;
Modl(long long v = 0)noexcept :val(v% MOD) { if (val < 0)v += MOD; }
operator long long() { return val; }
};
Modl operator-(const Modl& a) { Modl r; r.val = a.val ? MOD - a.val : 0; return r; }
Modl operator+(const Modl& a, const Modl& b) { Modl r(a.val + b.val); return r; }
Modl operator-(const Modl& a, const Modl& b) { Modl r(a.val - b.val); return r; }
Modl operator*(const Modl& a, const Modl& b) { Modl r(a.val * b.val); return r; }
Modl operator/(const Modl& a, const Modl& b) { Modl r(a.val * modinv(b.val, MOD)); return r; }
Modl operator+(const Modl& a, const int& b) { Modl r(a.val + LL(b)); return r; }
Modl operator-(const Modl& a, const int& b) { Modl r(a.val - LL(b)); return r; }
Modl operator*(const Modl& a, const int& b) { Modl r(a.val * LL(b)); return r; }
Modl operator/(const Modl& a, const int& b) { Modl r(a.val * modinv(LL(b), MOD)); return r; }
Modl operator+(const Modl& a, const long long& b) { Modl r(a.val + b); return r; }
Modl operator-(const Modl& a, const long long& b) { Modl r(a.val - b); return r; }
Modl operator*(const Modl& a, const long long& b) { Modl r(a.val * b); return r; }
Modl operator/(const Modl& a, const long long& b) { Modl r(a.val * modinv(b, MOD)); return r; }
Modl operator-(const int& a, const Modl& b) { Modl r(LL(a) - b.val); return r; }
Modl operator*(const int& a, const Modl& b) { Modl r(LL(a) * b.val); return r; }
Modl operator/(const int& a, const Modl& b) { Modl r(LL(a) * modinv(b.val, MOD)); return r; }
Modl operator+(const int& a, const Modl& b) { Modl r(LL(a) + b.val); return r; }
Modl operator+(const long long& a, const Modl& b) { Modl r(a + b.val); return r; }
Modl operator-(const long long& a, const Modl& b) { Modl r(a - b.val); return r; }
Modl operator*(const long long& a, const Modl& b) { Modl r(a * b.val); return r; }
Modl operator/(const long long& a, const Modl& b) { Modl r(a * modinv(b.val, MOD)); return r; }
Modl pow(Modl a, int n) { Modl r(modpow(a, n)); return r; }
Modl pow(Modl a, long long n) { Modl r(modpow(a, n)); return r; }
/* age */
struct agel { long long val; agel(long long i) : val(i) {} };
agel operator"" age(unsigned long long i) { return agel(i); }
long long operator/(const long long& a, const agel& b) { return Age(a, b.val); }
struct ATFIRST {
ATFIRST() {}
}ATFIRST_;
int main() {
int n = inif;
VI a = invif(n);
int b = 1;
for (int i = 1; i <= n; i++) {
if (2 == (b = a[b - 1])) {
out, i, out;
return 0;
}
}
out, -1, out;
} | a.cc:126:49: warning: multi-character character constant [-Wmultichar]
126 | while ('0' <= c && c <= '57') {
| ^~~~
a.cc:149:41: warning: multi-character character constant [-Wmultichar]
149 | while ('0' <= c && c <= '57') {
| ^~~~
a.cc:183:41: warning: multi-character character constant [-Wmultichar]
183 | while ('0' <= c && c <= '57') {
| ^~~~
a.cc: In member function 'int inputter_Int::operator[](int)':
a.cc:133:29: error: 'inputbuffer' was not declared in this scope; did you mean 'setbuffer'?
133 | return stoi(inputbuffer[n]);
| ^~~~~~~~~~~
| setbuffer
a.cc: At global scope:
a.cc:314:6: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
314 | agel operator"" age(unsigned long long i) { return agel(i); }
| ^~~~~~~~
|
s610980653 | p03680 | C++ | コンテスト時間: 2017-06-24(土) 21:00 ~ 2017-06-24(土) 22:40 AtCoderホームへ戻る
トップ
問題
質問
提出
提出一覧
順位表
コードテスト
解説
提出 #5552131
ソースコード
Copy
Copy
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using namespace std;
int n;
vector<int> a;
int ans = 0;
void func(int tmp){
if(a[tmp] == 2){
cout<<ans + 1;
return ;
} else if(ans>n){
cout<< -1;
return;
}
else{
ans++;
func(a[tmp]-1 );
}
}
int main(){
cin >>n;
a.resize(n);
for(int i=0; i<n; i++){
cin >> a[i];
}
func(0);
} | a.cc:10:6: error: stray '#' in program
10 | 提出 #5552131
| ^
a.cc:1:1: error: '\U000030b3\U000030f3\U000030c6\U000030b9\U000030c8\U00006642\U00009593' does not name a type
1 | コンテスト時間: 2017-06-24(土) 21:00 ~ 2017-06-24(土) 22:40 AtCoderホームへ戻る
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from a.cc:16:
/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 __sele |
s436334626 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> x(N);
for(int i=1; i<=N; i++) {
cin >> x[i];
}
int b=1, ans=0, v;
while(x[b] != 2){
if(x[b] = 1) {
ans=-1;
break;
}
else{
v=b;
ans++;
b=x[b];
x[v]=1;
}
}
cout << s;
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:11: error: 's' was not declared in this scope
24 | cout << s;
| ^
|
s803986174 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> x(N);
for(int i=1; i<=N; i++) {
cin >> x[i];
}
int b=1, ans=0, v;
while(x[b] != 2){
if(x[b] = 1) {
ans=-1;
break;
}
else{
v=b;
ans++;
b=x[b];
x[v]=1
}
}
cout << s;
return 0;
}
| a.cc: In function 'int main()':
a.cc:21:13: error: expected ';' before '}' token
21 | x[v]=1
| ^
| ;
22 | }
| ~
a.cc:24:11: error: 's' was not declared in this scope
24 | cout << s;
| ^
|
s054319408 | p03680 | C++ | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner((System.in));
int N = sc.nextInt();
int[] a = new int[N+1];
int ans = 0;
for (int i= 1; i <= N; i++){
a[i] = sc.nextInt();
}
int x = 1;
while (ans < N){
x = a[x];
ans++;
if (x == 2) {
System.out.println(ans);
sc.close();
return;
}
}
System.out.println("-1");
sc.close();
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
3 | public class Main {
| ^~~~~~
|
s871511075 | p03680 | C++ | #include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int a[N];
for (int i=0; i < N; ++i) {
cin >> a[i];
}
int ans = 0;
bool flag = false;
int now = 1;
for (int i+0; i < N; ++i) {
now = a[now -1];
++ans;
if (now == 2) {
flag = true;
break;
}
}
if (flag) {
cout << ans << "\n";
}
else {
cout << "-1\n";
}
}
| a.cc: In function 'int main()':
a.cc:14:13: error: expected ';' before '+' token
14 | for (int i+0; i < N; ++i) {
| ^
| ;
a.cc:14:22: error: expected ')' before ';' token
14 | for (int i+0; i < N; ++i) {
| ~ ^
| )
a.cc:14:26: error: 'i' was not declared in this scope
14 | for (int i+0; i < N; ++i) {
| ^
|
s916617088 | p03680 | C++ | #include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int a[N];
for (int i=0; i < N; ++i) {
cin >> a[i];
}
int ans = 0;
bool flag = false;
int now = 1;
for (int i+0; i < N; ++i) {
now = a[now -1];
++ans;
if (now == 2) {
flag = true;
break;
}
}
if (flag) {
cout >> ans >> "\n";
}
else {
cout "-1\n";
}
}
| a.cc: In function 'int main()':
a.cc:14:13: error: expected ';' before '+' token
14 | for (int i+0; i < N; ++i) {
| ^
| ;
a.cc:14:22: error: expected ')' before ';' token
14 | for (int i+0; i < N; ++i) {
| ~ ^
| )
a.cc:14:26: error: 'i' was not declared in this scope
14 | for (int i+0; i < N; ++i) {
| ^
a.cc:23:10: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'int')
23 | cout >> ans >> "\n";
| ~~~~ ^~ ~~~
| | |
| | int
| std::ostream {aka std::basic_ostream<char>}
a.cc:23:10: note: candidate: 'operator>>(int, int)' (built-in)
23 | cout >> ans >> "\n";
| ~~~~~^~~~~~
a.cc:23:10: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/c++/14/string:55,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:23:13: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
23 | cout >> ans >> "\n";
| ^~~
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:23:5: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
23 | cout >> ans >> "\n";
| ^~~~
In file included from /usr/include/c++/14/istream:1109,
from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:23:13: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
23 | cout >> ans >> "\n";
| ^~~
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:23:13: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
23 | cout >> ans >> "\n";
| ^~~
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:23:13: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
23 | cout >> ans >> "\n";
| ^~~
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed:
a.cc:23:13: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
23 | cout >> ans >> "\n";
| ^~~
/usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)'
939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed:
a.cc:23:13: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
23 | cout >> ans >> "\n";
| ^~~
/usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)'
945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed:
a.cc:23:13: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
23 | cout >> ans >> "\n";
| ^~~
/usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
/usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = int&]':
a.cc:23:13: required from here
23 | cout >> ans >> "\n";
| ^~~
/usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
a.cc:26:9: error: expected ';' before string constant
26 | cout "-1\n";
| ^~~~~~~
| ;
|
s055048214 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> botton(N);
int i;
for(i=0;i<N;i++){
cin >> botton(i);
}
int hop;
int light;
hop = 0;
light = 0;
for(i=0;i<N;i++){
if(botton.at(light) == 0){
hop = -1;
break;
}
if(botton.at(light) == 1){
hop += 1;
break;
}
light = botton.at(light);
botton.at(light) = 0;
hop += 1;
}
cout << hop << endl;
}
| a.cc: In function 'int main()':
a.cc:11:18: error: no match for call to '(std::vector<int>) (int&)'
11 | cin >> botton(i);
| ~~~~~~^~~
|
s520638062 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
vector<int> botton(N);
int i;
for(i=0;i<N;i++){
cin >> botton(i);
}
int hop;
int light;
hop = 0;
light = 0;
for(i=0;i<N;i++){
if(botton.at(light) == 0){
hop = -1;
break;
}
if(botton.at(light) == 1){
hop += 1;
break;
}
light = botton.at(light);
botton.at(light) = 0;
hop += 1;
}
cout << hop << endl;
}
| a.cc: In function 'int main()':
a.cc:10:18: error: no match for call to '(std::vector<int>) (int&)'
10 | cin >> botton(i);
| ~~~~~~^~~
|
s148181919 | p03680 | C++ | n = int(input())
a = [int(input()) for i in range(n)]
c,s=1,a[0]
while s != 2 and c < n:
c,s = c+1, a[s-1]
print(c if c<n else -1) | a.cc:1:1: error: 'n' does not name a type
1 | n = int(input())
| ^
|
s098973601 | p03680 | C++ | int main() {
int N;
cin >> N;
vector<int> buttom(N);
for (int i = 0; i < N; i++){
cin >> buttom.at(i);
}
int push = 0;
for (int j = 0; j < N; j++){
if (buttom.at(push) == 2){
cout << j + 1 << endl;
break;
}
else{
push = buttom.at(push) - 1;
if (j == N - 1){
cout << -1 << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
4 | cin >> N;
| ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
6 | vector<int> buttom(N);
| ^~~~~~
a.cc:6:12: error: expected primary-expression before 'int'
6 | vector<int> buttom(N);
| ^~~
a.cc:8:16: error: 'buttom' was not declared in this scope
8 | cin >> buttom.at(i);
| ^~~~~~
a.cc:14:13: error: 'buttom' was not declared in this scope
14 | if (buttom.at(push) == 2){
| ^~~~~~
a.cc:15:13: error: 'cout' was not declared in this scope
15 | cout << j + 1 << endl;
| ^~~~
a.cc:15:30: error: 'endl' was not declared in this scope
15 | cout << j + 1 << endl;
| ^~~~
a.cc:21:17: error: 'cout' was not declared in this scope
21 | cout << -1 << endl;
| ^~~~
a.cc:21:31: error: 'endl' was not declared in this scope
21 | cout << -1 << endl;
| ^~~~
a.cc:24:6: error: expected '}' at end of input
24 | }
| ^
a.cc:1:12: note: to match this '{'
1 | int main() {
| ^
|
s314312072 | p03680 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main() {
int N, a;
int flg = 1;
cin >> N;
vector<int> buttonStream(N);
for ( int i = 0 ; i < N ; i++ ) {
buttonStream.at(i) = a - 1;
}
int now = 0, c = 0;
for ( ; ; ){
if ( now == 1) {
cout << c << endl;
break;
}
if (c > = N ) {
cout << -1 << endl;
break;
}
c++;
now = buttonStream.at(now);
}
} | a.cc: In function 'int main()':
a.cc:38:25: error: expected primary-expression before '=' token
38 | if (c > = N ) {
| ^
|
s889065714 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a(N);
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a.at(i);
}
for (int j = 0; j < N - 1 ;j++) {
a.at(0) = a.at(a.at(0));
if (a.at(0) == 2) {
cout << j << endl;
break;
}
}
if (a.at(0) != 2) {
cout << -1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:6:17: error: 'N' was not declared in this scope
6 | vector<int> a(N);
| ^
|
s638806893 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
}
for (int j = 0; j < N - 1 ;j++) {
a.at(0) = a.at(a.at(0));
if (a.at(0) == 2) {
cout << j << endl;
break;
}
}
if (a.at(0) != 2) {
cout << -1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:6:17: error: 'N' was not declared in this scope
6 | vector<int> a(N);
| ^
|
s964439154 | p03680 | C++ | #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main()
{
int n; //鳩の巣原理よりN+1回押すと絶対1つ以上かぶってる
cin >> n;
int ans = 0;
bool used[n] = {0};
int a[n];
int now = 0;
for(int i = 0; i < n; ++i){
int b; cin >> b;
a[i] = b - 1;
}
while(1){
++ans;
if(a[now] == 1){
cout << ans << endl;
break;
}else if(used[a[now]]){
cout << -1 << endl;
break;
}else{
used[a[now]] = 1;
now = a[now];
}
}
} | a.cc:29:11: error: extended character is not valid in an identifier
29 | int n; //鳩の巣原理よりN+1回押すと絶対1つ以上かぶってる
| ^
a.cc: In function 'int main()':
a.cc:29:11: error: '\U00003000' was not declared in this scope
29 | int n; //鳩の巣原理よりN+1回押すと絶対1つ以上かぶってる
| ^~
|
s510417121 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
int n;
cin>>n
vector<int> a(n);
FDS(i,n){
cin>>a[i];
}
int t;
FDS(i,n){
if(a[t]==2){
cout<<i<<endl;
return 0;
}
t=a[t]-1;
}
cout<<-1<<endl;
} | a.cc: In function 'int main()':
a.cc:16:9: error: expected ';' before 'vector'
16 | cin>>n
| ^
| ;
17 | vector<int> a(n);
| ~~~~~~
a.cc:19:10: error: 'a' was not declared in this scope
19 | cin>>a[i];
| ^
a.cc:23:8: error: 'a' was not declared in this scope
23 | if(a[t]==2){
| ^
a.cc:27:7: error: 'a' was not declared in this scope
27 | t=a[t]-1;
| ^
|
s155258420 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> v(n);
for(int i=0; i < n ; i++) {
cin >> v.at(i);
}
int j = 0;
int i = 0;
while(i < n) {
if(v.at(j) != 2){
j = v.at(j)
}
i++
if(v.at(j) == 2){
cout << i << endl;
}
}
cout << "-1" << endl;
}
| a.cc: In function 'int main()':
a.cc:18:18: error: expected ';' before '}' token
18 | j = v.at(j)
| ^
| ;
19 | }
| ~
a.cc:20:8: error: expected ';' before 'if'
20 | i++
| ^
| ;
21 | if(v.at(j) == 2){
| ~~
|
s853716339 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector v(n);
for(int i=0; i < n ; i++) {
cin >> v.at(i);
}
int j = 0;
while(i < n) {
if(v.at(j) != 2){
j = v.at(j)
}
i++
if(v.at(j) == 2){
cout << i << endl;
}
}
cout << "-1" << endl;
} | a.cc: In function 'int main()':
a.cc:7:13: error: class template argument deduction failed:
7 | vector v(n);
| ^
a.cc:7:13: error: no matching function for call to 'vector(int&)'
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _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, 1 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: template argument deduction/substitution failed:
a.cc:7:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
7 | vector v(n);
| ^
/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, 1 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, 1 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, 1 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, 1 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: template argument deduction/substitution failed:
a.cc:7:13: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int'
7 | vector v(n);
| ^
/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: template argument deduction/substitution failed:
a.cc:7:13: note: mismatched types 'const std::vector<_Tp, _Alloc>' and 'int'
7 | vector v(n);
| ^
/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, 1 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: template argument deduction/substitution failed:
a.cc:7:13: note: couldn't deduce template parameter '_Tp'
7 | vector v(n);
| ^
/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: template argument deduction/substitution failed:
a.cc:7:13: note: couldn't deduce template parameter '_Tp'
7 | vector v(n);
| ^
/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: candidate expects 0 arguments, 1 provided
/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: template argument deduction/substitution failed:
a.cc:7:13: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int'
7 | vector v(n);
| ^
/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, 1 provided
a.cc:14:9: error: 'i' was not declared in this scope
14 | while(i < n) {
| ^
|
s440065184 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> vec(n + 1);
vec.at(0) = 0;
for (int i = 1; i < n + 1; i++) cin >> vec.at(i);
int b = 1;
for (int i = 1; i < n + 1; i++) {
b = vec.at(b)
if (b == 2) {
cout << i << endl;
break;
}
}
if (i == n) cout << -1 << endl;
} | a.cc: In function 'int main()':
a.cc:14:22: error: expected ';' before 'if'
14 | b = vec.at(b)
| ^
| ;
15 | if (b == 2) {
| ~~
a.cc:21:9: error: 'i' was not declared in this scope
21 | if (i == n) cout << -1 << endl;
| ^
|
s493887181 | 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 s = 0, b = 0, c;
while(s != 2){
if(a.at(s)== -1){
b = -1;
break;
}
c = s
s = a.at(s);
a.at(c) = -1;
b++;
}
cout << b << endl;
} | a.cc: In function 'int main()':
a.cc:18:10: error: expected ';' before 's'
18 | c = s
| ^
| ;
19 | s = a.at(s);
| ~
|
s287457810 | 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);
}
int s = 0, b = 0;
while(s != 2){
if(a.at == -1){
b = -1;
break;
}
s = a.at(s);
a.at(s) = -1;
b++;
}
cout << b << endl;
} | a.cc: In function 'int main()':
a.cc:10:12: error: no match for call to '(std::vector<int>) (int&)'
10 | cin >> a(i);
| ~^~~
a.cc:14:14: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator=='
14 | if(a.at == -1){
| ~~~~ ^~ ~~
| | |
| | int
| <unresolved overloaded function type>
|
s106315515 | p03680 | C++ | #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 s = 1, cnt = 1, tmp;
while(s==2) {
if(A[s]==-1) {cout << -1 << "\n"; return 0;}
tmp = s-1;
s = A[s-1];
A[tmp] = -1;
cnt++;
}
cout << cnt << "\n";
}
| a.cc: In function 'int main()':
a.cc:7:3: error: expected initializer before 'for'
7 | for (int i = 0; i<N; i++) cin >> A[i];
| ^~~
a.cc:7:19: error: 'i' was not declared in this scope
7 | for (int i = 0; i<N; i++) cin >> A[i];
| ^
a.cc:10:8: error: 'A' was not declared in this scope
10 | if(A[s]==-1) {cout << -1 << "\n"; return 0;}
| ^
a.cc:12:9: error: 'A' was not declared in this scope
12 | s = A[s-1];
| ^
|
s034993398 | p03680 | Java | import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
int cnt = 0;
int s = 0;
for(int i=0; i<n; i++){
a[i] = sc.nextInt();
}
for(int i=0; i<a.length(); i++){
s = a[s];
cnt++;
if(s == 2){
System.out.println(cnt);
return;
}
}
System.out.println("-1");
}
} | Main.java:13: error: cannot find symbol
for(int i=0; i<a.length(); i++){
^
symbol: method length()
location: variable a of type int[]
1 error
|
s654752722 | p03680 | Java | import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new Int[n];
int cnt = 0;
int s = 0;
for(int i=0; i<n; i++){
a[i] = sc.nextInt();
}
for(int i=0; i<a.lenth(); i++){
s = a[s];
cnt++;
if(s == 2){
System.out.println(cnt);
return;
}
}
System.out.println("-1");
}
} | Main.java:6: error: cannot find symbol
int[] a = new Int[n];
^
symbol: class Int
location: class Main
Main.java:13: error: cannot find symbol
for(int i=0; i<a.lenth(); i++){
^
symbol: method lenth()
location: variable a of type int[]
2 errors
|
s185091977 | p03680 | C++ |
#include <bits/stdc++.h>
using namespace std;
int main(){
int i, N;
int k;
int x;
cin >> N;
vector<int> vec(N);
for (int i=0;i<N;i++){
cin >> vec.at(i);
}
// 入力はすべてここで終わり。
k = vec.at(0) ;
if (k == 2){
cout <<"1" <<endl;
}//〇
else if (k == 1){
cout << "-1" <<endl;
}//〇
else {
for (int i= 2; i =< N ; i++){
vec.at(0) = 0;
x = vec.at(k-1); //xは次に光るボタン
vec.at(k-1) == 0;//kのボタンを押して次に進んだので、k-1番目の配列要素を0に更新
if (x == 2 ){//終わるパタン
cout << i <<endl;
break; // 〇
}
else if (x == 0){//抜け出せないパタン
cout << "-1" <<endl;
break; //〇
}
else if (x==k){//同じ光っちゃった
cout << "-1" <<endl;
break;
//〇
}
k = x;
}
}
}
//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
//ただし2のスイッチは配列的には1番目
//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
//これは押した後に光った番号。すなわち押し他番号をnとして
//vec.at n がn+1の時にループが起こるってこt
///これもしかして""で囲まなきゃダメ解けない?いいえ。
///1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。/これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。/n=xでxの値を代入しなおすことが出来たはず。
| a.cc: In function 'int main()':
a.cc:23:35: error: expected primary-expression before '<' token
23 | for (int i= 2; i =< N ; i++){
| ^
|
s936123615 | p03680 | C++ |
#include <bits/stdc++.h>
using namespace std;
int main(){
int i, N;
int k;
int x;
cin >> N;
vector<int> vec(N);
for (int i=0;i<N;i++){
cin >> vec.at(i);
}
// 入力はすべてここで終わり。
k = vec.at(0) ;
if (k == 2){
cout <<"1" <<endl;
}//〇
else if (k == 1){
cout << "-1" <<endl;
}//〇
vec.at(0) = 0;
else {
for (int i= 2; i < N ; i++){
x = vec.at(k-1); //xは次に光るボタン
vec.at(k-1) == 0;//kのボタンを押して次に進んだので、k-1番目の配列要素を0に更新
if (x == 2 ){//終わるパタン
cout << i <<endl;
break; // 〇
}
else if (x == 0){//抜け出せないパタン
cout << "-1" <<endl;
break; //〇
}
else if (x==k){//同じ光っちゃった
cout << "-1" <<endl;
break;
//〇
}
k = x;
}
}
}
//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
//ただし2のスイッチは配列的には1番目
//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
//これは押した後に光った番号。すなわち押し他番号をnとして
//vec.at n がn+1の時にループが起こるってこt
///これもしかして""で囲まなきゃダメ解けない?いいえ。
///1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。/これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。/n=xでxの値を代入しなおすことが出来たはず。
| a.cc: In function 'int main()':
a.cc:23:9: error: 'else' without a previous 'if'
23 | else {
| ^~~~
|
s322437699 | p03680 | C++ |
#include <bits/stdc++.h>
using namespace std;
int main(){
int i, N;
int k;
cin >> N;
vector<int> vec(N);
for (int i=0;i<N;i++){
cin >> vec.at(i);
}
//forは一回ここで終わった
int k;
k = vec.at(0) ;
if (k == 2){
cout <<"1" <<endl;
}
else if (k == 1){
cout << "-1" <<endl;
}
else {
vec.at(0) = 0;
for (int i= 2; i < N+2 ; i++){
x = vec.at(k-1); //xは次に光るボタン
if (x == 2 ){
cout << i <<endl;
break;
}
else if (x == 0){
cout << "-1" <<endl;
break;
}
else if (x==k){
cout << "-1" <<endl;
break;
}
else {
vec.at(x) == 0;
k = x;
}
}
}
}
//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
//ただし2のスイッチは配列的には1番目
//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
//これは押した後に光った番号。すなわち押し他番号をnとして
//vec.at n がn+1の時にループが起こるってこt
///これもしかして""で囲まなきゃダメ解けない?いいえ。
///1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。/これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。/n=xでxの値を代入しなおすことが出来たはず。
| a.cc: In function 'int main()':
a.cc:13:13: error: redeclaration of 'int k'
13 | int k;
| ^
a.cc:6:13: note: 'int k' previously declared here
6 | int k;
| ^
a.cc:25:25: error: 'x' was not declared in this scope
25 | x = vec.at(k-1); //xは次に光るボタン
| ^
|
s317780032 | p03680 | C++ |
#include <bits/stdc++.h>
using namespace std;
int main(){
int i, N;
cin >> N;
vector<int> vec(N);
for (int i=0;i<N;i++){
cin >> vec.at(i);
}
//forは一回ここで終わった
int k;
k = vec.at(0) ;//1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。
if (k == 2){
cout <<"1" <<endl;
}
else if (k == 1){
cout << "-1" <<endl;
}
else {
vec.at(0) = 0;//これもしかして""で囲まなきゃダメ解けない?いいえ。
//これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。
for (int i= 2; i < N+2 ; i++){
//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
//ただし2のスイッチは配列的には1番目
//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
//これは押した後に光った番号。すなわち押し他番号をnとして
//vec.at n がn+1の時にループが起こるってこt
int x;
x = vec.at(k-1);
if (x == 2 ){
cout << i <<endl;
break;//これはおk
}
else if (x == 0){
cout << "-1" <<endl;
break;//これもおk
}
else if (x==k){
cout << "-1" <<endl;
break;
}
else {
vec.at(x) == 0;
k = x;
}
} //n=xでxの値を代入しなおすことが出来たはず。
}
| a.cc: In function 'int main()':
a.cc:49:24: error: expected '}' at end of input
49 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s998605604 | p03680 | C++ |
#include <bits/stdc++.h>
using namespace std;
int main(){
int i, N;
cin >> N;
vector<int> vec(N);
for (int i=0;i<N;i++){
cin >> vec.at(i);
}
int k;
k = vec.at(0) ;//1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。
if (k == "2"){
cout <<"1" <<endl;
else if (k == "1"){
cout << "-1" <<endl;
}
else {
vec.at(0) = 0;//これもしかして""で囲まなきゃダメ解かないよね
//これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。
for (int i= 2; i < N+2 ; i++){
//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
//ただし2のスイッチは配列的には1番目
//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
//これは押した後に光った番号。すなわち押し他番号をnとして
//vec.at n がn+1の時にループが起こるってこt
int x;
x = vec.at(n-1);
if (x == "2" ){
cout << i <<endl;
break;//これはおk
}
else if (x == "0"){
cout << "-1" <<endl;
break;//これもおk
}
else if (x==n){
cout << "-1" <<endl;
break;
}
else {
vec.at(x) == "0";
n = x;
}
} //n=xでxの値を代入しなおすことが出来たはず。
}
}
| a.cc: In function 'int main()':
a.cc:14:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
14 | if (k == "2"){
| ~~^~~~~~
a.cc:17:9: error: expected '}' before 'else'
17 | else if (k == "1"){
| ^~~~
a.cc:14:22: note: to match this '{'
14 | if (k == "2"){
| ^
a.cc:17:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
17 | else if (k == "1"){
| ~~^~~~~~
a.cc:30:20: error: 'n' was not declared in this scope
30 | x = vec.at(n-1);
| ^
a.cc:32:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
32 | if (x == "2" ){
| ~~^~~~~~
a.cc:36:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
36 | else if (x == "0"){
| ~~^~~~~~
a.cc:45:27: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
45 | vec.at(x) == "0";
| ~~~~~~~~~~^~~~~~
|
s761898423 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
class Graph
{
public:
struct Edge
{
long long to;
long long distance;
Edge(long long t, long long d)
{
to = t;
distance = d;
}
bool operator<(const Edge &e) const
{
return distance < e.distance;
}
bool operator<=(const Edge &e) const
{
return distance <= e.distance;
}
bool operator>(const Edge &e) const
{
return distance > e.distance;
}
bool operator>=(const Edge &e) const
{
return distance >= e.distance;
}
bool operator==(const Edge &e) const
{
return distance == e.distance;
}
};
vector<vector<long long>> adjacency_matrix;
long long node;
long long initial_value;
vector<list<Edge>> edge;
Graph(long long N)
{
setNode(N);
initializeEdgeList();
}
Graph(long long N, long long init)
{
setNode(N);
initializeEdgeList();
setInitialValue(init);
}
void setNode(long long N)
{
node = N + 1;
}
void setInitialValue(long long init)
{
initial_value = init;
}
void initializeAdjacencyMatrix()
{
adjacency_matrix = vector<vector<long long>>(
node, vector<long long>(node, initial_value));
}
void initializeAdjacencyMatrix(long long init)
{
setInitialValue(init);
initializeAdjacencyMatrix();
}
void initializeEdgeList()
{
edge = vector<list<Edge>>(node);
}
void updateAdjacencyMatrix(long long from, long long to, long long distance)
{
adjacency_matrix[from][to] = distance;
}
void addEdge(long long from, long long to, long long distance)
{
edge[from].push_back({to, distance});
}
// O(V^3)
// CAUTION: Use adjacency matrix
void runFloydWarshall()
{
for (int i = 0; i < node; i++)
{
for (int j = 0; j < node; j++)
{
for (int k = 0; k < node; k++)
{
adjacency_matrix[j][k] = min(
adjacency_matrix[j][k],
adjacency_matrix[j][i] + adjacency_matrix[i][k]);
}
}
}
}
// O(VE)
// CAUTION: Use edge list
vector<long long> runBellmanFord(long long from)
{
vector<long long> distance(node, initial_value);
distance[from] = 0;
for (long long i = 0; i < node - 1; i++)
{
for (long long j = 1; j < node; j++)
{
for (auto itr = edge[j].begin(); itr != edge[j].end(); itr++)
{
if (distance[itr->to] > distance[j] + itr->distance)
{
distance[itr->to] = distance[j] + itr->distance;
}
}
}
}
for (long long i = 1; i < node; i++)
{
for (auto itr = edge[i].begin(); itr != edge[i].end(); itr++)
{
if (distance[itr->to] > distance[i] + itr->distance)
{
distance[0]--;
}
}
}
return distance;
}
// O(E + VlogV)
// CAUTION: Use edge list
vector<long long> runDijkstra(long long from)
{
vector<long long> distance(node, initial_value);
priority_queue<Edge, vector<Edge>, greater<Edge>> queue;
queue.push(Edge(from, 0));
while (!queue.empty())
{
long long d = queue.top().distance;
long long to = queue.top().to;
queue.pop();
if (distance[to] == initial_value)
{
distance[to] = d;
for (auto itr = edge[to].begin(); itr != edge[to].end(); itr++)
{
if (distance[itr->to] == initial_value)
{
queue.push({itr->to, itr->distance + d});
}
}
}
}
return distance;
}
// O(ElogV)
// CAUTION: Use adjacency matrix
long long runPrim()
{
vector<bool> is_visited(node, false);
long long cost = 0;
priority_queue<Edge> queue;
queue.push(Edge(1, 0));
while (!queue.empty())
{
long long distance = queue.top().distance;
long long to = queue.top().to;
queue.pop();
if (!is_visited[to])
{
cost += distance;
is_visited[to] = true;
for (auto itr = edge[to].begin(); itr != edge[to].end(); itr++)
{
queue.push({itr->to, itr->distance});
}
}
}
return cost;
}
long long runKruskal()
{
}
};
int main()
{
int N;
cin >> N;
Graph g(N, -1);
int a;
for (int i = 1; i <= N; i++)
{
cin >> a;
g.addEdge(i, a, 1);
}
vector<int> distance = g.runDijkstra(1);
cout << distance[2] << endl;
}
| a.cc: In member function 'long long int Graph::runKruskal()':
a.cc:199:5: warning: no return statement in function returning non-void [-Wreturn-type]
199 | }
| ^
a.cc: In function 'int main()':
a.cc:214:41: error: conversion from 'vector<long long int>' to non-scalar type 'vector<int>' requested
214 | vector<int> distance = g.runDijkstra(1);
| ~~~~~~~~~~~~~^~~
|
s017632662 | p03680 | Java | class Main{
public static void main(String arg[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[]a = new int[N+1];
for(int i = 1; i <= N; i++) {
a[i] = sc.nextInt();
}
sc.close();
boolean[] b = new boolean[N+1];
int i = 1;
b[1] = true;
int count = 0;
while(true) {
if(b[i] == false) {
count++;
b[i] = true;
if(a[i] == 2) {
break;
}
i = a[i];
}else {
count = -1;
break;
}
}
System.out.println(count);
}
} | Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s905259387 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N,;
vector<int> v(N);
for(int i=0; i<N; i++) {
cin >> v[i];
v[i]--;
}
for(int i=0, next=v[0]; i<N; i++) {
if(v[0]==1) {
cout << i+1 << endl;
return 0;
}
next=v[next];
}
cout << -1 << endl;
}
| a.cc: In function 'int main()':
a.cc:5:9: error: expected unqualified-id before ';' token
5 | int N,;
| ^
|
s712848749 | p03680 | C++ | #include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;
int main(void)
{
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;
}
if (c >= n)
{
cout << "-1" << endl;
break;
}
c++;
now = v[now];
}
return 0;
} | a.cc: In function 'int main()':
a.cc:11:9: error: 'cin' was not declared in this scope
11 | cin >> n;
| ^~~
a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
5 | #include<iomanip>
+++ |+#include <iostream>
6 | using namespace std;
a.cc:25:25: error: 'cout' was not declared in this scope
25 | cout << c << endl;
| ^~~~
a.cc:25:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:25: error: 'cout' was not declared in this scope
30 | cout << "-1" << endl;
| ^~~~
a.cc:30:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s890590942 | p03680 | C++ | #include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;
int main(void)
{
int n;
cin >> n;
vector<int>v;
for (int i = 0; i < n; i++)
{
int z;
cin >> n;
z--;
v.push_back(z);
}
int now = 0; c = 0;
for (;;)
{
if (now == 1)
{
cout << c << endl;
break;
}
if (c >= n)
{
cout << "-1" << endl;
break;
}
c++;
now = v[now];
}
return 0;
} | a.cc: In function 'int main()':
a.cc:21:22: error: 'c' was not declared in this scope
21 | int now = 0; c = 0;
| ^
|
s290472866 | p03680 | C++ | 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;
}
if (c >= n) {
cout << -1 << endl;
break;
}
c++;
now = v.at(now);
}
} | a.cc:9:5: error: extended character − is not valid in an identifier
9 | z−−;
| ^
a.cc:9:5: error: extended character − is not valid in an identifier
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
4 | cin >> N;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | using namespace std;
a.cc:5:3: error: 'vector' was not declared in this scope
5 | vector<int> v;
| ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
+++ |+#include <vector>
1 | using namespace std;
a.cc:5:10: error: expected primary-expression before 'int'
5 | vector<int> v;
| ^~~
a.cc:6:23: error: 'n' was not declared in this scope
6 | for (int i = 0; i < n; i++) {
| ^
a.cc:9:5: error: 'z\U00002212\U00002212' was not declared in this scope
9 | z−−;
| ^~~
a.cc:10:5: error: 'v' was not declared in this scope
10 | v.push_back(z);
| ^
a.cc:15:7: error: 'cout' was not declared in this scope
15 | cout << c << endl;
| ^~~~
a.cc:15:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:20: error: 'endl' was not declared in this scope
15 | cout << c << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | using namespace std;
a.cc:18:14: error: 'n' was not declared in this scope
18 | if (c >= n) {
| ^
a.cc:19:7: error: 'cout' was not declared in this scope
19 | cout << -1 << endl;
| ^~~~
a.cc:19:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:21: error: 'endl' was not declared in this scope
19 | cout << -1 << endl;
| ^~~~
a.cc:19:21: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:23:11: error: 'v' was not declared in this scope
23 | now = v.at(now);
| ^
|
s153525700 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, b;
b = 0;
cin >> N;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
}
for (i = 0; i >= 0; i++) {
b = a.at(b);
if (b == 1){
cout << i << endl;
break;
}else if (b == 0){
cout << -1 << endl;
break;
}
}
}
| a.cc: In function 'int main()':
a.cc:13:8: error: 'i' was not declared in this scope
13 | for (i = 0; i >= 0; i++) {
| ^
|
s394399434 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, b;
b = 0;
cin >> N;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
}
for (i = 0; i >= 0; i++) {
b = a.at(b);
if (b == 1){
cout << i << endl;
break;
}else if (b == 0){
cout << -1 << endl;
break;
}
}
}
| a.cc: In function 'int main()':
a.cc:13:8: error: 'i' was not declared in this scope
13 | for (i = 0; i >= 0; i++) {
| ^
|
s381207325 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, b;
b = 0;
cin >> N;
vector<int> a(N);
for (int i = 0; i < N, i++) {
cin >> a.at(i);
}
int i = 1;
while () {
b = a.at(b);
if (b == 1){
cout << i << endl;
break;
}else if (b == 0){
cout << -1 << endl;
break;
}
i++;
}
}
| a.cc: In function 'int main()':
a.cc:10:29: error: expected ';' before ')' token
10 | for (int i = 0; i < N, i++) {
| ^
| ;
a.cc:14:10: error: expected primary-expression before ')' token
14 | while () {
| ^
|
s542531204 | 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 count = 0;
int a = 1;
while (true) {
a = A.at(a);
count++;
if (a == 2) {
break;
}
else if (count > N) {
count = -1;
break;
}
}
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:9:19: error: expected ';' before '}' token
9 | cin >> A.at(i)
| ^
| ;
10 | }
| ~
|
s350861106 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int nazo=-1;
vector<int> button(N);
vector <int> a(N);
for (int i=0; i<N; i++)
{
cin >> a.at(i);
}
for (int i=0; i<N-1; i++)
{
button.at(i+1) = a.at(button.at(i+1)-1);
}
button.at(0) = 1;
for (int i=0; i<N; i++)
{
if (button.at(i) == 2)
{
nazo = i+1;
break
}
}
cout << nazo << endl;
}
| a.cc: In function 'int main()':
a.cc:24:12: error: expected ';' before '}' token
24 | break
| ^
| ;
25 | }
| ~
|
s218509125 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int nazo=-1;
vector<int> button(N);
vector <int> a(N);
for (int i=0; i<N; i++)
{
cin >> a.at(i);
}
for (int i=0; i<N-1; i++)
{
button.at(i+1) = a.at(button(i+1)-1);
}
button.at(0) = 1;
for (int i=0; i<N; i++)
{
if (button.at(i) == 2)
{
nazo = i+1;
break
}
}
cout << nazo << endl;
}
| a.cc: In function 'int main()':
a.cc:16:33: error: no match for call to '(std::vector<int>) (int)'
16 | button.at(i+1) = a.at(button(i+1)-1);
| ~~~~~~^~~~~
a.cc:24:12: error: expected ';' before '}' token
24 | break
| ^
| ;
25 | }
| ~
|
s352184567 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, i, t, c = 0;
cin >> n;
a[n+1];
for(i=1; i<=n; i++){
cin >> a[i];
}
t = 1
while(c < n){
c++;
t = a[t];
if(t == 2){
break;
}
}
if(c == n){
cout << -1;
}else{
cout << c;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:5: error: 'a' was not declared in this scope
7 | a[n+1];
| ^
a.cc:11:10: error: expected ';' before 'while'
11 | t = 1
| ^
| ;
12 | while(c < n){
| ~~~~~
|
s112604095 | p03680 | C++ | #include<iostream>
using namespace std;
int main(){
int N;cin>>N;
int count=0;
int a[100001];
for(int i=1;i<=N;++i){
cin>>a[i];
if(a[i]==i&&a[i]!=2){cout<<"-1"<<endl;return 0;}
int v=a[1];++count;
for(int i=2;i<=N;++i){
v=a[v];++count;
if(v==2){
cout<<count<<endl;
return 0;
}if(a[count]==a[count-2]&&a[count-1]==a[count-3])break;
}
cout<<"-1"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:2: error: expected '}' at end of input
21 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s001565990 | p03680 | C++ | #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int N;
cin >> N;
int a[100002];
bool hist[100002];
int count=0;
for(int i=0;i<N;i++){
cin >> a[i+1];
hist[i+1] = false;
}
int curbtn = 1;
while(!hist[curbtn]){
hist[curbtn]=true;
curbtn = a[curbtn];
count++
if(curbtn==2) cout << count << endl; return 0;
}
cout << -1 << endl;
}
| a.cc: In function 'int main()':
a.cc:26:16: error: expected ';' before 'if'
26 | count++
| ^
| ;
27 | if(curbtn==2) cout << count << endl; return 0;
| ~~
|
s506112592 | 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 ( )
| ^
|
s067374474 | p03680 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
vector<int> a[];
int main()
{
int n;
int res = 0;
cin >> n;
vector<int> a(n+1);
vector<int> na(n + 1);
for (int i = 1;i <= n;i++) {
cin >> a[i];
}
na[0] = 0;
na[1] = 1;
for (int i = 1; i <= n;) {
na[a[i]]++;
if (na[a[i]] >= 2) {
res = -1;
break;
}
i = a[i];
if (i == 2) {
break;
}
}
if (res == -1) {
cout << res << endl;
return 0;
}
for (int i = 1;i < n + 1;i++) {
res += na[i];
}
cout << res-1 << endl;
return 0;
}
| a.cc:18:13: error: array size missing in 'a'
18 | vector<int> a[];
| ^
|
s225483387 | p03680 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
vector<int> a[];
int main()
{
int n;
int res = 0;
cin >> n;
vector<int> a(n+1);
vector<int> na(n + 1);
for (int i = 1;i <= n;i++) {
cin >> a[i];
}
na[0] = 0;
na[1] = 1;
for (int i = 1; i <= n;) {
na[a[i]]++;
if (na[a[i]] >= 2) {
res = -1;
break;
}
i = a[i];
if (i == 2) {
break;
}
}
if (res == -1) {
cout << res << endl;
return 0;
}
for (int i = 1;i < n + 1;i++) {
res += na[i];
}
cout << res-1 << endl;
return 0;
}
| a.cc:18:13: error: array size missing in 'a'
18 | vector<int> a[];
| ^
|
s321408264 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
vector<int> buttons(N);
for (int i=0;i<N;++i){
cin>>buttons.at(i);
}
int on = 0;
for (int i=0;i<=N;++i){
if (on == 1){
cout << i << endl;
return 0;
}
on = buttons.at(on)
}
cout<<-1<<endl;
} | a.cc: In function 'int main()':
a.cc:20:28: error: expected ';' before '}' token
20 | on = buttons.at(on)
| ^
| ;
21 | }
| ~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.