submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s751214215 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int button(int n, vector<int> a(n)){
int ret=0;
int light=a(n).at(0);
a(n).at(0)=0;
ret++;
while(light!=2&&light!=0){
int k;
k=a(n).at(light);
a(n).at(light)=0;
light=k;
ret++;
}
if(light==0) return -1;
if(light==2) return ret;
}
int main(){
int n;
cin>>n;
vector<int> but(n);
if(button(n,but(n))!=-1){
cout<<button(n,but(n))<<endl;
}else{
cout<<-1<<endl;
}
} | a.cc:3:32: error: expected ',' or '...' before '(' token
3 | int button(int n, vector<int> a(n)){
| ^
a.cc: In function 'int button(int, std::vector<int>)':
a.cc:5:16: error: no match for call to '(std::vector<int>) (int&)'
5 | int light=a(n).at(0);
| ~^~~
a.cc:6:6: error: no match for call to '(std::vector<int>) (int&)'
6 | a(n).at(0)=0;
| ~^~~
a.cc:10:12: error: no match for call to '(std::vector<int>) (int&)'
10 | k=a(n).at(light);
| ~^~~
a.cc:11:10: error: no match for call to '(std::vector<int>) (int&)'
11 | a(n).at(light)=0;
| ~^~~
a.cc: In function 'int main()':
a.cc:24:20: error: no match for call to '(std::vector<int>) (int&)'
24 | if(button(n,but(n))!=-1){
| ~~~^~~
a.cc:25:27: error: no match for call to '(std::vector<int>) (int&)'
25 | cout<<button(n,but(n))<<endl;
| ~~~^~~
a.cc: In function 'int button(int, std::vector<int>)':
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
|
s756966732 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
vector<int> vec(N);
for(i=0;i<N;i++){
cin>>vec.at(i);
}
int a=1;
for(i=1;i<N;i++){
a=vec.at(a-1);
if(a==2){
cout<<i<<endl;
return 0;
}
cout<<-1<<endl;
}
} | a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
8 | for(i=0;i<N;i++){
| ^
a.cc:12:7: error: 'i' was not declared in this scope
12 | for(i=1;i<N;i++){
| ^
|
s783030843 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n = INF;
cin >> n;
int ans = -1;
vector<int> v(n);
for(int i = 0;i<n;++i) {
int temp;
cin >> temp;
v.push_back(temp);
}
int curr = v[0];
for(int i =0;i<n+1;++i) {
if(v[curr-1] == 2) {
ans = i + 1;
break;
}
curr = nums[curr-1];
}
cout << ans << '\n';
} | a.cc: In function 'int main()':
a.cc:22:24: error: 'nums' was not declared in this scope
22 | curr = nums[curr-1];
| ^~~~
|
s483520741 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;
const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
int n, m, t, a[mxN];
vi v;
void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
int main() {
fast();
cin >> n;
map<int, int> mp;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
mp[i + 1] = x;
}
int t = mp[i], ans = 0, i = 0;
set<int> s;
bool ok = true;
while (t != 2) {
if (s.find(t) != s.end()) {
ok = false;
break;
} else {
s.insert(t);
t = mp[t];
}
++ans;
}
if (ok)
cout << ans + 1;
else
cout << -1;
return 0;
}
| a.cc:20:29: warning: overflow in conversion from 'double' to 'int' changes value from '1.000000001e+18' to '2147483647' [-Woverflow]
20 | const int inf = 1e18 + iinf + 10;
| ~~~~~~~~~~~~^~~~
a.cc: In function 'int main()':
a.cc:46:14: error: 'i' was not declared in this scope
46 | int t = mp[i], ans = 0, i = 0;
| ^
a.cc:57:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
57 | ++ans;
| ^~~
| abs
a.cc:60:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
60 | cout << ans + 1;
| ^~~
| abs
|
s978213370 | p03680 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main()
{
int N,cnt = 0;
cin>>N;
vector<int> a(N);
for(int ni=0;ni<N;ni++)
{
cin>>a.at(ni);
cnt++;
if(2 == a.at.(ni))
break;
}
cout<<cnt<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:15: error: invalid use of member function 'std::vector<int>::at' (did you forget the '()' ?)
15 | if(2 == a.at.(ni))
| ~~^~
|
s502883802 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n ;
scanf(”%d ”, &n);
vector<int>v;
for(int i = 0 ; i < n ; i++)
{
int z;
scanf(”%d ”, &z );
z−−;
v.push back(z);
}
int now = 0 , c = 0 ;
for(;;)
{
if ( now == 1 )
{
printf(”%d\n ”, c );
break ;
}
if ( c >= n )
{
printf(”−1\n ”);
break ;
}
c++;
now = v[ now ];
}
}
| a.cc:7:7: error: extended character ” is not valid in an identifier
7 | scanf(”%d ”, &n);
| ^
a.cc:7:11: error: extended character ” is not valid in an identifier
7 | scanf(”%d ”, &n);
| ^
a.cc:12:7: error: extended character ” is not valid in an identifier
12 | scanf(”%d ”, &z );
| ^
a.cc:12:11: error: extended character ” is not valid in an identifier
12 | scanf(”%d ”, &z );
| ^
a.cc:13:1: error: extended character − is not valid in an identifier
13 | z−−;
| ^
a.cc:13:1: error: extended character − is not valid in an identifier
a.cc:21:8: error: extended character ” is not valid in an identifier
21 | printf(”%d\n ”, c );
| ^
a.cc:21:11: error: stray '\' in program
21 | printf(”%d\n ”, c );
| ^
a.cc:21:14: error: extended character ” is not valid in an identifier
21 | printf(”%d\n ”, c );
| ^
a.cc:26:8: error: extended character ” is not valid in an identifier
26 | printf(”−1\n ”);
| ^
a.cc:26:8: error: extended character − is not valid in an identifier
a.cc:26:11: error: stray '\' in program
26 | printf(”−1\n ”);
| ^
a.cc:26:14: error: extended character ” is not valid in an identifier
26 | printf(”−1\n ”);
| ^
a.cc: In function 'int main()':
a.cc:7:7: error: '\U0000201d' was not declared in this scope
7 | scanf(”%d ”, &n);
| ^
a.cc:7:9: error: 'd' was not declared in this scope
7 | scanf(”%d ”, &n);
| ^
a.cc:13:1: error: 'z\U00002212\U00002212' was not declared in this scope
13 | z−−;
| ^~~
a.cc:14:3: error: 'class std::vector<int>' has no member named 'push'
14 | v.push back(z);
| ^~~~
a.cc:26:8: error: '\U0000201d\U000022121' was not declared in this scope
26 | printf(”−1\n ”);
| ^~~
|
s419024167 | p03680 | C++ | #include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define pq priority_queue
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef string BigNum;
const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);
//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))
/*----IMPORTANT THINGS----*/
pll dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
/*------------------------*/
ll n;
vll g[limit];
bool visit[limit];
ll ans = -1;
void bfs() {
queue <pll> q;
q.push({1, 0});
visit[1] = true;
while(!q.empty()) {
auto t = q.front();
q.pop();
if (t.fi == 2) ans = t.se;
for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
}
}
void solveProblem() {
bfs();
cout << ans << endl;
}
void fastInput() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void readInput() {
cin >> n;
REP(i, 1, n) {
ll v;
cin >> v;
g[i].pb(v);
}
}
int main() {
fastInput();
readInput();
solveProblem();
}
| a.cc: In function 'void bfs()':
a.cc:64:5: error: reference to 'visit' is ambiguous
64 | visit[1] = true;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
a.cc:72:38: error: reference to 'visit' is ambiguous
72 | for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
a.cc:72:74: error: reference to 'visit' is ambiguous
72 | for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
|
s991429068 | p03680 | C++ | a | a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s243401942 | p03680 | C++ | #include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define pq priority_queue
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef string BigNum;
const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);
//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))
/*----IMPORTANT THINGS----*/
pll dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
/*------------------------*/
ll n;
vll g[limit];
bool visit[limit];
ll ans = -1;
void bfs() {
queue <pll> q;
q.push({1, 0});
visit[1] = true;
while(!q.empty()) {
auto t = q.front();
q.pop();
if (t.fi == 2) ans = t.se;
for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
}
}
void solveProblem() {
bfs();
cout << ans << endl;
}
void fastInput() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void readInput() {
cin >> n;
REP(i, 1, n) {
ll v;
cin >> v;
g[i].pb(v);
}
}
int main() {
fastInput();
readInput();
solveProblem();
}
| a.cc: In function 'void bfs()':
a.cc:64:5: error: reference to 'visit' is ambiguous
64 | visit[1] = true;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
a.cc:72:38: error: reference to 'visit' is ambiguous
72 | for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
a.cc:72:74: error: reference to 'visit' is ambiguous
72 | for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
|
s599105102 | p03680 | C++ | #include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define pq priority_queue
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef string BigNum;
const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);
//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))
/*----IMPORTANT THINGS----*/
pll dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
/*------------------------*/
ll n;
vll g[limit];
bool visit[limit];
ll ans = -1;
void bfs() {
queue <pll> q;
q.push({1, 0});
visit[1] = true;
while(!q.empty()) {
auto t = q.front();
q.pop();
if (t.fi == 2) ans = t.se;
for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
}
}
void solveProblem() {
bfs();
cout << ans << endl;
}
void fastInput() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void readInput() {
cin >> n;
REP(i, 1, n) {
ll v;
cin >> v;
g[i].pb(v);
}
}
int main() {
fastInput();
readInput();
solveProblem();
}
| a.cc: In function 'void bfs()':
a.cc:64:5: error: reference to 'visit' is ambiguous
64 | visit[1] = true;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
a.cc:72:38: error: reference to 'visit' is ambiguous
72 | for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
a.cc:72:74: error: reference to 'visit' is ambiguous
72 | for (auto it : g[t.fi]) if (!visit[it]) {q.push({it, t.se + 1}); visit[it] = true;}
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:58:6: note: 'bool visit [200005]'
58 | bool visit[limit];
| ^~~~~
|
s226350485 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
using namespace std;
int main() {
int n; cin >> n;
int cur = 1;
int ans = 0;
vector<int> a(n+1);
vector<bool> l(n+1);
rep(i,n) cin >> a[i+1];a
rep(i,n) l[i+1] = false;
while(1){
if(l[cur]) break;
else{
if(cur == 2) break;
l[cur] = true;
cur = a[cur];
ans ++;
}
}
if(cur == 2) cout << ans;
else cout << -1;
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:29: error: expected ';' before 'for'
15 | rep(i,n) cin >> a[i+1];a
| ^
| ;
a.cc:16:9: error: 'i' was not declared in this scope
16 | rep(i,n) l[i+1] = false;
| ^
a.cc:3:35: note: in definition of macro 'rep'
3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
| ^
|
s013452448 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
using namespace std;
int main() {
int n; cin >> n;
int cur = 1;
int ans = 0;
vector<int> a(n+1);
vector<bool> l(n+1);
rep(i,n) cin >> a[i+1];a
rep(i,n) l[i+1] = false;
while(1){
if(l[cur]) break;
else{
if(cur == 2) break;
l[cur] = true;
cur = a[cur];
ans ++;
}
}
if(cur == 2) cout << ans;
else cout << -1;
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:29: error: expected ';' before 'for'
15 | rep(i,n) cin >> a[i+1];a
| ^
| ;
a.cc:16:9: error: 'i' was not declared in this scope
16 | rep(i,n) l[i+1] = false;
| ^
a.cc:3:35: note: in definition of macro 'rep'
3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
| ^
|
s768316471 | p03680 | C++ | #include <cstdlib>
using namespace std;
int a[100000];
int n;
int cnt = 1;
int botton(int x){
if(cnt > n) {
return -1;
}
if(a[x] == 2) {
return cnt;
} else {
cnt++;
return botton(a[x]);
}
}
int main(){
cin >> n;
for(int i = 1; i < n+1; i++){
cin >> a[i];
}
cout << botton(1) << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:3: error: 'cin' was not declared in this scope
23 | cin >> n;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include <cstdlib>
+++ |+#include <iostream>
2 |
a.cc:27:3: error: 'cout' was not declared in this scope
27 | cout << botton(1) << endl;
| ^~~~
a.cc:27:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:27:24: error: 'endl' was not declared in this scope
27 | cout << botton(1) << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include <cstdlib>
+++ |+#include <ostream>
2 |
|
s877244274 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N,i,k=0;
cin >> N;
vector<int> a(N);
for(i=0;i<N;++i){
cin >> a.at(i);
--a.at(i);
}
i=0;
do{
++k;
i=a.at(i)-;
if(i==1)
break;
}while(--N);
if(N)
cout << k << endl;
else
cout << -1 << endl;
}
| a.cc: In function 'int main()':
a.cc:15:15: error: expected primary-expression before ';' token
15 | i=a.at(i)-;
| ^
|
s529445935 | p03680 | C++ | #include<stdio.h> #include<vector> #include<algorithm>
using namespace std ; int main()
{
int n;
scanf(”%d”, &n); vector<int>v ;
for (int i = 0; i < n; i++) {
int z; scanf(”%d”, &z); z −−;
v. push back(z );
}
int now = 0, c = 0; for (;;)
{
{
} } | a.cc:1:19: warning: extra tokens at end of #include directive
1 | #include<stdio.h> #include<vector> #include<algorithm>
| ^
a.cc:5:7: error: extended character ” is not valid in an identifier
5 | scanf(”%d”, &n); vector<int>v ;
| ^
a.cc:5:9: error: extended character ” is not valid in an identifier
5 | scanf(”%d”, &n); vector<int>v ;
| ^
a.cc:7:14: error: extended character ” is not valid in an identifier
7 | int z; scanf(”%d”, &z); z −−;
| ^
a.cc:7:16: error: extended character ” is not valid in an identifier
7 | int z; scanf(”%d”, &z); z −−;
| ^
a.cc:7:27: error: extended character − is not valid in an identifier
7 | int z; scanf(”%d”, &z); z −−;
| ^
a.cc:7:27: error: extended character − is not valid in an identifier
a.cc: In function 'int main()':
a.cc:5:7: error: '\U0000201d' was not declared in this scope
5 | scanf(”%d”, &n); vector<int>v ;
| ^
a.cc:5:9: error: 'd\U0000201d' was not declared in this scope
5 | scanf(”%d”, &n); vector<int>v ;
| ^~
a.cc:5:18: error: 'vector' was not declared in this scope
5 | scanf(”%d”, &n); vector<int>v ;
| ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
1 | #include<stdio.h> #include<vector> #include<algorithm>
+++ |+#include <vector>
2 | using namespace std ; int main()
a.cc:5:25: error: expected primary-expression before 'int'
5 | scanf(”%d”, &n); vector<int>v ;
| ^~~
a.cc:7:26: error: expected ';' before '\U00002212\U00002212'
7 | int z; scanf(”%d”, &z); z −−;
| ^~~
| ;
a.cc:8:1: error: 'v' was not declared in this scope
8 | v. push back(z );
| ^
a.cc:13:4: error: expected '}' at end of input
13 | } }
| ^
a.cc:3:1: note: to match this '{'
3 | {
| ^
|
s903787889 | p03680 | C++ | #include<stdio .h> #include<vector> #include<algorithm>
using namespace std ; int main()
{
int n;
scanf(”%d”, &n); vector<int>v ;
for (int i = 0; i < n; i++) {
int z; scanf(”%d”, &z); z −−;
v. push back(z );
}
int now = 0, c = 0; for (;;)
{
{
} } | a.cc:1:20: warning: extra tokens at end of #include directive
1 | #include<stdio .h> #include<vector> #include<algorithm>
| ^
a.cc:1:9: fatal error: stdio .h: No such file or directory
1 | #include<stdio .h> #include<vector> #include<algorithm>
| ^~~~~~~~~~
compilation terminated.
|
s999838563 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main()
{
int n;
cin >> n;
int a[n];
int b = 0;
int ans = 0;
rep(i, n){
cin >> a[i];
if(a[i] == 2) b = 1;
}
map<int, int> mp;
if(b == 0){
cout << -1 << endl;
}
else{
int cnt = 0;
int x = 1;
b = 0;
while(cnt < n){
ans++;
if(a[x - 1] == 2){
b = 1;
break;
}
x = a[x - 1];
}
cout << (b ? ans : -1) << endl;
}
}
//cout << ans << endl;
return 0;
}
| a.cc:46:3: error: expected unqualified-id before 'return'
46 | return 0;
| ^~~~~~
a.cc:47:1: error: expected declaration before '}' token
47 | }
| ^
|
s812327283 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main()
{
int n;
cin >> n;
int a[n];
int b = 0;
int ans = 0;
rep(i, n){
cin >> a[i];
if(a[i] == 2) b = 1;
}
map<int, int> mp;
if(b = 0){
cout << -1 << endl;
}
else{
int cnt = 0;
int x = 1;
while(cnt < n){
ans++;
if(a[x - 1] == 2){
break;
}
x = a[x - 1];
}
cout << (b ? ans : -1) << endl;
}
}
//cout << ans << endl;
return 0;
}
| a.cc:44:3: error: expected unqualified-id before 'return'
44 | return 0;
| ^~~~~~
a.cc:45:1: error: expected declaration before '}' token
45 | }
| ^
|
s942717499 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int button = 0;
int array = 0;
int check = 0;
int nextlight = 0;
int count = 0;
cin >> button;
vector<int> light(button);
for (int loopI = 0; loopI < button; loopI++) {
cin >> array;
light.at(i) = array;
}
for (int loopII = 0; loopII < button; loopII++) {
nextlight = light.at(loopII) - 1;
if (light.at(nextlight) == 2) {
check = 1;
break;
}
else{
count++;
}
}
if (check == 0) {
cout << "-1" << endl;
}
else{
cout << count << endl;
}
} | a.cc: In function 'int main()':
a.cc:14:18: error: 'i' was not declared in this scope
14 | light.at(i) = array;
| ^
|
s264584452 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int button = 0;
int array = 0;
int check = 0;
int nextlight = 0;
int count = 0;
cin >> button;
vector<int> light(button);
for (int loopI = 0; loopI < button; loopI++) {
cin >> array;
light.at(i) = array;
}
for (int loopII = 0; loopII < button; loopII++) {
nextlight = light.at(loopII) - 1;
if (light.at(nextlight) == 2) {
check = 1;
break;
}
else{
count++;
}
}
if (check == 0) {
cout << "-1" << endl;
}
else{
cout << count << endl;
}
}
| a.cc: In function 'int main()':
a.cc:14:18: error: 'i' was not declared in this scope
14 | light.at(i) = array;
| ^
|
s243959578 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
int n;
int i = 1;
vector<int> vec(100005);
vector<bool> jud(100005);
cin >> n;
rep(i, n)
cin >> vec.at(i + 1);
do{
if(jud.at(i) == false){
jud.at(i) = true;
i = vec.at(i)
}
else{
i = -1;
break;
}
} while(i != 2);
cout << i << endl;
}
| a.cc: In function 'int main()':
a.cc:19:20: error: expected ';' before '}' token
19 | i = vec.at(i)
| ^
| ;
20 | }
| ~
|
s164491899 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
int n;
int i = 1;
vector<int> vec(100005);
vector<bool> jud(100005);
cin >> n;
rep(i, n)
cin >> vec.at(i + 1);
do{
if(jud.at(i) == false){
jud.at(i) = true;
i = vec.at(i)
}
else{
i = -1;
break;
}
} while(i != 2);
cout << i << emdl;
} | a.cc: In function 'int main()':
a.cc:19:20: error: expected ';' before '}' token
19 | i = vec.at(i)
| ^
| ;
20 | }
| ~
a.cc:28:16: error: 'emdl' was not declared in this scope
28 | cout << i << emdl;
| ^~~~
|
s242512726 | p03680 | C++ |
#include<bits/stdc++.h>
#include <string>
using namespace std;
int X,N;
int A[2000010]{};
bool B[2000010]{};
int main()
{
cin>>N;
for(int i=0;i<N;i++)cin>>A[i];
int count=0;
for(int i=0;count<N;){
i=A[i]-1;
count++;
if(i==){
cout<<count;
return 0;
}
}
cout<<-1;
return 0;
}
| a.cc: In function 'int main()':
a.cc:18:11: error: expected primary-expression before ')' token
18 | if(i==){
| ^
|
s897103979 | p03680 | C++ |
#include<bits/stdc++.h>
#include <string>
using namespace std;
string X,N;
int A[2000010]{};
bool B[2000010]{};
int main()
{
cin>>N;
for(int i=0;i<N;i++)cin>>A[i];
int count=0;
for(int i=0;;){
i=A[i]-1;
count++;
if(i==0){
cout<<count;
return 0;
}
}
cout<<-1;
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:16: error: no match for 'operator<' (operand types are 'int' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
13 | for(int i=0;i<N;i++)cin>>A[i];
| ~^~
| | |
| | std::string {aka std::__cxx11::basic_string<char>}
| 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:2:
/usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1317 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1485 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1660 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::pair<_T1, _T2>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[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:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
a.cc:13:17: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
13 | for(int i=0;i<N;i++)cin>>A[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(co |
s192636567 | p03680 | C++ | テンプレ
#include<bits/stdc++.h>
#include <string>
using namespace std;
string X,N;
int A[2000010]{};
bool B[2000010]{};
int main()
{
cin>>N;
for(int i=0;i<N;i++)cin>>A[i];
int count=0;
for(int i=0;;){
i=A[i]-1;
count++;
if(i==0){
cout<<count;
return 0;
}
}
cout<<-1;
return 0;
}
| a.cc:1:1: error: '\U000030c6\U000030f3\U000030d7\U000030ec' does not name a type
1 | テンプレ
| ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) 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:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| |
s240775229 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
int main(void)
{
ll n; cin>>n;
vector<ll> a(n);
rep(i,n){
ll b; cin>>b;
b--;
a[i]=b;
}
ll cnt=0,tmp=0;
while(true){
if(tmp==2){
cout<<cnt<<endl;
break;
}
if(cnt>=n){
cout<<"-1"<<endl;
break;
}
tmp=a[tmp];
}
return 0;
}
v | a.cc:34:1: error: 'v' does not name a type
34 | v
| ^
|
s275139110 | p03680 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int a[1000010];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int current = a[1];
a[1] = 0;
int ans = 1;
while(i < 100000000) {
if (a[current] == a[2]) {
cout << ans << endl;
return 0;
}
if (a[current] == 0) {
cout << -1 << endl;
return 0;
}
int tmp = current;
current = a[current];
// a[tmp] = 0;
ans++;
}
cout << -1 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:24:9: error: 'i' was not declared in this scope
24 | while(i < 100000000) {
| ^
|
s956143294 | p03680 | C++ | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
bool re = any_of(a.begin(), a.end(), [](int x) {return x == 2;});
if (!re) {
cout << -1 << endl;
} else {
int j = 1, count = 0;
vector<int> che(n, 1);
while (j != 2) {
if (che[j - 1] == 1) {
che[j - 1] = 0;
j = a[j - 1];
count++;
} else {
cout << -1 << endl;
return 0;
}
}
cout << count << endl;
}
} | a.cc: In function 'int main()':
a.cc:8:5: error: 'vector' was not declared in this scope
8 | 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:8:12: error: expected primary-expression before 'int'
8 | vector<int> a(n);
| ^~~
a.cc:9:40: error: 'a' was not declared in this scope
9 | for (int i = 0; i < n; i++) cin >> a[i];
| ^
a.cc:11:22: error: 'a' was not declared in this scope
11 | bool re = any_of(a.begin(), a.end(), [](int x) {return x == 2;});
| ^
a.cc:11:15: error: 'any_of' was not declared in this scope
11 | bool re = any_of(a.begin(), a.end(), [](int x) {return x == 2;});
| ^~~~~~
a.cc:17:16: error: expected primary-expression before 'int'
17 | vector<int> che(n, 1);
| ^~~
a.cc:19:17: error: 'che' was not declared in this scope
19 | if (che[j - 1] == 1) {
| ^~~
|
s978897737 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int i;
int n;
cin >> n;
vector<int> a(n);
for (i = 0; i < n; i++) cin >> a[i];
int count;
i = 1;
while (int i != 2) {
i = a[i];
count++;
if (count == 50) {
cout << -1 <<endl;
return 0;
}
}
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:15:18: error: expected initializer before '!=' token
15 | while (int i != 2) {
| ^~
a.cc:15:17: error: expected ')' before '!=' token
15 | while (int i != 2) {
| ~ ^~~
| )
a.cc:15:18: error: expected primary-expression before '!=' token
15 | while (int i != 2) {
| ^~
|
s863736836 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
int a;
for (int i = 0; i < N; i++) {
cin >> a;
vec.at(i) = a;
}
int counter = 0;
int b;
b = vec.at(0);
for (int i = 0; i < N + 1; i++) {
if (b == 2) {
counter++;
cout << counter << endl;
break;
}
else if (b == 1)
cout << -1 << endl;
break;
else if (b != 2 && b != 1 && i < N) {
counter++;
b = vec.at(b-1);
continue;
}
else if (b != 2 && b != 1 && i == N + 1)
cout << -1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:28:5: error: 'else' without a previous 'if'
28 | else if (b != 2 && b != 1 && i < N) {
| ^~~~
|
s124685796 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
int a;
for (int i = 0; i < N; i++) {
cin >> a;
vec.at(i) = a;
}
int counter = 0;
int b;
b = vec.at(0);
for (int i = 0; i < N + 1; i++) {
if (b == 2) {
counter++;
cout << counter << endl;
break;
}
else if (b == 1)
cout << -1 << endl;
break;
else if (b != 2 && b != 1 && i < N) {
counter++;
b = vec.at(b-1);
continue;
}
else if (b != 2 && b != 1 && i = N + 1)
cout << -1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:28:5: error: 'else' without a previous 'if'
28 | else if (b != 2 && b != 1 && i < N) {
| ^~~~
a.cc:33:31: error: lvalue required as left operand of assignment
33 | else if (b != 2 && b != 1 && i = N + 1)
| ~~~~~~~~~~~~~~~~~^~~~
|
s327206698 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
int a;
for (int i = 0; i < N; i++) {
cin >> a;
vec.at(i) = a;
}
int counter = 0;
int b;
b = vec.at(0);
for (int i = 0; i < N + 1; i++) {
if (b == 2) {
counter++;
cout << counter << endl;
break;
}
else if (b == 1)
cout << -1 << endl;
break;
else if (b != 2 && b != 1 && i < N) {
counter++;
b = vec.at(b-1);
continue;
}
else if (b != 2 && b != 1 && i = N + 1) {
cout << -1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:28:5: error: 'else' without a previous 'if'
28 | else if (b != 2 && b != 1 && i < N) {
| ^~~~
a.cc:33:31: error: lvalue required as left operand of assignment
33 | else if (b != 2 && b != 1 && i = N + 1) {
| ~~~~~~~~~~~~~~~~~^~~~
a.cc:36:2: error: expected '}' at end of input
36 | }
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s556630956 | p03680 | C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct array {
// the type of elements
typedef int TYPE;
TYPE* m_data;
int m_size;
int m_capacity;
array(int n) : m_size(n), m_capacity(n+1) {
m_data = (TYPE*)malloc(m_capacity * sizeof(TYPE));
if(m_data == NULL){
printf("failed to initialize an array.\n");
exit(0);
}
}
~array(){ free(m_data); }
// push_back
void push(TYPE x){
if(m_size == m_capacity){
m_capacity *= 2;
TYPE* new_data = (TYPE*)malloc(m_capacity * sizeof(TYPE));
if(new_data == NULL){
printf("failed to resize an array.\n");
exit(0);
}
memcpy(new_data, m_data, m_size * sizeof(TYPE));
free(m_data);
m_data = new_data;
}
m_data[m_size++] = x;
}
// pop_back
void pop(){
if(m_size * 2 < m_capacity){
m_capacity /= 2;
TYPE* new_data = (TYPE*)malloc(m_capacity * sizeof(TYPE));
if(new_data == NULL){
printf("failed to resize an array.\n");
exit(0);
}
memcpy(new_data, m_data, (m_size-1) * sizeof(TYPE));
free(m_data);
m_data = new_data;
}
m_size--;
}
void set(int i, TYPE x){
if(i < 0 || m_size <= i){
printf("index out of range: %d\n", i);
exit(0);
}
m_data[i] = x;
}
int size() const { return m_size; }
TYPE get(int i) const {
if(i < 0 || m_size <= i){
printf("index out of range: %d\n", i);
exit(0);
}
return m_data[i];
}
} array;
int main(){
int n;
scanf("%d", &n);
array a(n);
for(int i = 0; i < a.size(); i++){
int temp;
scanf("%d", &temp);
a.set(i, temp-1);
}
int j = 0;
int cnt = 0;
while(cnt < a.size()){
j = a.get(j);
cnt++;
if(j == 1) break;
}
printf("%d\n", (j == 1 ? cnt : -1));
return 0;
} | main.c:7:5: error: expected specifier-qualifier-list before 'typedef'
7 | typedef int TYPE;
| ^~~~~~~
main.c: In function 'main':
main.c:77:5: error: parameter names (without types) in function declaration [-Wdeclaration-missing-parameter-type]
77 | array a(n);
| ^~~~~
main.c:78:25: error: request for member 'size' in something not a structure or union
78 | for(int i = 0; i < a.size(); i++){
| ^
main.c:81:10: error: request for member 'set' in something not a structure or union
81 | a.set(i, temp-1);
| ^
main.c:85:18: error: request for member 'size' in something not a structure or union
85 | while(cnt < a.size()){
| ^
main.c:86:14: error: request for member 'get' in something not a structure or union
86 | j = a.get(j);
| ^
|
s013535775 | 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 ( )
| ^
|
s051071483 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> a(N);
for (int i = 0; i < N; i++) cin >> a.at(i);
int ans = 0;
int lamp = 1;
for (int i = 0; i < N; i++) {
lamp = a.at(lamp - 1);
ans++;
if (lamp == 2) break;
else if (lamp == 1) {
ans = -1;
break;
else if (i == N - 1) ans = -1;
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:18:9: error: expected '}' before 'else'
18 | else if (i == N - 1) ans = -1;
| ^~~~
a.cc:15:29: note: to match this '{'
15 | else if (lamp == 1) {
| ^
a.cc: At global scope:
a.cc:21:5: error: 'cout' does not name a type
21 | cout << ans << endl;
| ^~~~
a.cc:22:1: error: expected declaration before '}' token
22 | }
| ^
|
s433338387 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
int a;
for (int i = 0; i < N; i++) {
cin >> a;
vec.at(i) = a;
}
int counter = 0;
int b, B;
b = vec.at(0);
for (int i = 0; i < N + 1; i++) {
if (b == 2) {
counter++;
cout << counter << endl;
break;
}
else if (b == 1) {
break;
}
else if (b != 2 && b != 1) {
counter++;
B = b-1;
b = vec.at(B);
continue;
}
}
if (b != 2)
cout << -1 << endl;
else
}
| a.cc: In function 'int main()':
a.cc:38:1: error: expected primary-expression before '}' token
38 | }
| ^
|
s193299766 | 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++) {
int a;
cin >> a;
vec.at(i) = a;
}
int counter = 0;
int b, B;
b = vec.at(0);
for (int i = 0; i < N; i++) {
if (b == 2) {
counter++;
cout << counter << endl;
break;
}
else if (b == 1) {
cout << -1 << endl;
break;
}
else if (b != 2 && b != 1) {
counter++;
vec.at(b-1) = B
b = vec.at(B);
}
}
}
| a.cc: In function 'int main()':
a.cc:31:22: error: expected ';' before 'b'
31 | vec.at(b-1) = B
| ^
| ;
32 | b = vec.at(B);
| ~
|
s418526865 | 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++) {
int a;
cin >> a;
vec.at(i) = a;
}
int counter;
int b;
b = vec.at(0);
for (int i = 0; i < N; i++) {
if (b == 2) {
counter++;
cout << counter << endl;
break;
}
else if (b != 2) {
counter++;
b = vec.at(i+1)
continue;
}
cout << -1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:27:22: error: expected ';' before 'continue'
27 | b = vec.at(i+1)
| ^
| ;
28 | continue;
| ~~~~~~~~
|
s836695497 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> vec(N);
for (i = 0; i < N; i++) {
int a;
cin >> a;
vec.at(i) = a;
}
int counter;
for (i = 0; i < N; i++) {
int b;
b = vec.at(i);
if (b == 2) {
counter++;
cout << counter << endl;
break;
}
else if (b != 2) {
counter++;
continue;
}
cout << -1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:9:8: error: 'i' was not declared in this scope
9 | for (i = 0; i < N; i++) {
| ^
a.cc:16:8: error: 'i' was not declared in this scope
16 | for (i = 0; i < N; i++) {
| ^
|
s625942350 | 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);
}
for (int i = 0; i < N; i++) {
int next = a.at(i); // 次のボタンの位置
if ((next - 1) == i) {
// 次のボタンの位置にあるaiの値が現在のボタンの位置だった場合
cout << "-1" << endl;
return 0;
}
}
bool is_finished = false;
int curr = 1, count = 0;
for (int i = 0; i < N; i++) {
count++;
int next = a.at(curr - 1);
if (next == 2) {
is_finished = true;
break;
}
curr = next;
}
cout << ((is_finished) ? count : "-1") << endl;
} | a.cc: In function 'int main()':
a.cc:33:28: error: operands to '?:' have different types 'int' and 'const char*'
33 | cout << ((is_finished) ? count : "-1") << endl;
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
|
s927837068 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int ans=0;
cin >> N;
vector<int> vec(N);
for(int i=0;i<N;i++){
cin >> vec.at(i);
}
vector<int> check;
check={};
int k = 1;
for(int i =0;i<N;i++){
ans += 1;
if(vec.at(k-1)==2){
break;
}
k = vec.at(k-1);
if(i == N-1){
ans =-1
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:28:16: error: expected ';' before '}' token
28 | ans =-1
| ^
| ;
29 | }
| ~
|
s343822792 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int ans=0;
cin >> N;
vector<int> vec(N);
for(int i=0;i<N;i++){
cin >> vec.at(i);
}
vector<int> check;
for(int i =0;i<N;i++){
ans += 1
if(vec.at(i)==2){
break;
}
for(int j=0;j<i+1;j++){
if(check.at(j) == vec.at(i)){
ans = -1;
break;
}
}
check.push_back(vec.at(i));
if(ans == -1)
break;
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:16:13: error: expected ';' before 'if'
16 | ans += 1
| ^
| ;
17 | if(vec.at(i)==2){
| ~~
|
s810461291 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int ans=0;
cin >> N;
vector<int> vec(N);
for(int =0;i<N;i++){
cin >> vec.at(i);
}
vector<int> check;
for(int i =0;i<N;i++){
ans += 1
if(vec.at(i)==2){
break;
}
for(int j=0;j<i+1;j++){
if(check.at(j) == vec.at(i)){
ans = -1;
break;
}
}
check.push_back(vec.at(i));
if(ans == -1)
break;
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:10:11: error: expected unqualified-id before '=' token
10 | for(int =0;i<N;i++){
| ^
a.cc:10:10: error: expected ';' before '=' token
10 | for(int =0;i<N;i++){
| ^~
| ;
a.cc:10:11: error: expected primary-expression before '=' token
10 | for(int =0;i<N;i++){
| ^
a.cc:10:14: error: 'i' was not declared in this scope
10 | for(int =0;i<N;i++){
| ^
a.cc:10:17: error: expected ')' before ';' token
10 | for(int =0;i<N;i++){
| ~ ^
| )
a.cc:10:18: error: 'i' was not declared in this scope
10 | for(int =0;i<N;i++){
| ^
a.cc:16:13: error: expected ';' before 'if'
16 | ans += 1
| ^
| ;
17 | if(vec.at(i)==2){
| ~~
|
s084913487 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
vector<int> vec(N+1);
for(int i=1;i<=N;i++){
cin>>vec.at(i);
}
int sta=vec.at(1);
int kai=0;
bool can=false;
if(sta==2) cout<<1<<endl;
else {
for(int i=1;i<=N;i++){
kai+=1;
sta=vec.at(sta);
if(sta==2){
can=true;
break;
}
}
if(can) cout<<kai+1<<endl;
else cout<<-1<<endl;
} | a.cc: In function 'int main()':
a.cc:31:4: error: expected '}' at end of input
31 | }
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s484481047 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
vector<int> vec(N+1);
for(int i=1;i<=N;i++){
cin>>vec.at(i);
}
int sta=vec.at(1);
int kai=1;
bool can=false;
for(int i=1;i<=N;i++){
kai+=1;
sta=vec.at(sta);
if(sta==2){
can=true;
break;
}
}
if(can) cout<<kai<<endl;
else cout<<-1<<endl; | a.cc: In function 'int main()':
a.cc:28:23: error: expected '}' at end of input
28 | else cout<<-1<<endl;
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s705128719 | p03680 | C++ | cat | a.cc:1:1: error: 'cat' does not name a type
1 | cat
| ^~~
|
s976807035 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N,count=0,i=1;
cin>>N;
vector <int> totori(N)
for(int i=0;i<N;i++)cin>>totori[i];
while(count <= N){
i=totori[i-1];
count++;
if(i==2){
cout <<count<<endl;
break;}
}
if(i !=2){cout <<"-1"<<endl;}
}
| a.cc: In function 'int main()':
a.cc:8:5: error: expected ',' or ';' before 'for'
8 | for(int i=0;i<N;i++)cin>>totori[i];
| ^~~
a.cc:8:24: error: expected ';' before ')' token
8 | for(int i=0;i<N;i++)cin>>totori[i];
| ^
| ;
|
s813493513 | p03680 | C++ | #include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i,n){
cin >> a[i];
a[i]--;
}
vector<bool> check(n,false);
check[0] = true;
int i = a[0];
int cnt=1;
if (i==1) cnt =0
bool stop = false;
while(!check[i]){
check[i] = true;
i = a[i];
if(!stop){
cnt++;
}
if(i==1) stop = true;
}
if(!check[1]) cout << -1 << endl;
else cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:20:21: error: expected ';' before 'bool'
20 | if (i==1) cnt =0
| ^
| ;
21 | bool stop = false;
| ~~~~
a.cc:25:13: error: 'stop' was not declared in this scope
25 | if(!stop){
| ^~~~
a.cc:28:18: error: 'stop' was not declared in this scope
28 | if(i==1) stop = true;
| ^~~~
|
s303248055 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> button(N);
for(int n = 0; n < N; n++){
cin >> button.at(n);
}
int light = 1;
int count = 1;
while(button.at(light-1) != 2){
count++;
light = button.at(light-1);
if(count > N){
break;
}
}
if(count > N){
break;
}else{
cout << count << endl;
}
}
| a.cc: In function 'int main()':
a.cc:21:7: error: break statement not within loop or switch
21 | break;
| ^~~~~
|
s425256141 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> button(N);
for(int n = 0; n < N; n++){
cin >> button.at(n);
}
int light = 0;
int count = 1;
while(button.at(light) != 2){
count++;
light = button.at(light);
if(count > N){
break;
}
}
if(count > N){
break;
}else{
cout << count << endl;
}
}
| a.cc: In function 'int main()':
a.cc:21:7: error: break statement not within loop or switch
21 | break;
| ^~~~~
|
s431452329 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> button(N);
for(int n = 0; n < N; n++){
cin >> button.at(n);
}
int light = 0;
int count = 1;
while(button(light) != 2){
count++;
light = button(light);
if(count > N){
break;
}
}
if(count > N){
break;
}else{
cout << count << endl;
}
}
| a.cc: In function 'int main()':
a.cc:13:15: error: no match for call to '(std::vector<int>) (int&)'
13 | while(button(light) != 2){
| ~~~~~~^~~~~~~
a.cc:15:19: error: no match for call to '(std::vector<int>) (int&)'
15 | light = button(light);
| ~~~~~~^~~~~~~
a.cc:21:7: error: break statement not within loop or switch
21 | break;
| ^~~~~
|
s737687740 | p03680 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
int main()
{
int n,flag=0; cin>>n;
vector<int>v;
for(int i=1,x;i<=n;i++){
cin>>x;
--x;
v.push_back(x);
}
int now=0,ans=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:22:11: error: 'c' was not declared in this scope
22 | cout<<c<<endl;
| ^
a.cc:25:7: error: 'c' was not declared in this scope
25 | if(c>= n){
| ^
a.cc:29:4: error: 'c' was not declared in this scope
29 | c++;
| ^
|
s301711757 | p03680 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt(),f=0,i=0;
int[] a=new int[n],b=new int[n];
b[0]=1;
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}
while(f<n){
b[i]=0;
b[a[i]-1]++;
f++;
i=a[i]-1;
if(i==1){
System.out.println(f);
break;
}
}
if(f==n){
System.out.println(-1);
}
}
}
| Main.java:10: error: variable i is already defined in method main(String[])
for(int i=0;i<n;i++){
^
1 error
|
s310841029 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector <int> botton(N);
for(int i; i<N; i++){
cin >> botton.at(i);
}
int count;
int now = botton.at(0);
for(int i; i<N; i++){
count++;
int k = botton.at(now-1)
now = botton.at(k);
if(now == 2){
cout << count << endl;
break;
}
if(count == N){
cout << -1 << endl;
}
}
}
| a.cc: In function 'int main()':
a.cc:16:5: error: expected ',' or ';' before 'now'
16 | now = botton.at(k);
| ^~~
|
s944153398 | p03680 | C++ | x#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
int N, count = 0, i;
vector<int> n(N), find(N);
cin >> N;
for (int i = 0; i < N; i++)
{
int tmp;
cin >> tmp;
n[i] = tmp - 1;
find[i] = -1;
}
i = 0;
int flug = 0;
while (find[i] == -1)
{
find[i] = 1;
if (n[i] == 1)
{
flug++;
break;
}
count++;
i = n[i];
}
if (flug == 1)
{
cout << count << "\n";
}
else
{
cout << -1 << "\n";
}
return 0;
} | a.cc:1:2: error: stray '#' in program
1 | x#include <iostream>
| ^
a.cc:1:1: error: 'x' does not name a type
1 | x#include <iostream>
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | |
s082727859 | p03680 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
int N, count = 0, i;
vector<int> n(N), find(N);
cin >> N;
for (int i = 0; i < N; i++)
{
int tmp;
cin >> tmp;
n[i] = tmp - 1;
find[i] = -1;
}
i = 0;
int flug = 0;
while (find[i] == -1)
{
find[i] = 1;
if (n[i] == 1)
{
flug++;
break;
}
count++;
i = n[i];
}
if (flug == 1)
{
cout << count << "\n";
}
else
{
cout << -1 << "\n";
}
return 0;
}#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
int N, count = 0, i;
vector<int> n(N), find(N);
cin >> N;
for (int i = 0; i < N; i++)
{
int tmp;
cin >> tmp;
n[i] = tmp - 1;
find[i] = -1;
}
i = 0;
int flug = 0;
while (find[i] == -1)
{
find[i] = 1;
if (n[i] == 1)
{
flug++;
break;
}
count++;
i = n[i];
}
if (flug == 1)
{
cout << count << "\n";
}
else
{
cout << -1 << "\n";
}
return 0;
} | a.cc:45:2: error: stray '#' in program
45 | }#include <iostream>
| ^
a.cc:45:3: error: 'include' does not name a type
45 | }#include <iostream>
| ^~~~~~~
a.cc:51:5: error: redefinition of 'int main()'
51 | int main(void)
| ^~~~
a.cc:7:5: note: 'int main()' previously defined here
7 | int main(void)
| ^~~~
|
s750268415 | p03680 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
int num=0;
int bottun=1;
cin>>n;
vector<int>a(n);
for(int i=1;i<=n;i++){
cin>>a[i];
}
while(bottun!=2){
bottun=a[bottun];
num++;
if(num>N) break;
}
if(num<N) cout<<num<<endl;
else cout<<-1<<endl;
}
| a.cc: In function 'int main()':
a.cc:16:12: error: 'N' was not declared in this scope
16 | if(num>N) break;
| ^
a.cc:18:10: error: 'N' was not declared in this scope
18 | if(num<N) cout<<num<<endl;
| ^
|
s942305221 | p03680 | C++ | #include <bits/stdc++.h>
#include <vector>
#include <math.h>
using namespace std;
#define pi 3.14159265358979323846264338327950L
/*#include <bits/stdc++.h>
#include <vector>
#include <stack>
using namespace std;
bool comp(int a, int b){
return (a < b);
}
int main(){
int t;
cin>>t;
while(t--){
int n,k,x; cin>>n>>k;
int a[n],b[n];
for(int i=0;i<n;i++)
cin>>a[i];
for(int j=0;j<n;j++)
cin>>b[j];
sort(a,a+n);
sort(b,b+n,greater<int>());
int* maxi;
maxi = std::max_element(b, b+n, comp);
int sum=0,lin=0;
for(int i=0;i<n;i++)
{
if(lin < k){
if(*maxi > a[i]){
swap(a[i],*maxi);
lin++;
maxi = max_element(b, b + n,comp); }
}
if(lin > k)
break;
}
for(int j=0;j<n;j++){
sum += a[j];}
cout<<sum<<endl;
}
return 0;
}
int main(){
int n = 4,flag = 0;
set<char>ani;
char a[4][4];
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
cin>>a[i][j];
ani.insert(a[i][j]);
}
}
if(ani.size() == 1)
cout<<"YES"<<endl;
else {
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
if(a[i][j] == '.' && a[i][j+1] == '#' && a[i+1][j] == '#' && a[i+1][j+1] == '#'
|| a[i][j] == '#' && a[i][j+1] == '.' && a[i+1][j] == '#' && a[i+1][j+1] == '#'
|| a[i][j] == '#' && a[i][j+1] == '#' &&a[i+1][j] == '.' && a[i+1][j+1] == '#'
|| a[i][j] == '#' && a[i][j+1] == '#' && a[i+1][j] == '#' && a[i+1][j+1] == '.'
|| a[i][j] == '#' && a[i][j+1] == '#' && a[i+1][j] == '#' && a[i+1][j+1] == '#' ){
flag = 1;
break; }
if(a[i][j] == '#' && a[i][j+1] == '.' && a[i+1][j] == '.' && a[i+1][j+1] == '.'
|| a[i][j] == '.' && a[i][j+1] == '#' && a[i+1][j] == '.' && a[i+1][j+1] == '.'
|| a[i][j] == '.' && a[i][j+1] == '.' &&a[i+1][j] == '#' && a[i+1][j+1] == '.'
|| a[i][j] == '.' && a[i][j+1] == '.' && a[i+1][j] == '.' && a[i+1][j+1] == '#'
|| a[i][j] == '.' && a[i][j+1] == '.' && a[i+1][j] == '.' && a[i+1][j+1] == '.'){
flag = 1;
break; }
}
}
if(flag == 0) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
ani.clear();
return 0;
}
#include <bits/stdc++.h>
#include <vector>
#include <math.h>
using namespace std;
#define pi 3.14159265358979323846264338327950L
int main(){
int a,b,h,m;
cin>>a>>b>>h>>m;
//long double rad = 2 * pi * ( ((long double)H/12.0+ ( (long double) M/60.0)/12.0 )- (long double) M/60.0 );
long double rads = pi * 2 * (
(long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);
long double ans = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rads);
cout<<sqrtl(ans)<<endl;
return 0;
}
int main(){
int n,x,a; cin>>n;
vector<int>das;
for(int i=0;i<n;i++){
cin>>x;
das.push_back(x--); }
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;
}
*/
int main(){
int n,x,now=0,c=0;
cin>>n;
vector<int>das;
for(int i=0;i<n;i++){
cin>>x;
v.push_back(--x);
}
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:194:5: error: 'v' was not declared in this scope
194 | v.push_back(--x);
| ^
a.cc:207:11: error: 'v' was not declared in this scope
207 | now = v[now];
| ^
|
s421356195 | p03680 | C++ | #include <bits/stdc++.h>
#include <vector>
#include <math.h>
using namespace std;
int main(){
int n,x; cin>>n;
vector<int>das;
for(int i=0;i<n;i++){
cin>>x;
das.push_back(x--); }
int now=0,c=0;
for(;;){
if(now == 1){
cout<<c<<endl;
break; }
if(c>=a){
cout<<"-1"<<endl;
break; }
c++;
now = v[now];
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:11: error: 'a' was not declared in this scope
26 | if(c>=a){
| ^
a.cc:31:9: error: 'v' was not declared in this scope
31 | now = v[now];
| ^
|
s214303097 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N; //ボタンの数
cin >> N;
vector <int> Botton(N); //次に光るボタンのi(番号)
for (int i=0; i<N; i++){
cin >> Botton.at(i);
}
int Ok = -1; //-1は不可能 正の数はボタンを押した回数
int I = 1; //光っているボタンの番号
for (int i=1; i<=N; i++){
if ( Botton.at(I) == 2){
Ok = i;
break;
}
I = Botton.at(I);
}
cout << i << endl;
}
| a.cc:6:1: error: extended character is not valid in an identifier
6 |
| ^
a.cc: In function 'int main()':
a.cc:6:1: error: '\U00003000' was not declared in this scope
6 |
| ^~
a.cc:22:11: error: 'i' was not declared in this scope
22 | cout << i << endl;
| ^
|
s892011535 | p03680 | C++ | #include<stdio .h>
#include<vector>
#include<algorithm>
using namespace std ;
int main() {
int n; scanf(”%d” , &n);
vector<int>v;
for ( int i = 0; i < n; i++) {
int z ; scanf(”%d” , &z ); z−−;
v. push back (z );
}
int now = 0 , c = 0;
for ( ; ; ) {
if (now == 1) {
printf(”%d\n” , c );
break ;
}
if (c >= n) {
printf (”−1\n”);
break;
}
c++; now = v[now ] ;
}
}
| a.cc:1:9: fatal error: stdio .h: No such file or directory
1 | #include<stdio .h>
| ^~~~~~~~~~
compilation terminated.
|
s920926553 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> a(N+1,-1);
for(int i=1; i<=N; i++){
cin >> a.at(i);
}
int next = 1, count = 1;
while(a.at(next)==2 || a.at(next)==-1){
int temp;
temp = next;
next = a.at(next);
a.at(temp) = -1
count++;
}
if(a.at(next)==-1) cout << -1 << endl;
else cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:18:20: error: expected ';' before 'count'
18 | a.at(temp) = -1
| ^
| ;
19 | count++;
| ~~~~~
|
s670533952 | p03680 | C | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> A(n);
vector<int> C(n);
int count=0;
for(int i=0;i<n;i++){
cin >> A.at(i);
}
int ini=A.at(0);
for(int j=0;j<n+1;j++){
count++;
if(C.at(ini-1)!=1&&ini!=2){
C.at(ini-1)=1;
ini = A.at(ini-1);
}else if(ini == 2){
break;
}else{
count = -1;
break;
}
}
cout << count << endl;
}
| main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s661886813 | 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 kaunto;
int flag;
int tugi;
}
| a.cc: In function 'int main()':
a.cc:6:11: error: expected ';' before 'vector'
6 | cin >> N
| ^
| ;
7 | vector<int> v(N);
| ~~~~~~
a.cc:9:12: error: 'v' was not declared in this scope
9 | cin >> v.at(i);
| ^
|
s023414859 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> btn(N);
for ( int i=0; i < N; i++){
cin >> btn[i];
}
int c=1;
int m,boo;
while 1{
boo = btn[btn[m]];
c++;
m=boo-1;
if ( boo ==2){
break;
}else if ( boo==1){
cout<<'-1'<<endl;
}
}
cout << c << endl;
}
| a.cc:23:13: warning: multi-character character constant [-Wmultichar]
23 | cout<<'-1'<<endl;
| ^~~~
a.cc: In function 'int main()':
a.cc:16:9: error: expected '(' before numeric constant
16 | while 1{
| ^
| (
a.cc:16:10: error: expected ')' before '{' token
16 | while 1{
| ~^
| )
|
s884613688 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
vector<int> vec(N);
int a=0;
for(int i=0;i<N;i++){
cin>>vec.at(i);
}
for(int i=0;i<N;i++){
a=vec.at(a)
if(a==2){
cout<<i+1<<endl;
break;
}
}
} | a.cc: In function 'int main()':
a.cc:13:20: error: expected ';' before 'if'
13 | a=vec.at(a)
| ^
| ;
14 | if(a==2){
| ~~
|
s266953567 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
vector<int> vec(N);
int a=0
for(int i=0;i<N;i++){
cin>>vec.at(i);
}
for(int i=0;i<N;i++){
a=vec.at(a)
if(a==2){
cout<<i+1<<endl;
break;
}
}
} | a.cc: In function 'int main()':
a.cc:9:5: error: expected ',' or ';' before 'for'
9 | for(int i=0;i<N;i++){
| ^~~
a.cc:9:17: error: 'i' was not declared in this scope
9 | for(int i=0;i<N;i++){
| ^
a.cc:13:20: error: expected ';' before 'if'
13 | a=vec.at(a)
| ^
| ;
14 | if(a==2){
| ~~
|
s328295234 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N,str,point,ans = 0,a;
cin >> N;
vector<int> n(N,0);
for(int i = 0; i < N; i++){
cin >> n.at(i);
}
str = 1;
point = 0;
a = 0;
for(int i = 0; i < N; i++){
a = n.at(str);
str = a;
ans += 1;
if(a == 2){
break;
}
if(i == N -1){
cout << "-1" << endl
point = 1;
}
}
if(point == 0){
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:22:29: error: expected ';' before 'point'
22 | cout << "-1" << endl
| ^
| ;
23 | point = 1;
| ~~~~~
|
s222557950 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N,str,point,ans = 0,a;
cin >> N;
vector<int> n(N,0);
for(int i = 0; i < N; i++){
cin >> n.at(i);
}
str = 1;
point = 0;
a = 0;
for(int i = 0; i < N + 1; i++){
a = n.at(str);
str = a;
ans += 1;
if(a == 2){
break;
}
if(i == N){
cout << "-1" << endl
point = 1;
}
}
if(point == 0){
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:22:29: error: expected ';' before 'point'
22 | cout << "-1" << endl
| ^
| ;
23 | point = 1;
| ~~~~~
|
s854284482 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, b;
cin >> N ;
vector<int> a(N);
for(i = 0; i < N; i++){
cin >> a.at(i);
}
b = a.at(0);
i = 1
while(i < N){
if(b = 2)
break;
b = a.at(b);
i++;
if(i = N){
i = -1;
break;
}
}
cout << i << endl;
}
| a.cc: In function 'int main()':
a.cc:15:8: error: expected ';' before 'while'
15 | i = 1
| ^
| ;
16 | while(i < N){
| ~~~~~
|
s063315451 | p03680 | C++ | #include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct edge{
ll to,cost;
};
const ll MAX_V=200100;
const ll Inf=1e18;
vector<vector<edge>>E(MAX_V);
ll d[MAX_V];
void dijkstra(ll s){
priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>que;
fill_n(d,MAX_V,Inf);
d[s] = 0;
que.push(pair<ll,ll>(0,s));
while(!que.empty()){
pair<ll,ll> p = que.top();
que.pop();
ll v = p.second;
if(d[v] < p.first)continue;
for(int j = 0;j < E[v].size();j++){
edge t = E[v][j];
if(d[t.to] > d[v] + t.cost){
d[t.to] = d[v] + t.cost;
que.push(pair<ll,ll>(d[t.to],t.to));
}
}
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;cin>>n;
for(int i=0;i<n;i++){
ll a;cin>>a;
E[i].pb(a-1);
}
dijkstra(0);
if(d[1] == Inf)cout<<-1<<endl;
else cout<<d[1]<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:50:12: error: no matching function for call to 'std::vector<edge>::push_back(long long int)'
50 | E[i].pb(a-1);
| ~~~~~~~^~~~~
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:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; value_type = edge]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from 'long long int' to 'const std::vector<edge>::value_type&' {aka 'const edge&'}
1283 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = edge; _Alloc = std::allocator<edge>; value_type = edge]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from 'long long int' to 'std::vector<edge>::value_type&&' {aka 'edge&&'}
1300 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~~
|
s544915243 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,;
cin >> n;
vector<int> v(n,1);
for (int i=0;i<n;i++) {
cin >> v.at(i);
}
for (int i=0;i<n;i++) {
if(v.at(0)==2) {
cout << i+1 << endl;
break;
}
else if (v.at(0)==1) {
cout << -1 << endl;
break;
}
else
v.at(0) = v.at(v.at(0)-1);
}
} | a.cc: In function 'int main()':
a.cc:5:9: error: expected unqualified-id before ';' token
5 | int n,;
| ^
|
s771493536 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const int MOD = 1e9+7;
int main() {
int N;
cin>> N;
vi a(N);
rep(i,N) cin >> a[i];
int on = 1;
frag = false;
int count;
rep(i,N){
on = a[on];
if(on == 2){
frag =true;
count = i+1;
break;
}
}
if(frag) cout << count << endl;
else cout << 0<< endl;
} | a.cc: In function 'int main()':
a.cc:20:9: error: 'frag' was not declared in this scope
20 | frag = false;
| ^~~~
|
s155333913 | p03680 | C++ | #include<stdio . h>#include<vector>#include<algorithm>using namespace std ;int main ()fint n ;scanf ("%d" , &n ) ;vector<int>v ;f o r ( int i = 0; i<n ; i++)fint z ;scanf ("%d" , &z ) ;z | a.cc:1:20: warning: extra tokens at end of #include directive
1 | #include<stdio . h>#include<vector>#include<algorithm>using namespace std ;int main ()fint n ;scanf ("%d" , &n ) ;vector<int>v ;f o r ( int i = 0; i<n ; i++)fint z ;scanf ("%d" , &z ) ;z
| ^
a.cc:1:9: fatal error: stdio . h: No such file or directory
1 | #include<stdio . h>#include<vector>#include<algorithm>using namespace std ;int main ()fint n ;scanf ("%d" , &n ) ;vector<int>v ;f o r ( int i = 0; i<n ; i++)fint z ;scanf ("%d" , &z ) ;z
| ^~~~~~~~~~~
compilation terminated.
|
s179494006 | p03680 | C++ | int main(){
int n;
cin >> n;
int a[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i];
}
int button = 1;
int count = 0;
while(1){
//button = a[button];
if(button == a[button]){
break;
}
else if(button != a[button]){
button = a[button];
count++;
if(button == 2){
break;
}
if(button == 1){
break;
}
}
}
if(button == 2){
printf("%d\n", count);
}
else{
printf("-1\n");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
3 | cin >> n;
| ^~~
a.cc:31:9: error: 'printf' was not declared in this scope
31 | printf("%d\n", count);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | int main(){
a.cc:34:9: error: 'printf' was not declared in this scope
34 | printf("-1\n");
| ^~~~~~
a.cc:34:9: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
|
s593495993 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
int n;
cin >> n;
int a[100005];
for(int i=0; i<n; i++){
cin >> a[i];
}
int i = 0;
int state[100005] = {0};
state[0] = 1;
while(state[i] != 2){
//cout << "while " << i << " " << state[i] << endl;
++i;
state[i] = a[state[i-1]-1];
//cout << i << " " << a[state[i-1]-1] << " " << state[i] << endl;
if(state[i] == 2) break;
if(state[i] == 1) {
cout << -1 << endl;
return 0;
}
/*
for(int j=0; j<i; j++){
//cout << "for" << endl;
if(state[i] == state[j]) {
cout << -1 << endl;
return 0;
}
}
*/
if(i=>n) {
cout << -1 << endl;
return 0;
}
}
cout << i << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:45:14: error: expected primary-expression before '>' token
45 | if(i=>n) {
| ^
|
s845745435 | p03680 | C++ | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N+1);
A.at(0) = 1;
for (int i=1; i<=N; i++) {
cin >> A.at(i);
}
vector<int> A_num(N+1);
A_num.at(0) = 1;
A_num.at(1) = A.at(1);
int num = 1;
for (int j=2; j<=N; j++) {
A_num.at(j) = A.at(A_num.at(j-1));
num ++;
if (A_num.at(j) == 2) {
cout << num << endl;
break;
}
else if (A.at(j) == A_num.at(j-2)) {
cout << -1 << endl;
break;
}
} | a.cc: In function 'int main()':
a.cc:28:4: error: expected '}' at end of input
28 | }
| ^
a.cc:5:12: note: to match this '{'
5 | int main() {
| ^
|
s443978409 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main() {
int N;
cin >> N;
vector<int> button(N);//0から始まることに注意;;
rep(i,N){
int n;
cin >> n;
button.at(i) = n-1;
}
//button(i)がai+1に対応
vector<int> route(N);
int idou=0,now=0;//now:現在地
route.at(0) = 1;
while(1){
now = button(now);
route.at(now)++;
idou++;
if(now == 1)
break;
else if(route.at(now) == 2){
idou = -1;
break;
}
}
cout << idou << endl;
}
| a.cc: In function 'int main()':
a.cc:19:17: error: no match for call to '(std::vector<int>) (int&)'
19 | now = button(now);
| ~~~~~~^~~~~
|
s890509711 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main() {
int N;
cin >> N;
vector<int> button(N);//0から始まることに注意;;
rep(0,N){
int n;
cin >> n;
button.at(i) = n-1;
}
//button(i)がai+1に対応
vector<int> route(N);
int idou=0,now=0;//now:現在地
route.at(0) = 1;
while(1){
now = button(now);
route.at(now)++;
idou++;
if(now == 1)
break;
else if(route.at(now) == 2){
idou = -1;
break;
}
}
cout << idou << endl;
}
| a.cc: In function 'int main()':
a.cc:9:7: error: expected unqualified-id before numeric constant
9 | rep(0,N){
| ^
a.cc:3:26: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
| ^
a.cc:9:7: error: expected ';' before numeric constant
9 | rep(0,N){
| ^
a.cc:3:26: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
| ^
a.cc:9:7: error: lvalue required as left operand of assignment
9 | rep(0,N){
| ^
a.cc:3:26: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
| ^
a.cc:3:40: error: expected ')' before ';' token
3 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
| ~ ^
a.cc:9:3: note: in expansion of macro 'rep'
9 | rep(0,N){
| ^~~
a.cc:9:7: error: lvalue required as increment operand
9 | rep(0,N){
| ^
a.cc:3:41: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
| ^
a.cc:19:17: error: no match for call to '(std::vector<int>) (int&)'
19 | now = button(now);
| ~~~~~~^~~~~
|
s377314321 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> arr(1000000);
int N;
cin >> N;
int count = 1;
for (int i = 0; i < N; i++) {
cin >> arr.at(i);
}
int a;
int flag = 0;
while (1) {
int x = 1;
x = arr.at(arr.at(x - 1))
count ++;
if (arr.at(x) = 2) {
break;
}
}
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:20:30: error: expected ';' before 'count'
20 | x = arr.at(arr.at(x - 1))
| ^
| ;
21 | count ++;
| ~~~~~
|
s031340121 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> arr(1000000);
int N;
cin >> N;
int count = 1;
for (int i = 0; i < N; i++) {
cin >> arr.at(i);
}
int a;
int flag = 0;
while (1) {
int x = 1
x = arr.at(arr.at(x - 1))
count ++;
if (arr.at(x) = 2) {
break;
}
}
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:20:5: error: expected ',' or ';' before 'x'
20 | x = arr.at(arr.at(x - 1))
| ^
|
s898440417 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> arr(1000000);
int N;
cin >> N;
int count = 1;
for (int i = 0; i < N; i++;) {
cin >> arr.at(i);
}
int a;
int flag = 0;
while (1) {
int x = 1
x = arr.at(arr.at(x - 1))
count ++;
if (arr.at(x) = 2) {
break;
}
}
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:11:29: error: expected ')' before ';' token
11 | for (int i = 0; i < N; i++;) {
| ~ ^
| )
a.cc:11:30: error: expected primary-expression before ')' token
11 | for (int i = 0; i < N; i++;) {
| ^
a.cc:20:5: error: expected ',' or ';' before 'x'
20 | x = arr.at(arr.at(x - 1))
| ^
|
s091768954 | 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);
}
vector<int> flags(N);
int on=0;
int count=0;
while(True){
on = buttons.at(on);
count++;
if(on==2)
cout << count << endl;
if(flags.at(on))
cout << -1 << endl;
else
flags.at(on)=1;
}
}
| a.cc: In function 'int main()':
a.cc:16:9: error: 'True' was not declared in this scope
16 | while(True){
| ^~~~
|
s233346214 | 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);
}
vector<int> flags(N);
int on=0;
int count=0;
while(True){
on = buttons.at(on);
count++;
if(on==2)
cout << count << endl;
if(flags.at(on))
cout << -1 << endl;
else
flags.at(on)=1;
}
} | a.cc: In function 'int main()':
a.cc:9:3: error: expected ',' or ';' before 'for'
9 | for(int i=0;i<N;i++){
| ^~~
a.cc:9:15: error: 'i' was not declared in this scope
9 | for(int i=0;i<N;i++){
| ^
a.cc:16:9: error: 'True' was not declared in this scope
16 | while(True){
| ^~~~
|
s403253767 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int a[N];
for (i = 0; i < N; i++) cin >> a[i];
int button = 1;
int ans = 0;
while (button != 1) {
button = a[button];
ans++;
if (button == 2){
cout << ans << endl;
return 0;
}
cout << -1 << endl;
} | a.cc: In function 'int main()':
a.cc:9:8: error: 'i' was not declared in this scope
9 | for (i = 0; i < N; i++) cin >> a[i];
| ^
a.cc:23:2: error: expected '}' at end of input
23 | }
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s560381958 | p03680 | C++ | n = int(input())
a = [int(input()) for _ in range(n)]
cnt = 0
cur = 1
if a[0] == 2:
print(1)
else:
for i in range(n):
cnt += 1
cur = a[cur - 1]
if cur == 2:
print(cnt)
exit()
print(-1) | a.cc:1:1: error: 'n' does not name a type
1 | n = int(input())
| ^
|
s857237429 | 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 all(x) (x).begin(),(x).end()
int main() {
int n; cin >> n;
vectore<int> a(n);
for (int i = 0; i < n; i ++) {
cin >> a[i];
}
vector<bool> b(n, true);
int on = 0;
int cnt = 0;
while(true) {
if (a[on] == 2) {
cout << cnt << endl;
return 0;
}
if (b[on]) {
b[on] = false;
on = a[on] - 1;
cnt ++;
} else {
cout << -1 << endl;
return 0;
}
}
}
| a.cc: In function 'int main()':
a.cc:9:3: error: 'vectore' was not declared in this scope
9 | vectore<int> a(n);
| ^~~~~~~
a.cc:9:11: error: expected primary-expression before 'int'
9 | vectore<int> a(n);
| ^~~
a.cc:11:12: error: 'a' was not declared in this scope
11 | cin >> a[i];
| ^
a.cc:18:9: error: 'a' was not declared in this scope
18 | if (a[on] == 2) {
| ^
a.cc:24:12: error: 'a' was not declared in this scope
24 | on = a[on] - 1;
| ^
|
s945702826 | 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 button = 1;
int count = 0;
while (button != 2){
button = a.at(button);
count++;
if (count !< N){
cout << -1 << endl;
break;
}
}
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:17:14: error: expected ')' before '!' token
17 | if (count !< N){
| ~ ^~
| )
|
s383558177 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
vector a(N);
for (int i = 0; i < N; i++){
cin >> a.at(i);
}
int button = 1;
int count = 0;
while (button != 2){
button = a.at(button);
count++;
if (count > 2*N){
cout << -1 << endl;
break;
}
}
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:6:13: error: class template argument deduction failed:
6 | vector a(N);
| ^
a.cc:6: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:6:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
6 | vector a(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:6:13: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int'
6 | vector a(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:6:13: note: mismatched types 'const std::vector<_Tp, _Alloc>' and 'int'
6 | vector a(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:6:13: note: couldn't deduce template parameter '_Tp'
6 | vector a(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:6:13: note: couldn't deduce template parameter '_Tp'
6 | vector a(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:6:13: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int'
6 | vector a(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
|
s145641970 | 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;
for (int i=0; i < 2*N; i = vec.at(i)-1) {
else if (vec.at(i)==2) {
cout << count+1 << endl;
break;
}
else if (i==2*N) {
cout << -1 << endl;
break;
}
else {
count++;
}
}
}
| a.cc: In function 'int main()':
a.cc:16:5: error: 'else' without a previous 'if'
16 | else if (vec.at(i)==2) {
| ^~~~
|
s627085862 | 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;
for (int i=0; i < N; i = vec.at(i)-1) {
if (vec.at(i)==1) {
cout << -1 << endl;
break;
}
else if (vec.at(i)==2) {
cout << count+1 << endl;
break;
}
else {
count++;
}
}
| a.cc: In function 'int main()':
a.cc:27:4: error: expected '}' at end of input
27 | }
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s397645423 | 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 button = 1;
int i = 0;
for(int j = 0; j < N; j++){
i++;
button = a.at(button - 1);
if(button == 2)break;
if(button == 1 || j = N - 1){
cout << "-1" << endl;
return 0;
}
}
cout << i << endl;
}
| a.cc: In function 'int main()':
a.cc:16:20: error: lvalue required as left operand of assignment
16 | if(button == 1 || j = N - 1){
| ~~~~~~~~~~~~^~~~
|
s812299122 | 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 button = 1;
int i = 0;
for(int j = 0; j < N; j++){
i++;
button = a.at(button - 1);
if(button == 2)break;
if(button == 1 || i = N - 1){
cout << "-1" << endl;
return 0;
}
}
cout << i << endl;
}
| a.cc: In function 'int main()':
a.cc:16:20: error: lvalue required as left operand of assignment
16 | if(button == 1 || i = N - 1){
| ~~~~~~~~~~~~^~~~
|
s400313463 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int A[100005];
cin>>n;
for(int i=0;i<n;i++){
cin>>A[i];
}
int temp=A[0];
int c=1;
while(100005--){
c++;
if (A[temp-1]==2){
cout<<c;
return 0;
}
temp=A[temp-1];
}
cout<<-1;
return 0;
} | a.cc: In function 'int main()':
a.cc:13:15: error: lvalue required as decrement operand
13 | while(100005--){
| ^~~~~~
|
s376427557 | p03680 | C++ | a | a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s034803314 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N; cin >> N;
vector<int> v;
for (int i=0; i<N; i++) {
int x; cin >> x;
v.push_back(x);
}
int y=0; z=0;
for (int i=0; i<N; i++) {
if (z==1) {
cout << y << endl;
break;
}
if (y>=N) {
cout << "-1" << endl;
break;
}
y++;
z = v.at(z);
}
} | a.cc: In function 'int main()':
a.cc:11:12: error: 'z' was not declared in this scope
11 | int y=0; z=0;
| ^
|
s622855313 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N; cin >> N;
vector<int> v;
for (int i=0; i<N; i++) {
int x; cin >> x;
v.push_back(x);
}
int y=0; z-0;
for (int i=0; i<N; i++) {
if (z==1) {
cout << y << endl;
break;
}
if (y>=N) {
cout << "-1" << endl;
break;
}
y++;
z = v.at(z);
}
} | a.cc: In function 'int main()':
a.cc:11:12: error: 'z' was not declared in this scope
11 | int y=0; z-0;
| ^
|
s272458450 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> vec(n);
vector<int> past(0);
int flag = 0;
int count = 0;
for (int i = 0; i < n; i++) {
cin >> vec[i]-1;
if(vec[i] == 1) flag = 1;
}
if(flag == 1){
int next = vec[0];
count++;
past.push_back(next);
while(next != 1 && flag == 1){
next = vec[next];
count++;
past.push_back(next);
for(int i = 0; i < past.size(); i++){
if(past[i] == next){
flag = 0;
break;
}
}
}
}
if(flag == 0){
cout << -1 << endl;
} else {
cout << count << endl;
}
}
| a.cc: In function 'int main()':
a.cc:13: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'})
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13: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'}
13 | cin >> vec[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:13:18: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'void*' [-fpermissive]
13 | cin >> vec[i]-1;
a.cc:13:18: error: cannot bind rvalue '(void*)((long int)(vec.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:13: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]
13 | cin >> vec[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:13:18: error: i |
s932162070 | p03680 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> vec(n);
vector<int> past(0);
int flag = 0;
int count = 0;
for (int i = 0; i < n; i++) {
cin >> vec[i];
if(vec[i] == 2) flag = 1;
}
if(flag == 1){
int next = vec[0];
count++;
past.push_back(next);
while(next != 2 && flag = 1){
next = vec[next];
count++;
past.push_back(next);
for(int i = 0; i < past.size(); i++){
if(past[i] == next){
flag = 0;
break;
}
}
}
}
if(flag == 0){
cout << -1 << endl;
} else {
cout << count << endl;
}
}
| a.cc: In function 'int main()':
a.cc:21:21: error: lvalue required as left operand of assignment
21 | while(next != 2 && flag = 1){
| ~~~~~~~~~~^~~~~~~
|
s907819144 | 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 y=A.at(0);
int cnt=0;
for (int i=0; i<N; i++){
y=A.at(y-1);
cnt++;
if (y==2){
cout << cnt+1 << endl;
break;
}
}
if (y!=2){
cout << -1 << endl;
} | 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() {
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.