s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s230516009
p03679
u729047216
1498850985
Python
Python (2.7.6)
py
Runtime Error
11
2568
26
a=int(raw_input()) print a
s814210511
p03679
u566924053
1498781529
Python
Python (3.4.3)
py
Runtime Error
17
2940
142
x, a, b = map(int, input().split()) if b - a < 0: print("delicious") elif 0 <= b - a =< x: print("safe") else: print("dangerous")
s832155788
p03679
u352499693
1498590408
Python
Python (2.7.6)
py
Runtime Error
10
2568
118
X, A, B = map(int, raw_input().split()) if A <= B: print 'delicious' else print 'dangerous' if X < B-A else 'safe'
s309786871
p03679
u892163034
1498573862
Python
Python (3.4.3)
py
Runtime Error
17
2940
137
x,a,b = map(int, input().split()) if b <=a: print("delicious") elif b <= a+x: print("safe") else: print("dangerous") afaafafd
s040588088
p03679
u185325486
1498502994
Python
Python (2.7.6)
py
Runtime Error
10
2568
259
N = int(raw_input()) a = [] for i in range(N): a.append(raw_input()) #print a for i in range(N): a[i] = int(a[i]) cnt = 0 trn = 0 while trn != 1: if trn == -2: cnt = -1 break #print a hako = trn trn = a[trn] - 1 a[hako] = -1 cnt += 1 print cnt
s232599171
p03679
u667084803
1498375515
Python
Python (3.4.3)
py
Runtime Error
18
2940
118
X,A,B=map(int,input().split()) if A-B>=0: print("delicious") eilf B-A<=X: print("safe") else: print("dangerous")
s325566690
p03679
u667084803
1498373823
Python
Python (3.4.3)
py
Runtime Error
17
2940
116
X,A,B=map(int,input().split()) if A-B>=0: print("delicious") eilf B-A<=X: print("safe") else: print(dangerous)
s143483301
p03679
u602740328
1498360558
Python
Python (3.4.3)
py
Runtime Error
17
3060
221
N = int(input()) a = [] for i in range(N): a.append(int(input())) x = [False]*N n,i = (0, 0) while x[n] == False: x[n] = True n = a[n]-1 i+=1 if n==1: print(i) break else: print(-1)
s316057746
p03679
u810709823
1498357839
Python
Python (2.7.6)
py
Runtime Error
12
2568
98
if (B-A)>X: return ‘dangerous’ elif (B-A)<0: return ‘delicious’ else: return ‘safe’
s134229764
p03679
u713627549
1498354631
Python
Python (3.4.3)
py
Runtime Error
18
2940
233
n = int(input()) a = [int(input()) for i in range(n)] count = 0 nextbottun = 1 while(nextbottun != 2 and count <= 100000): nextbottun = a[nextbottun - 1] count += 1 if count <= 100000: print(count) else: print(-1)
s948566036
p03679
u409900997
1498354343
Python
Python (2.7.6)
py
Runtime Error
11
2568
298
num=raw_input('the 3 number of days:') numberdays=num.split(' ') if int(numberdays[2])-int(numberdays[1])>int(numberdays[0]): print 'dangerous' if 0<int(numberdays[2])-int(numberdays[1])<=int(numberdays[0]): print 'safe' if if int(numberdays[2])-int(numberdays[1])<=0: print 'delicious'
s533528650
p03679
u210440747
1498352964
Python
Python (3.4.3)
py
Runtime Error
17
2940
181
if __name__=="__main__": x, a ,b = input().split() if b - a <= 0: print("delicious") elif b - a <= x: print("safe") else: print("dangerous")
s323827244
p03679
u150117535
1498352653
Python
Python (3.4.3)
py
Runtime Error
17
2940
150
X A B = map(int,input().split()) if A-B>=0: print("delicious") else: if X+A-B>=0: print("safe") else: print("dangerous")
s915408867
p03680
u546853743
1601507507
Python
Python (3.8.2)
py
Runtime Error
25
9124
259
n=int(input()) k=[] i=k[0] cnt=1 for i in range(n): l=int(input()) k.append(l) if k.count(2)==0: print(-1) else: while i != 2 and cnt<=n: cnt += 1 i=k[i-1] if i==2: print(cnt+1) else: print(-1)
s658157083
p03680
u333537444
1600768507
Python
PyPy3 (7.3.0)
py
Runtime Error
207
81048
593
def input_int(): return(int(input())) def input_int_list(): return(list(map(int,input().split()))) def input_int_map(): return(map(int,input().split())) def run(): num_count = input_int() nums = [] for _ in range(num_count): nums.append(input_int()) num_history = set(1) curr...
s461408657
p03680
u190850294
1600664349
Python
PyPy3 (7.3.0)
py
Runtime Error
113
67988
1376
import sys def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] de...
s403802242
p03680
u551437236
1600610242
Python
Python (3.8.2)
py
Runtime Error
161
13920
319
n = int(input()) al = [0 for _ in range(n)] for i in range(n): al[i] = int(input()) def check(al,bl,i): bl.append(i) i = al[i]-1 if len(bl) == len(al): print(-1) elif i in bl: print(-1) elif i == 1: print(len(bl)) else: check(al,bl,i) bl = [] check(al,bl,0)
s897730797
p03680
u551437236
1600610109
Python
Python (3.8.2)
py
Runtime Error
169
13668
272
n = int(input()) al = [0 for _ in range(n)] for i in range(n): al[i] = int(input()) def check(al,bl,i): bl.append(i) i = al[i]-1 if i in bl: print(-1) elif i == 1: print(len(bl)) else: check(al,bl,i) bl = [] check(al,bl,0)
s824067106
p03680
u551437236
1600610073
Python
Python (3.8.2)
py
Runtime Error
161
13624
274
n = int(input()) al = [0 for _ in range(n)] for i in range(n): al[i] = int(input()) def check(al,bl,i): bl.append(i) i = al[i]-1 if i in bl: print("-1") elif i == 1: print(len(bl)) else: check(al,bl,i) bl = [] check(al,bl,0)
s937962858
p03680
u317508154
1600400897
Python
Python (3.8.2)
py
Runtime Error
2206
32828
334
n = int(input()) data = [input().split() for i in range(n)] light = [0]*n light[0] = 1 count = 0 bool = False for i in range(n): temp = light.index(1) light[int(data[temp][0]) - 1] = 1 light[temp] = 0 if temp == 1: bool = True print(count) exit() count += 1 if bool == False:...
s562854791
p03680
u347397127
1600397422
Python
PyPy3 (7.3.0)
py
Runtime Error
187
80128
191
def main(): n=int(input()) A=[int(input()) for i in range(n)] crt=1 for i in range(n): crt = A[crt-1] if crt == 2: print(len(L)) break else: print(-1) main()
s546927638
p03680
u325864493
1600103825
Python
Python (3.8.2)
py
Runtime Error
28
9076
225
N = int(input()) A = [0 * N] for i in range(N): A[i] = int(input()) - 1 # 配列に対応 index = 0 trials = -1 for i in range(N): index = A[index] if index == 1: trials = i + 1 break print(trials)
s909056920
p03680
u266874640
1599969527
Python
Python (3.8.2)
py
Runtime Error
146
13656
279
N = int(input()) a = [int(input()) for _ in range(N)] ans = 1 seen = [0] * N seen[0] = 1 now = a[0] while True: if now == 1 or seen[now] == 1: print(-1) break if now == 2: print(ans) break now = a[now-1] seen[now] = 1 ans += 1
s503784708
p03680
u135265051
1599968186
Python
Python (3.8.2)
py
Runtime Error
2206
13108
685
# import math # import statistics a=int(input()) #b,c=int(input()),int(input()) # c=[] # for i in a: # c.append(int(i)) # e1,e2,e3 = map(int,input().split()) #f = list(map(int,input().split())) g = [int(input()) for _ in range(a)] # zoro = int(a[0]*len(a)) find = g.index(2)+1 ans=True count=0 if g[0]==2: print(...
s440667798
p03680
u135265051
1599968060
Python
Python (3.8.2)
py
Runtime Error
2206
13000
565
# import math # import statistics a=int(input()) #b,c=int(input()),int(input()) # c=[] # for i in a: # c.append(int(i)) # e1,e2,e3 = map(int,input().split()) #f = list(map(int,input().split())) g = [int(input()) for _ in range(a)] # zoro = int(a[0]*len(a)) find = g.index(2)+1 ans=True count=0 if g[0]==2: print(...
s879078171
p03680
u135265051
1599967828
Python
Python (3.8.2)
py
Runtime Error
2206
13056
482
# import math # import statistics a=int(input()) #b,c=int(input()),int(input()) # c=[] # for i in a: # c.append(int(i)) # e1,e2,e3 = map(int,input().split()) #f = list(map(int,input().split())) g = [int(input()) for _ in range(a)] # zoro = int(a[0]*len(a)) find = g.index(2)+1 ans=True count=0 while ans: find=g....
s367858013
p03680
u750651325
1599966539
Python
Python (3.8.2)
py
Runtime Error
36
10512
631
import re import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal import functools def v(): return input() def k(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def X(): return list(inpu...
s744697103
p03680
u705418271
1599278836
Python
Python (3.8.2)
py
Runtime Error
139
16308
219
n=int(input()) a=[] t=[] t.append(1) for i in range(n): a.append(input()) x=a[0] while True: if x==2: print(len(t)) break elif x in t: print(-1) break else: t.append(x) y=x x=a[y-1]
s267788097
p03680
u705418271
1599278364
Python
Python (3.8.2)
py
Runtime Error
136
16216
196
n=int(input()) a=[] t=[] t.append(1) for i in range(n): a.append(input()) x=a[0] while True: if x==2: print(len(t)) exit() elif x in t: print(-1) exit() else: x=a[x-1]
s624263966
p03680
u440478998
1599270065
Python
Python (3.8.2)
py
Runtime Error
28
8944
219
n = int(input()) a = [0,int(input()) for i in range(n)] cnt = 1 next_a = a[1] while cnt <= 10**5: next_a = a[next_a] cnt += 1 if next_a == 2: break if cnt < 10**5: print(cnt) else: print(-1)
s721844548
p03680
u909224749
1599158968
Python
Python (3.8.2)
py
Runtime Error
25
8976
317
N = int(input()) A = [] for i in range(N): A.append(int(input())-1) ans = -1 push = 0 count = [] for i in range(N+1): if A[push] == 1: ans = i+1 break elif A[push] in count: break else:  count.append(push) push = A[push] print(ans)
s868625454
p03680
u909224749
1599157265
Python
Python (3.8.2)
py
Runtime Error
2206
13284
257
N = int(input()) A = [] for _ in range(N): A.append(int(input())-1) count = [] n = 0 for k in range(N+1): if A[n] == 1: break elif A[n] in count: ans = -1 break else: count.append(A[n]) ans = k+1 n = A[n] print(ans)
s713249394
p03680
u282813849
1599086084
Python
Python (3.8.2)
py
Runtime Error
160
14692
294
N = int(input()) d = [] visited = [False for _ in range(N+1)] for _ in range(N): d.append(int(input())-1) def dfs(i,cnt): if i == 1: return cnt elif cnt >= N: return -1 elif visited[i]: return -1 else: visited[i] = True return dfs(d[i],cnt+1) print(dfs(0,0))
s728994278
p03680
u282813849
1599085904
Python
Python (3.8.2)
py
Runtime Error
164
14360
263
N = int(input()) d = [] visited = [False for _ in range(N+1)] for _ in range(N): d.append(int(input())-1) def dfs(i,cnt): if i == 1: return cnt elif visited[i]: return -1 else: visited[i] = True return dfs(d[i],cnt+1) print(dfs(0,0))
s578074432
p03680
u282813849
1599085709
Python
Python (3.8.2)
py
Runtime Error
162
14392
293
N = int(input()) d = [] visited = [False for _ in range(N)] for _ in range(N): d.append(int(input())-1) def dfs(i,cnt): if i == 1: return cnt elif visited[i]: return -1 else: visited[i] = True return dfs(d[i],cnt+1) def main(): return dfs(0,0) print(main())
s573293402
p03680
u282813849
1599085374
Python
Python (3.8.2)
py
Runtime Error
158
14432
323
N = int(input()) d = [] visited = [False for _ in range(N)] for _ in range(N): d.append(int(input())-1) def dfs(i,cnt): if visited[i]: return -1 elif i == 1: return cnt else: visited[i] = True return dfs(d[i],cnt+1) def main(): if d[1] == 1: return -1 return dfs(0,0) print(main...
s157265853
p03680
u978677493
1598813782
Python
Python (3.8.2)
py
Runtime Error
166
14444
385
import math n = int(input()) g = [0 for _ in range(int(1e5+3))] visited = [False] * int(1e5 + 3) ans = math.inf def dfs(i, c): if visited[i]: return global ans if i == 2: ans = min(ans, c-1) return visited[i] = True dfs(g[i], c + 1) for i in range(n): a = int(input()) ...
s292068230
p03680
u978677493
1598813616
Python
Python (3.8.2)
py
Runtime Error
189
23976
398
import math n = int(input()) g = [[] for _ in range(int(1e5+2))] visited = [False] * int(1e5 + 2) ans = math.inf def dfs(i, c): if visited[i]: return global ans if i == 2: ans = min(ans, c-1) visited[i] = True for to in g[i]: dfs(to, c + 1) for i in range(n): a = int(in...
s135763218
p03680
u620846115
1598790047
Python
Python (3.8.2)
py
Runtime Error
131
16264
197
n = int(input()) x = [input()for i in range(n)] turn = 1 count = 0 while turn != 2: turn = x[turn-1] count +=1 if turn ==x[turn-1]: print(-1) if turn ==2: print(count) else: print(-1)
s432622355
p03680
u826637752
1598464484
Python
Python (3.8.2)
py
Runtime Error
138
13052
167
n = int(input()) al = [int(input()) for _ in range(n)] pos = 0 for i in range(N): pos = A[pos] - 1 if (pos == 1): print(i+1) exit() print(-1)
s090791353
p03680
u077013956
1598401996
Python
Python (3.8.2)
py
Runtime Error
26
8912
969
#include <bits/stdc++.h> using namespace std; int main() { /* 入力処理 */ int N; cin >> N; vector<int> a(N); for(int i =0;i<N;i++) { cin >> a.at(i); } /* 変数宣言 */ int count = 0; //ボタンを押した回数のカウンター int j = 0; //最初のボタン1(すなわち、j=0) /* ボタンを押していく */ for(int i=0;i<N;i++) { ...
s145020076
p03680
u468972478
1598320480
Python
Python (3.8.2)
py
Runtime Error
28
9044
199
n = int(input()) a = [] s = [1] t = 1 ans = 0 for i in range(n): a.append(int(input()) while t != 2: t = a[t-1] s.append(t) if s.count(t) == 2: ans = -1 break ans += 1 print(ans)
s885380455
p03680
u198930868
1598214530
Python
Python (3.8.2)
py
Runtime Error
140
12984
252
n = int(input()) a = [int(input()) for l in range(n)] flag = True ans = 0 i = a[0] while flag: i = a[i-1] ans += 1 if i == 2: print(ans+1) flag = False else: count += 1 if count >= n: print(-1) flag = False
s555809989
p03680
u107915058
1597862386
Python
Python (3.8.2)
py
Runtime Error
24
9116
166
cnt = 1 l = a[0] for _ in range(N): if l in a: l = a[l-1] cnt += 1 if l == 2: print(cnt) break else: print(-1)
s902379438
p03680
u869790980
1597373082
Python
PyPy2 (7.3.0)
py
Runtime Error
64
64300
186
ais = [int(raw_input()) for oo in range(raw_input())]#n = raw_input() seen = set([]) u = 0 while(u!= 1 or u not in seen): seen.add(u) u = ais[u] - 1 print len(seen) if u == 1 else -1
s209114613
p03680
u869790980
1597373032
Python
PyPy2 (7.3.0)
py
Runtime Error
314
84284
230
ais = [int(raw_input()) for oo in range(raw_input())]#n = raw_input() #for ais = map(int , raw_input().split()) seen = set([]) u = 0 while(u!= 1 or u not in seen): seen.add(u) u = ais[u] - 1 print len(seen) if u == 1 else -1
s691459335
p03680
u939790872
1596783624
Python
Python (3.8.2)
py
Runtime Error
159
13044
193
N = int(input()) l = [int(input()) for i in range(N)] index = 0 count = 0 for j in range(N): index = l[index] count += 1 if index == 2: print(count) exit() print(-1)
s475214916
p03680
u113255362
1595457794
Python
Python (3.8.2)
py
Runtime Error
164
13040
232
Row = int(input()) List = [] for i in range (Row): List.append(int(input())) s = 1 res = 0 flag = False for i in range(Row): s = List[s] res += 1 if s == 2: flag=True break if not flag: print(-1) else: print(res)
s308882621
p03680
u072717685
1595386310
Python
Python (3.8.2)
py
Runtime Error
2206
20544
363
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n, *a = map(int, read().split()) if n == 2: print(1) sys.exit() r = 0 x = 2 while x != 1: r += 1 x = a.index(x) + 1 if x == 2 or r >= n: r = -1 break print...
s428707642
p03680
u072717685
1595385989
Python
Python (3.8.2)
py
Runtime Error
2206
20560
352
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n, *a = map(int, read().split()) if n == 2: print(1) sys.exit() r = 0 x = 2 while x != 1: r += 1 x = a.index(x) + 1 if x == 2: r = -1 break print(r) if __...
s970085470
p03680
u185806788
1594784306
Python
PyPy3 (7.3.0)
py
Runtime Error
191
80608
142
N=int(input()) a=[int(input()) for i in range(N)] X=1 i=1 while a[i-1]!=2 and X<=n: X+=1 i=a[i-1] if X>N: print(-1) else: print(X)
s663850364
p03680
u075401284
1594148967
Python
Python (3.8.2)
py
Runtime Error
149
13044
235
n = int(input()) a = [] for i in range(n): a.append(int(input())) def check(now, memo, cnt): now = a[now] if now in memo: return -1 if now == 2: return cnt check(now, memo.add(now), cnt+1) print(check(1,{1},0))
s270391069
p03680
u075401284
1594148912
Python
Python (3.8.2)
py
Runtime Error
150
13048
255
n = int(input()) a = [] for i in range(n): a.append(int(input())) def check(now, memo, cnt): now = a[now] if now in memo: return False if now == 2: return cnt check(now, memo.add(now), cnt+1) if flg: print(cnt) else: print(-1)
s635819919
p03680
u075401284
1594148635
Python
Python (3.8.2)
py
Runtime Error
2206
13116
257
n = int(input()) a = [] for i in range(n): a.append(int(input())) memo = {1} now = 1 cnt = 0 flg = False while True: now = a[now] cnt += 1 if now in memo: break if now == 2: flg = True break if flg: print(cnt) else: print(-1)
s617133377
p03680
u050622763
1593981471
Python
Python (3.8.2)
py
Runtime Error
230
31816
289
import numpy as np N = int(input()) a = np.array([int(input()) for i in range(N)]) #回数i,インデックスn def button(i,n): if i == N: return n_new = a[n-1] if n_new == 2: print(i) return else: return button(i+1,n_new) button(1,1)
s200190772
p03680
u870518235
1593557047
Python
Python (3.8.2)
py
Runtime Error
154
12928
205
# ABC065_B N = int(input()) A = [int(input()) for _ in range(N)] next = A[0] ans = -1 cnt = 0 for i in range(N): next = A[next] cnt += 1 if next == 2: ans = cnt break print(ans)
s521941607
p03680
u088488125
1593397697
Python
Python (3.8.2)
py
Runtime Error
29
8976
134
n=int(input()) a=[input() for i in range(n)] bu=0 end=-1 for i in range(n): if bu==1: end=i-1 break bu=a[bu]-1 print(end)
s578319183
p03680
u801533740
1593212602
Python
PyPy3 (7.3.0)
py
Runtime Error
89
74660
290
import sys from io import StringIO import unittest lines = sys.stdin.readlines() lines = list(map(lambda x: int(x.rstrip()), lines)) n = lines[0] i = 1 for c in range(1, n+1): i = lines[i] if i == 2: print(c) return print(-1)
s987570552
p03680
u801533740
1593212513
Python
PyPy3 (7.3.0)
py
Runtime Error
89
74564
238
lines = sys.stdin.readlines() lines = list(map(lambda x: int(x.rstrip()), lines)) n = lines[0] i = 1 for c in range(1, n+1): i = lines[i] if i == 2: print(c) return print(-1)
s546935145
p03680
u729119068
1593202175
Python
Python (3.8.2)
py
Runtime Error
24
8896
185
S={n:int(input()) for n in list(range(1,N+1))} a=1 cnt=0 while True: a=S[a] cnt+=1 if a==2: print(cnt) break if a==1: print(-1) break
s176189688
p03680
u729119068
1593201602
Python
Python (3.8.2)
py
Runtime Error
24
9056
176
S={n:int(input()) for n in range(1,N+1)} a=1 cnt=0 while True: a=S[a] cnt+=1 if a==2: print(cnt) break if a==1: print(-1) break
s714693214
p03680
u729119068
1593200683
Python
Python (3.8.2)
py
Runtime Error
155
21868
188
N=int(input()) S={n:int(input()) for n in range(1,N+1)} a=1 while True: a=S[a] cnt+=1 if a==2: print(cnt) break if a==1: print(-1) break
s334156505
p03680
u729119068
1593200489
Python
Python (3.8.2)
py
Runtime Error
25
9020
172
S={n:int(input()) for n in range(1,N+1)} a=1 while True: a=S[a] cnt+=1 if a==2: print(cnt) break if a==1: print(-1) break
s535094407
p03680
u285681431
1592537922
Python
Python (3.8.2)
py
Runtime Error
23
9192
323
N = int(input()) a = [int(input()) for i in range(n)] #最初はボタン1が光っている index = 1 #押した回数0からスタート count = 0 while count < N: if a[index-1]==2: count += 1 print(count) exit() else: count += 1 #次に光るボタン index=a[index-1] print(-1)
s306315210
p03680
u540290227
1591670709
Python
Python (3.4.3)
py
Runtime Error
2104
7852
398
n = int(input()) a = [int(input()) for _ in range(n)] button = [0]*n button1 = a[0] - 1 try: a.remove(2) print('01') exit() except: pass count = 1 while True: button[button1] += 1 button1 = a[button1] - 1 if button[1] == 1: print(count) break try: button.remove(2)...
s336589961
p03680
u730769327
1591248161
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38384
210
n=int(input()) a=[] for i in range(n): a.appent(int(input())) i=0 count=1 while(1): if a[i]==1: frag=-1 break elif a[i]==2: frag=count break else: i=a[i]-1 count+=1 print(frag)
s358793494
p03680
u730769327
1591248128
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
208
n=int(input()) a=[] for i in range(n): a.appent(int(input)) i=0 count=1 while(1): if a[i]==1: frag=-1 break elif a[i]==2: frag=count break else: i=a[i]-1 count+=1 print(frag)
s498909255
p03680
u674588203
1591156720
Python
Python (3.4.3)
py
Runtime Error
210
7852
343
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,"aaa") PressedButtons=[False]*N a=1 count=0 if lamps.count(2)==0: print("-1") exit() while PressedButtons[a]==False : PressedButtons[a]=True count+=1 a=lamps[a] if a==2: print(count) ...
s151521542
p03680
u674588203
1591156618
Python
Python (3.4.3)
py
Runtime Error
209
7852
332
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,"aaa") PressedButtons=[False]*N a=1 count=0 if lamps.count(2)==0: print("-1") while PressedButtons[a]==False : PressedButtons[a]=True count+=1 a=lamps[a] if a==2: print(count) exit() ...
s769096948
p03680
u674588203
1591156530
Python
Python (3.4.3)
py
Runtime Error
197
7852
292
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,"aaa") PressedButtons=[False]*N a=1 count=0 while PressedButtons[a]==False : PressedButtons[a]=True count+=1 a=lamps[a] if a==2: print(count) exit() print('-1')
s006939772
p03680
u674588203
1591156241
Python
Python (3.4.3)
py
Runtime Error
2104
7852
454
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,"aaa") PressedButtons=[False]*N a=1 count=0 while True: if PressedButtons[a]==False: PressedButtons[a]=True count+=1 a=lamps[a] if a==2: print(count) exit() ...
s616616671
p03680
u674588203
1591156032
Python
Python (3.4.3)
py
Runtime Error
203
7852
443
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,"aaa") PressedButtons=[False]*N a=1 count=0 while True: if PressedButtons[a]==False: PressedButtons[a]=True count+=1 a=lamps[a] if a==2: print(count) exit() ...
s800298809
p03680
u674588203
1591155933
Python
Python (3.4.3)
py
Runtime Error
212
7852
431
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,"aaa") PressedButtons=[False]*N a=1 count=0 while True: if PressedButtons[a]==False: PressedButtons[a]=True count+=1 a=lamps[a] if a==2: print(count) exit() ...
s433906263
p03680
u674588203
1591155871
Python
Python (3.4.3)
py
Runtime Error
203
7852
416
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,"aaa") PressedButtons=[False]*N a=1 count=0 while True: if PressedButtons[a]==False: PressedButtons[a]=True count+=1 a=lamps[a] if a==2: print(count) exit() ...
s469551299
p03680
u674588203
1591155558
Python
Python (3.4.3)
py
Runtime Error
204
7852
396
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,"aaa") PressedButtons=[False]*N a=1 count=0 while True: if PressedButtons[a]==False: PressedButtons[a]=True count+=1 a=lamps[a] if a==2: print(count) elif PressedButton...
s893885157
p03680
u674588203
1591122875
Python
Python (3.4.3)
py
Runtime Error
2104
7464
413
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) lamps.insert(0,-1) if lamps.count(2)==0: print("-1") exit() # no2=[i for i , x in enumerate(lamps) if x==2] PressedButton=[] num=2 while lamps[1]!=num: a=lamps.index(num) if PressedButton.count(a)==0: PressedBut...
s032323310
p03680
u674588203
1591122669
Python
Python (3.4.3)
py
Runtime Error
2108
7084
394
N=int(input()) lamps=[] for a in range(N): _=int(input()) lamps.append(_) if lamps.count(2)==0: print("-1") exit() # no2=[i for i , x in enumerate(lamps) if x==2] PressedButton=[] num=2 while lamps[0]!=num: a=lamps.index(num) if PressedButton.count(a)==0: PressedButton.append(a) ...
s511410023
p03680
u991619971
1590962049
Python
Python (3.4.3)
py
Runtime Error
18
2940
415
#import numpy as np #from itertools import combinations as comb #from itertools import combinations_with_replacement as comb_with #from itertools import permutations as perm N = int(input()) #H1,M1,H2,M2,K= map(int,input().split()) #A = list(map(int,input().split())) #B = list(map(int,input().split())) #S= str(input(...
s217035116
p03680
u274644863
1590383402
Python
Python (3.4.3)
py
Runtime Error
17
3060
299
for i in range(n): a.append(int(input())-1) button = 0 cnt = 0 done = [False] * n while True: if done[button] == False: done[button] = True cnt += 1 if a[button] == 1: break button = a[button] else: cnt = -1 break print(cnt)
s669884521
p03680
u738622346
1590353769
Python
Python (3.4.3)
py
Runtime Error
2104
7088
421
n = int(input()) buttons = [0] target_index = 0 for _ in range(n): num = int(input()) buttons.append(num) count = 0 next_index = 2 while count < n: if next_index < 1 or len(buttons) - 1 <= next_index: count = -1 break prev_index = buttons.index(next_index) count += 1 if prev_in...
s724386027
p03680
u738622346
1590353335
Python
Python (3.4.3)
py
Runtime Error
2104
7080
421
n = int(input()) buttons = [0] target_index = 0 for i in range(n): num = int(input()) buttons.append(num) count = 0 next_index = 2 while count < n: if next_index < 1 or len(buttons) - 1 <= next_index: count = -1 break prev_index = buttons.index(next_index) count += 1 if prev_in...
s314536517
p03680
u738622346
1590353281
Python
Python (3.4.3)
py
Runtime Error
2104
7080
408
n = int(input()) buttons = [0] target_index = 0 for i in range(n): num = int(input()) buttons.append(num) count = 0 next_index = 2 while count < n: if len(buttons) - 1 <= next_index <= 0: count = -1 break prev_index = buttons.index(next_index) count += 1 if prev_index == 1: ...
s773577824
p03680
u738622346
1590353195
Python
Python (3.4.3)
py
Runtime Error
2104
7080
403
n = int(input()) buttons = [0] target_index = 0 for i in range(n): num = int(input()) buttons.append(num) count = 0 next_index = 2 while count < n: if len(buttons) - 1 <= next_index: count = -1 break prev_index = buttons.index(next_index) count += 1 if prev_index == 1: ...
s557637053
p03680
u738622346
1590352994
Python
Python (3.4.3)
py
Runtime Error
2104
7080
402
n = int(input()) buttons = [0] target_index = 0 for i in range(n): num = int(input()) buttons.append(num) count = 0 next_index = 2 while count < n: if len(buttons) - 1 < next_index: count = -1 break prev_index = buttons.index(next_index) count += 1 if prev_index == 1: b...
s247547929
p03680
u738622346
1590352767
Python
Python (3.4.3)
py
Runtime Error
2104
7080
329
n = int(input()) buttons = [0] target_index = 0 for i in range(n): num = int(input()) buttons.append(num) count = 0 next_index = 2 while count < n: prev_index = buttons.index(next_index) count += 1 if prev_index == 1: break else: next_index = prev_index print(count if count < n...
s765639497
p03680
u854992222
1590241670
Python
Python (3.4.3)
py
Runtime Error
2104
7084
187
n = int(input()) a = [int(input()) for _ in range(n)] tmp = a.index(2) count = 1 while tmp != 0: tmp = a.index(tmp+1) count += 1 if count >= n: print(-1) exit() print(count)
s937337560
p03680
u503111914
1590189828
Python
Python (3.4.3)
py
Runtime Error
211
7084
225
import sys N = int(input()) A = [int(input()) for _ in range(N)] ans = 1 a = A.index(1)+1 #print(a) for i in range(N*2): a = A[a-1] #print(a) if a == 2: print(ans) sys.exit() ans += 1 print(-1)
s722564265
p03680
u106778233
1590117854
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
152
n=int(input()) A=[int(input()) for _ in range(n)] A=[0]+A cnt=1 for ? in range(1,n+1): cnt=A[cnt] if cnt==2: print(?) exit() print(-1)
s115831313
p03680
u696969901
1590096239
Python
Python (3.4.3)
py
Runtime Error
262
17892
302
N = int(input()) dic = {} for i in range(1, N + 1): dic[i] = int(input()) routedDic = [] def NextRoute(i): x = dic[i] if x in routedDic: return -1 routedDic.append(x) if x == 2: return len(routedDic) else: return NextRoute(x) print(NextRoute(1))
s910614312
p03680
u057415180
1589869159
Python
Python (3.4.3)
py
Runtime Error
190
6900
246
n = int(input()) a = [0]*n for i in range(n): a[i] = int(input()) now = a[0] cnt = 0 while now != 2: cnt += 1 now = a[now-1] if cnt >= n: print(-1) exit() fp.append(now) if now == 2: cnt += 1 print(cnt)
s095385095
p03680
u494037809
1589844122
Python
Python (3.4.3)
py
Runtime Error
214
7084
249
N = int(input()) a_list = [] for n in range(N): a_list.append(int(input())) count = 0 pos = 1 for n in range(N): pos = a_list[pos-1] count += 1 if a_list[pos-1]==2: print(count) break if a_list[pos]!=2: print(-1)
s447324860
p03680
u085717502
1589729653
Python
Python (3.4.3)
py
Runtime Error
254
7984
411
#!/usr/bin/env python # coding: utf-8 # In[28]: N = int(input()) a = [] for i in range(N): a.append(int(input())) # In[29]: def func(x, a, history, cnt): # print(x, a[x-1], history) if a[x-1] == 2: print(cnt) elif a[x-1] in history: print(-1) else: history.append(a[x-1...
s850939069
p03680
u790012205
1589715955
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38256
246
import sys N = int(input()) a = [int(input()) for i in range(N)] d = [0] b = 0 c = 0 while True: if b == 1:a print(c) sys.exit() c += 1 b = a[b] - 1 if b in d: print('-1') sys.exit() d.append(b)
s741312604
p03680
u589047182
1589660588
Python
PyPy3 (2.4.0)
py
Runtime Error
241
51896
424
import sys input = sys.stdin.readline N = int(input().rstrip()) a_dict = {} for i in range(N): a_dict[i+1] = int(input().rstrip()) target = 1 next_target = a_dict[target] cont = True ans = 0 while cont: del a_dict[target] target = next_target next_target = a_dict[target] ans += 1 if next_target not in a...
s970997435
p03680
u202826462
1588816303
Python
Python (3.4.3)
py
Runtime Error
406
100176
330
import sys sys.setrecursionlimit(100000) n = int(input()) a = [int(input()) for i in range(n)] switch = [False] * (n + 1) def button(x,cnt): if switch[x]: print(-1) return -1 if x == 2: print(cnt) return switch[x] = True button(a[x - 1], cnt + 1) return cnt ans = bu...
s432254212
p03680
u202826462
1588816257
Python
Python (3.4.3)
py
Runtime Error
319
54088
329
import sys sys.setrecursionlimit(50000) n = int(input()) a = [int(input()) for i in range(n)] switch = [False] * (n + 1) def button(x,cnt): if switch[x]: print(-1) return -1 if x == 2: print(cnt) return switch[x] = True button(a[x - 1], cnt + 1) return cnt ans = but...
s949841863
p03680
u202826462
1588816174
Python
Python (3.4.3)
py
Runtime Error
246
17084
329
import sys sys.setrecursionlimit(10000) n = int(input()) a = [int(input()) for i in range(n)] switch = [False] * (n + 1) def button(x,cnt): if switch[x]: print(-1) return -1 if x == 2: print(cnt) return switch[x] = True button(a[x - 1], cnt + 1) return cnt ans = but...
s640461546
p03680
u202826462
1588816054
Python
Python (3.4.3)
py
Runtime Error
236
8768
289
n = int(input()) a = [int(input()) for i in range(n)] switch = [False] * (n + 1) def button(x,cnt): if switch[x]: print(-1) return -1 if x == 2: print(cnt) return switch[x] = True button(a[x - 1], cnt + 1) return cnt ans = button(1, 0)
s342494544
p03680
u798260206
1588813684
Python
Python (3.4.3)
py
Runtime Error
194
3884
203
import sys n = int(input()) a = [] ans = 0 lamp = 1 for _ in range(n): A = int(input()) a.append(a) for i in range(n): if lamp -1 == 1: print(i) sys.exit() lamp = a[lamp - 1] print(-1)
s575021641
p03680
u766566560
1588731186
Python
Python (3.4.3)
py
Runtime Error
210
7084
191
N = int(input()) a = [int(input()) for _ in range(N)] cnt = 1 for i in range(N+1): nxt = a[i]-1 cnt += 1 if a[nxt] == 2: print(cnt) exit() else: nxt = a[i] - 1 print(-1)