s_id
string
p_id
string
u_id
string
date
string
language
string
original_language
string
filename_ext
string
status
string
cpu_time
string
memory
string
code_size
string
code
string
error
string
stdout
string
s641423998
p04005
u837286475
1473571553
Python
Python (3.4.3)
py
Runtime Error
39
3188
411
N,x = map(int,input().split()) lst = list( map(int,input().split() ) ) ans = sum(lst) dp = lst[:] #print(N,x) #print(lst) for i in range(1,N): tmp = 0 for k in range(0,N): index_ = 0 if(0 <= k-i): index_ = k-i else: index_ = N-i+k dp[k] = min(dp[k],lst[index_]) tmp = tmp+dp[k] tmp = tmp + x*i ans = min(ans,tmp) print(ans)
Traceback (most recent call last): File "/tmp/tmppcdu0zc7/tmpex1l_s5d.py", line 2, in <module> N,x = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s746003662
p04005
u010075034
1473128156
Python
Python (3.4.3)
py
Runtime Error
38
3064
319
def main(): ints = (int(_) for _ in input().split(' ')) if any(_ % 2 == 0 for _ in ints): print(0) return t = max(ints) x, y, z = ints if t == x: print(y * z) elif t == y: print(x * z) elif t == z: print(x * y) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmp3eevon05/tmp4y7kdycd.py", line 17, in <module> main() File "/tmp/tmp3eevon05/tmp4y7kdycd.py", line 2, in main ints = (int(_) for _ in input().split(' ')) ^^^^^^^ EOFError: EOF when reading a line
s133089835
p04005
u010075034
1473127873
Python
Python (3.4.3)
py
Runtime Error
38
3064
292
if __name__ == '__main__': x, y, z = (int(_) for _ in input().split(' ')) if x % 2 == 0 or y % 2 == 0 or z % 2 == 0: print(0) return t = max((x, y, z)) if t == x: print(y * z) elif t == y: print(x * z) elif t == z: print(x * y)
File "/tmp/tmpy0r3dau2/tmp0srkj5jo.py", line 5 return ^^^^^^ SyntaxError: 'return' outside function
s834177418
p04005
u091855288
1473101376
Python
Python (2.7.6)
py
Runtime Error
157
10420
205
import numpy as np import copy a = map(int,raw_input().split()) def myfunc(a): A.sort(reverse=True) if (A[0]%2 != 0 and A[1]%2 !=0 and A[2]%2 != 0): print A[1]*A[2] else: print 0 myfunc(a)
File "/tmp/tmpu4hpbn6x/tmptvzff_pf.py", line 9 print A[1]*A[2] ^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s112571289
p04005
u516438812
1473084975
Python
Python (3.4.3)
py
Runtime Error
42
3184
218
A,B,C = map(int,input().split()) if A % 2 == 0 or B % 2 == 0 or C % 2 == 0: print(0) return S = A * B * C mi = min(A,min(B,C)) ma = max(A,max(B,C)) mid = S // ma // mi // 2 ans = ma * mi * mid print(abs(S - ans * 2))
File "/tmp/tmpl7j6xu33/tmp4_o8vfz3.py", line 4 return ^^^^^^ SyntaxError: 'return' outside function
s169478662
p04005
u837286475
1473058365
Python
Python (3.4.3)
py
Runtime Error
38
3064
243
a,b,c = map(int,input().split()) lst = [a,b,c] cnt = len(list( filter(lambda x:x%2==0,lst))) if(0<cnt): print(0) else: lst.sort() res = 0 if(lst[2]%2 == 1): res = lst[0]*lst[1] else: res = 0 prin
Traceback (most recent call last): File "/tmp/tmploiu7d7a/tmpqk71oklj.py", line 2, in <module> a,b,c = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s285906466
p04005
u601018334
1473044979
Python
Python (3.4.3)
py
Runtime Error
37
3064
443
N, x = list(map(int, input().split())) a = list(map(int, input().split())) min_index = a.index(min(a)) index_list = list(range(min_index,N)) + list(range(min_index)) cost = a.copy() c_count = [0]*N for i in range(1,N): if cost[index_list[i]] > (cost[index_list[i-1]]+x): cost[index_list[i]] = cost[index_list[i-1]]+x c_count[index_list[i]] = c_count[index_list[i-1]]+1 print(sum(cost) - sum(c_count)*x + max(c_count)*x )
Traceback (most recent call last): File "/tmp/tmpv5xyinj6/tmp6z6p1b5j.py", line 1, in <module> N, x = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s959814121
p04005
u436484848
1473044171
Python
Python (3.4.3)
py
Runtime Error
36
3064
149
str = input() num = list(map(int,str.split(' '))) if (num[0]%2)and(num[1]%2)and(num[2])==0: print(0) else: num.sort() print(num[0]*num[1])
File "/tmp/tmpz538e0c4/tmpqt9zqbrf.py", line 7 print(num[0]*num[1]) TabError: inconsistent use of tabs and spaces in indentation
s470573294
p04005
u436484848
1473043929
Python
Python (3.4.3)
py
Runtime Error
39
3064
152
str = input() num = list(map(int,str.split(' '))) if (num[0]%2)*(num[1]%2)*(num[2])==1: num.sort() print(num[0]*num[1]) else: print(0)
File "/tmp/tmpk5pz1lpf/tmpetn0jujo.py", line 5 print(num[0]*num[1]) TabError: inconsistent use of tabs and spaces in indentation
s314111636
p04005
u436484848
1473043769
Python
Python (3.4.3)
py
Runtime Error
37
3064
135
str = input() num = list(map(int,str.split(' '))) if !(num[0]%2)*(num[1]%2)*(num[2]): print(0) else: num.sort() print(num[0]*num[1])
File "/tmp/tmppunjo329/tmpohcui_l1.py", line 3 if !(num[0]%2)*(num[1]%2)*(num[2]): ^ SyntaxError: invalid syntax
s044929033
p04005
u866746776
1473040585
Python
Python (3.4.3)
py
Runtime Error
39
3064
430
def solve(n, x, a): costs = [] cost_min = 0 for k in range(n): if k == 0: costs = a.copy() else: for i in range(n): costs[i] = min(costs[i], a[(i-k)%n]) cost_k = sum(costs) + k*x if k == 0: cost_min = cost_k else: cost_min = min(cost_min, cost_k) if cost_min < (k+1) *x: break return cost_min n, x = [int(i) for i in input().split()] a = [int(i) for i in input().split()] print(solve(n,x,a))
Traceback (most recent call last): File "/tmp/tmpdugmhw74/tmpj8byfi1_.py", line 19, in <module> n, x = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s349125909
p04005
u010075034
1473039791
Python
Python (3.4.3)
py
Runtime Error
39
3064
222
#!/usr/bin/env python3 if __name__ == '__main__': N, x = (int(_) for _ in input().split(' ')) As = [int(_) for _ in input().split(' ')] each = sum(As) change = (N - 1) * x + N print(min(each, change))
Traceback (most recent call last): File "/tmp/tmprya3wq2j/tmp557h2ci7.py", line 4, in <module> N, x = (int(_) for _ in input().split(' ')) ^^^^^^^ EOFError: EOF when reading a line
s357005931
p04005
u010075034
1473038769
Python
Python (3.4.3)
py
Runtime Error
37
3064
294
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) lst = (x, y, z) a = max(lst) if a == x: b, c = y, z elif a == y: b, c = x, z elif a == z: b, c = x, y print(((a - (a // 2)) * b * c) - ((a // 2) * b * c))
Traceback (most recent call last): File "/tmp/tmpjymke76y/tmptpzvy33q.py", line 2, in <module> x = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s530520046
p04005
u010075034
1473038345
Python
Python (3.4.3)
py
Runtime Error
40
3188
218
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) t = (x, y, z) a = max(t) b, c = [_ for _ in t if _ != a] print(((a - (a // 2)) * b * c) - ((a // 2) * b * c))
Traceback (most recent call last): File "/tmp/tmpxs_7182s/tmptgzmqrce.py", line 2, in <module> x = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s395762583
p04005
u177721681
1473038057
Python
Python (2.7.6)
py
Runtime Error
26
2568
425
from sys import stdin from sys import stdout A,B,C = stdin.readline().split() if A%2 == 0 or B%2 == 0 or C%2 == 0 : print 0 exit() AB = int(A) * int(B) BC = int(C) * int(B) AC = int(A) * int(C) ABC = AB * int(C) area = (AB,BC,AC).sort().reverse()[0] print area
File "/tmp/tmp5aaa8q5z/tmpk4qns5p9.py", line 7 print 0 ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s928162301
p04005
u132360211
1473038021
Python
Python (2.7.6)
py
Runtime Error
26
2568
152
io = STDIN a,b,c=io.gets.chomp.split.map(&:to_i) p [(a*b*(c/2)-a*b*(c-(c/2))).abs, (c*b*(a/2)-c*b*(a-(a/2))).abs, (a*c*(b/2)-a*c*(b-(b/2))).abs].min
File "/tmp/tmpwaulq82k/tmpku8nclyy.py", line 2 a,b,c=io.gets.chomp.split.map(&:to_i) ^ SyntaxError: invalid syntax
s700164432
p04005
u530850765
1473037674
Python
Python (3.4.3)
py
Runtime Error
42
3316
169
a,b,c = (int(x) for x in input()) ans = abs(a*b*(c//2)-a*b*(c-c//2)) ans = min(ans, abs(a*c*(b//2)-a*c*(b-b//2))) ans = min(ans, abs(b*c*(a//2)-b*c*(a-a//2))) print(ans)
Traceback (most recent call last): File "/tmp/tmp_ko75o91/tmp2t4mb57h.py", line 1, in <module> a,b,c = (int(x) for x in input()) ^^^^^^^ EOFError: EOF when reading a line
s556051583
p04006
u493520238
1601347319
Python
PyPy3 (7.3.0)
py
Runtime Error
1270
71424
1779
# 0-indexed class SegTree: def __init__(self, vals, seg_f, ide_ele): n = len(vals) self.seg_f = seg_f self.ide_ele = ide_ele self.leaf_n = 1 << (n-1).bit_length() self.tree = [ide_ele]*(2*self.leaf_n-1) for i in range(n): # init leaf self.tree[i+self.leaf_n-1] = vals[i] for i in range(self.leaf_n-2, -1, -1): # bottom-up self.tree[i] = self.seg_f(self.tree[2*i+1], self.tree[2*i+2]) def update(self, i, x): i += (self.leaf_n-1) self.tree[i] = x while i > 0: i = (i-1)//2 self.tree[i] = self.seg_f(self.tree[2*i+1], self.tree[2*i+2]) # [l,r) def query(self, l, r): v_l = self.ide_ele v_r = self.ide_ele l += (self.leaf_n-1) r += (self.leaf_n-1) while l < r: if l&1 == 0: v_l = self.seg_f(v_l, self.tree[l]) if r&1 == 0: v_r = self.seg_f(v_r, self.tree[r-1]) r -= 1 l >>= 1 r >>= 1 return self.seg_f(v_l ,v_r) ''' def add(a,b): return a+b st = SegTree(vl,add,0) st = SegTree(vl,(lambda a,b: a+b),0) st = SegTree(vl,min,10**10) print(st.query(2,4)) st.update(4,-4) print(st.query(2,5)) st.update(0,-10) print(st.query(0,5)) ''' n,x = map(int, input().split()) al = list(map(int, input().split())) st = SegTree(al, min, 10**18) ans = 10**18 for i in range(0,n): # move cnt curr_i_ans = i*x for j in range(n): # ind l = j-i if l >= 0: amin = st.query(l,j+1) else: amin1 = st.query(0,j+1) amin2 = st.query(l+n,n+1) amin = min(amin1,amin2) curr_i_ans += amin ans = min(ans, curr_i_ans) print(ans)
Traceback (most recent call last): File "/tmp/tmpkabnb0lg/tmpa5t94a1a.py", line 50, in <module> n,x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s594163422
p04006
u423585790
1590435983
Python
PyPy3 (2.4.0)
py
Runtime Error
214
71808
246
n,x=map(int,input().split()) A=list(map(int,input().split())) ans=0 dp=[[A[i]]*n for i in range(n)] for l in range(n): a=A[l:]+A[:l] a=a[::-1] for i in range(n): dp[l][i+1]=min(dp[l][i],a[i]+x*(i+1)) print(sum(map(lambda x:x[-1], dp)))
Traceback (most recent call last): File "/tmp/tmpxg_o3kew/tmp0n0sx7x2.py", line 1, in <module> n,x=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s969365719
p04006
u423585790
1590434975
Python
PyPy3 (2.4.0)
py
Runtime Error
223
41180
268
n,x=map(int,input().split()) A=list(map(int,input().split())) ans=0 m=0 r=0 for l in range(n): a=A[l:]+A[:l] a=a[::-1] tmp=A[l] r=A[r] for i in range(n): if tmp>a[i]+x*(i+1): r=a[i] tmp=a[i]+x*(i+1) m=max(i+1,m) ans+=r print(ans+m*x)
Traceback (most recent call last): File "/tmp/tmpbftx9lwk/tmpkz8e6m8s.py", line 1, in <module> n,x=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s095670006
p04006
u922449550
1589680494
Python
PyPy3 (2.4.0)
py
Runtime Error
178
38640
275
N, x = map(int, input().split()) A = list(map(int, input().split())) min_time = A.copy() ans = 10**15 for t in range(N): time = t*x for i in range(N): j = (i - t) % N min_time[i] = min(min_time[i], A[j]) time += min_time[i] ans = min(ans, time) print(ans)
Traceback (most recent call last): File "/tmp/tmpf2mocvqe/tmph27s1a9j.py", line 1, in <module> N, x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s126596184
p04006
u843135954
1588734074
Python
Python (3.4.3)
py
Runtime Error
19
3188
379
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n,i = na() a = na() dp = [i for i in a] ans = sum(dp) for i in range(1,n): for j in range(n): dp[(j+i)%n] = min(dp[(j+i)%n], a[j]) ans = min(ans, sum(dp)+x*i) print(ans)
Traceback (most recent call last): File "/tmp/tmpjvnsu114/tmpq6iwo2r5.py", line 9, in <module> n,i = na() ^^^ ValueError: not enough values to unpack (expected 2, got 0)
s401760883
p04006
u648212584
1587824867
Python
PyPy3 (2.4.0)
py
Runtime Error
185
39408
387
import sys input = sys.stdin.buffer.readline def main(): N,x = map(int,input().split()) a = list(map(int,input().split())) b = a.copy() ans = 10**15 for i in range(N): time = i*x+sum(b) ans = min(ans,time) for now in range(N): b[now] = min(b[now],a[(now-i-1+N)%N]) print(ans) if __name__ == "__main__": main()
Traceback (most recent call last): File "/tmp/tmpfg6r_ask/tmpws3az7n6.py", line 19, in <module> main() File "/tmp/tmpfg6r_ask/tmpws3az7n6.py", line 5, in main N,x = map(int,input().split()) ^^^ ValueError: not enough values to unpack (expected 2, got 0)
s852204809
p04006
u476604182
1584561583
Python
PyPy3 (2.4.0)
py
Runtime Error
181
38768
254
from itertools import accumulate as acc N, x, *A = map(int, open(0).read().split()) dp = [] for i in range(N): dp.append(list(acc((A[(i-j)%N] for j in range(N)),min))) ans = 10**10 for i,a in enumerate(zip(*dp)): ans = min(ans,i*x+sum(a)) print(ans)
Traceback (most recent call last): File "/tmp/tmply5p26j0/tmplxl5zyj2.py", line 2, in <module> N, x, *A = map(int, open(0).read().split()) ^^^^^^^^ ValueError: not enough values to unpack (expected at least 2, got 0)
s799130764
p04006
u476604182
1584561573
Python
PyPy3 (2.4.0)
py
Runtime Error
181
38256
256
from itertools import accumulate as acc N, x, *A = map(int, open('0').read().split()) dp = [] for i in range(N): dp.append(list(acc((A[(i-j)%N] for j in range(N)),min))) ans = 10**10 for i,a in enumerate(zip(*dp)): ans = min(ans,i*x+sum(a)) print(ans)
Traceback (most recent call last): File "/tmp/tmppi6bjena/tmpzgyb0j_2.py", line 2, in <module> N, x, *A = map(int, open('0').read().split()) ^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '0'
s987488288
p04006
u186838327
1583367013
Python
Python (3.4.3)
py
Runtime Error
18
3192
1789
def segfunc(x, y): return min(x, y) class segment_(): def __init__(self, init_val, n, segfunc): self.ide_ele = 10**9+1 # num: n以上の最小の2のべき乗 self.num = 2**(n-1).bit_length() self.seg = [self.ide_ele]*2*self.num self.segfunc = segfunc # set_val for i in range(n): self.seg[i+self.num-1] = init_val[i] # built for i in range(self.num-2, -1, -1): self.seg[i] = self.segfunc(self.seg[2*i+1], self.seg[2*i+2]) def update(self, k, x): k += self.num - 1 self.seg[k] = x while k: k = (k-1)//2 self.seg[k] = self.segfunc(self.seg[2*k+1], self.seg[2*k+2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q-p>1: if p&1 == 0: res = self.segfunc(res, self.seg[p]) if q&1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p//2 q = (q-1)//2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res def main(): n, x = list(map(int,sys.stdin.readline().split())) A = list(map(int,sys.stdin.readline().split())) seg_ = segment_(A, n, lambda a, b: min(a, b)) ans = 10**18 for k in range(n): t = k*x for i in range(n): if k <= i: t += seg_.query(i-k, i+1) else: t += min(seg_.query(0, i+1), seg_.query(n-(k-i), n)) ans = min(t, ans) print(ans) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmph3nresag/tmpkm5hg9z9.py", line 62, in <module> main() File "/tmp/tmph3nresag/tmpkm5hg9z9.py", line 46, in main n, x = list(map(int,sys.stdin.readline().split())) ^^^ NameError: name 'sys' is not defined
s033913099
p04006
u298297089
1571703959
Python
Python (3.4.3)
py
Runtime Error
1326
3316
384
n,x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 mx = 0 inf = float('INF') for i in range(n): mn = a[i] con = a[i] for j in range(i-n,i+1): idx = (i-j)%n if mn > a[idx] + (i-j) * x: mn = a[idx] + (i-j) * x con = a[idx] if mx < tmp: mx = tmp ans += con print(ans + mx * x)
Traceback (most recent call last): File "/tmp/tmplrkve5ax/tmpbzvtxhe0.py", line 1, in <module> n,x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s813300931
p04006
u623687794
1570654417
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38768
327
n,x=map(int,input().split()) a=list(map(int,input().split())) a*=2 INF=10**15 cost=[INF]*n b=[(c,d) for i in enumerate(a)] b.sort(key=lambda x:x[1]) start=b[0][1] cost[start]=a[start] for i in range(start+1,start+n): cost[i%n]=min(cost[(i-1)%n]+x,cost[i%n]) ans=0 for i in cost: if i==INF:continue ans+=i print(ans)
Traceback (most recent call last): File "/tmp/tmpb4kp5_cs/tmp4mn8oetr.py", line 1, in <module> n,x=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s491888180
p04006
u143509139
1570488561
Python
PyPy3 (2.4.0)
py
Runtime Error
215
40688
239
n, x = map(int, input().split()) a = list(map(int, input().split())) d = a.copy() ans = float('inf') for i in range(n): ans = min(ans, sum(d) + x * i) for j in range(n): d[j] = min(d[j], a[(j - (i + 1) + n) % n]) print(ans)
Traceback (most recent call last): File "/tmp/tmp1eo6fcu6/tmprifg6c2o.py", line 1, in <module> n, x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s403672941
p04006
u532966492
1564980871
Python
Python (3.4.3)
py
Runtime Error
26
3572
625
from copy import deepcopy as dc #n,x=map(int,input().split()) x=int(input()) # a=list(map(int,input().split())) n=len(a) # a=[[i,i,0] for i in a] aa=dc(a) b=[] m=0 while(b!=a): b=dc(a) for _ in range(2): for i in range(n): j=i-1 if j==-1: j=n-1 if a[i][1]!=a[j][1]: if aa[i][0]>=a[j][1]+x or (aa[i][0]>=a[j][1] and a[j][2]<m): a[i][0]=a[j][1]+x a[i][1]=a[j][1] a[i][2]=a[j][2]+1 for i in a: m=max(i[2],m) s=0 s+=m*x for i in a: s+=i[1] print(s) #print(a)
Traceback (most recent call last): File "/tmp/tmp642zlcxh/tmpnd5blk0z.py", line 3, in <module> x=int(input()) # ^^^^^^^ EOFError: EOF when reading a line
s651188657
p04006
u532966492
1564980127
Python
Python (3.4.3)
py
Runtime Error
22
3444
603
from copy import deepcopy as dc #n,x=map(int,input().split()) x=int(input()) # a=list(map(int,input().split())) n=len(a) # a=[[i,i,0] for i in a] b=[] m=0 while(b!=a): b=dc(a) for _ in range(2): for i in range(n): j=i-1 if j==-1: j=n-1 if a[i][1]!=a[j][1]: if a[i][0]>=a[j][1]+x or (a[i][0]>=a[j][1] and a[j][2]<m): a[i][0]=a[j][1]+x a[i][1]=a[j][1] a[i][2]=a[j][2]+1 for i in a: m=max(i[2],m) s=0 s+=m*x for i in a: s+=i[1] print(s)
Traceback (most recent call last): File "/tmp/tmp7n7xz19h/tmpykv6ejsi.py", line 3, in <module> x=int(input()) # ^^^^^^^ EOFError: EOF when reading a line
s861315379
p04006
u623687794
1557517269
Python
Python (3.4.3)
py
Runtime Error
18
2940
104
N,x = int(input().split()) a = sorted(list(map(int,input().split()))) print(min(N*a[0]+(N-1)*x,sum(a)))
Traceback (most recent call last): File "/tmp/tmpgu7x9z_a/tmpc048um9h.py", line 1, in <module> N,x = int(input().split()) ^^^^^^^ EOFError: EOF when reading a line
s533169261
p04006
u095426154
1556331104
Python
Python (3.4.3)
py
Runtime Error
18
3064
532
n,x=map(int,input().split()) a=list(map(int,input().split())) t=[a[i] for i in range(n)] sp_cnt=[0 for i in range(n)] for i in range(1,n): if a[n-i]+i*x<t[0]: t[0]=a[n-i] sp_cnt[0]=i for i in range(1,n): for j in range(n): if i-j>=0: if a[i-j]+j*x<t[i]: t[i]=a[i-j] sp_cnt[i]=j else: if a[n+(i-j)]+j*x<t[i]: t[i]=a[n+(i-j)] sp_cnt[i]=j max_sp_cnt=max(sp_cnt) ans=sum(t)+max_sp_cnt*x print(ans)
File "/tmp/tmpf4c05w24/tmpe1qearlk.py", line 18 t[i]=a[n+(i-j)] ^ IndentationError: expected an indented block after 'if' statement on line 17
s171621829
p04006
u095426154
1556331039
Python
Python (3.4.3)
py
Runtime Error
17
3064
534
n,x=map(int,input().split()) a=list(map(int,input().split())) t=[a[i] for i in range(n)] sp_cnt=[0 for i in range(n)] for i in range(1,n): if a[n-i]+i*x<t[0]: t[0]=a[n-i] sp_cnt[0]=i for i in range(1,n): for j in range(n): if i-j>=0: if a[i-j]+j*x<t[i]: t[i]=a[i-j] sp_cnt[i]=j else: if a[n-(i-j)]+j*x<t[i]: t[i]=a[n-(i-j)] sp_cnt[i]=j max_sp_cnt=max(sp_cnt) ans=sum(t)+max_sp_cnt*x print(ans,t)
File "/tmp/tmpzmi7hp49/tmp4uorqi6r.py", line 18 t[i]=a[n-(i-j)] ^ IndentationError: expected an indented block after 'if' statement on line 17
s170961821
p04006
u095426154
1556329160
Python
Python (3.4.3)
py
Runtime Error
17
2940
459
n,x=map(int,input().split()) a=list(map(int,input().split())) dp=[a[i] for i in range(n)] sp_cnt[0 for i in range(n)] for i in range(1,n): if a[n-i]+i*x<dp[0]: dp[0]=a[n-1]+i*x sp_cnt[0]=i for i in range(1,n): for j in range(i): if a[i-j]+j*x<dp[0]: dp[i]=a[i-j]+j*x sp_cnt[i]=max(sp_cnt[i],j) all_sp_cnt=sum(sp_cnt) max_sp_cnt=max(sp_cnt) ans=sum(dp)-(all_sp_cnt-max_sp_cnt)*x print(ans)
File "/tmp/tmp74e18_sh/tmp90r_3x8m.py", line 4 sp_cnt[0 for i in range(n)] ^^^ SyntaxError: invalid syntax
s887876342
p04006
u069838609
1554690964
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38804
668
import sys fin = sys.stdin.readline N, x = [int(elem) for elem in fin().split()] a_list = [int(elem) for elem in fin().split()] min_cost_for = a_list.copy() this_is_from = list(range(N)) max_num_magics = 0 for i, a in enumerate(a_list): for j, other_a in enumerate(a_list): if i == j: continue num_magics = i - j if j < i else (N - j + i) cost = other_a + num_magics * x if cost < min_cost_for[i]: min_cost_for[i] = cost max_num_magics = max(num_magics, max_num_magics) this_is_from[i] = j total_cost = sum(a_list[origin] for origin in this_is_from) + x * max_num_magics print(total_cost)
Traceback (most recent call last): File "/tmp/tmpsctv4l5b/tmphosvy39q.py", line 5, in <module> N, x = [int(elem) for elem in fin().split()] ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s263694653
p04006
u572144347
1554690779
Python
PyPy3 (2.4.0)
py
Runtime Error
212
39152
278
N,X = map(int, input().split()) A = list(map(int, input().split())) # ans = 10**13 ans = float("inf") for k in range(N): tmp = k * X for i in range(2*N): j = (i-k+N*4) % N A[i] = min(A[i], A[j]) tmp += sum(A) ans = min(ans, tmp) print(ans)
Traceback (most recent call last): File "/tmp/tmpi9zdzft1/tmpfyh_k291.py", line 1, in <module> N,X = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s320733535
p04006
u555962250
1554420281
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38384
289
import numpy as np N, x = map(int, input().split()) a = np.array(list(map(int, input().split()))) min_a = a.copy() ans = 10 ** 18 for i in range(N): s = x * i for j in range(N): min_a[j] = min(min_a[j], a[(i + j) % N]) s += min_a[j] ans = min(ans, s) print(ans)
Traceback (most recent call last): File "/tmp/tmp_h3c9jz7/tmp98nxdqc8.py", line 2, in <module> N, x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s792290457
p04006
u785578220
1552361207
Python
Python (3.4.3)
py
Runtime Error
163
12500
233
import numpy as np N, x = map(int, input().split()) a = np.array(map(int, input().split())) b = np.copy(a) ans = float('inf') for i in range(N): c = np.roll(a,i) b = np.minimum(b,c) ans = min(ans, sum(b)+i*x) print(ans)
Traceback (most recent call last): File "/tmp/tmp5_xnt324/tmpckpdm9dm.py", line 2, in <module> N, x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s582122424
p04006
u785578220
1552361192
Python
PyPy3 (2.4.0)
py
Runtime Error
184
38384
234
import numpy as np N, x = map(int, input().split()) a = np.array(map(int, input().split())) b = np.copy(a) ans = float('inf') for i in range(N): c = np.roll(a,i) b = np.minimum(b,c) ans = min(ans, sum(b)+i*x) print(ans)
Traceback (most recent call last): File "/tmp/tmpj_a3ox9v/tmpwwtttwc7.py", line 3, in <module> N, x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s417303129
p04006
u785578220
1552361023
Python
PyPy3 (2.4.0)
py
Runtime Error
191
39664
248
def inpl(): return [int(i) for i in input().split()] import numpy as np N, x = inpl() a = np.array(inpl()) b = np.copy(a) ans = float('inf') for i in range(N): c = np.roll(a,i) b = np.minimum(b,c) ans = min(ans, sum(b)+i*x) print(ans)
Traceback (most recent call last): File "/tmp/tmpafxuktly/tmpupr8s9wf.py", line 3, in <module> N, x = inpl() ^^^^^^ File "/tmp/tmpafxuktly/tmpupr8s9wf.py", line 1, in inpl def inpl(): return [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s903772612
p04006
u223904637
1551986927
Python
Python (3.4.3)
py
Runtime Error
22
3188
291
n,x=map(int,input().split()) li=list(map(int,input().split())) mi=min(li) ind=-1 for i in range(n): if mi==li[i]: ind=i ans=[0]*n ans[0]=li[ind] k=0 for i in range(1,n): if ind+i>=n: k=ind+i-n else: k=ind+i ans[i]=min(li[k],ans[i-1]+x) print(sun(ans))
Traceback (most recent call last): File "/tmp/tmp_z7pbw1z/tmpp5jvsila.py", line 1, in <module> n,x=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s729309097
p04006
u594567187
1551132421
Python
PyPy3 (2.4.0)
py
Runtime Error
189
39408
353
loop, magic_cost = map(int, input().split(" ")) cost = [n for n in map(int, input().split(" "))] answer = float("inf") min_costs = [float(inf) for n in range(loop)] for i in range(loop): for j in range(loop): min_costs[j] = min(min_costs[j], cost[(i - j) % loop]) answer = min(answer, sum(min_costs) + (magic_cost * (i) ) ) print(answer)
Traceback (most recent call last): File "/tmp/tmpdoyin0x4/tmpkd_tr_63.py", line 1, in <module> loop, magic_cost = map(int, input().split(" ")) ^^^^^^^ EOFError: EOF when reading a line
s864728423
p04006
u427344224
1548368896
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38768
293
N, x = map(int, input().split()) a_list = list(map(int, input().split())) ex_list = a_list.copy() ex_list.extend(a_list) ans = float("inf") for i in range(N): cost = 0 for j in range(N): cost += min(ex_list[N-i+j:N+1+j]) cost += x * i ans = min(ans, cost) print(ans)
Traceback (most recent call last): File "/tmp/tmp5crjjgwl/tmpr3ff03yh.py", line 1, in <module> N, x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s059139194
p04006
u732285858
1531505124
Python
Python (3.4.3)
py
Runtime Error
17
2940
1091
#include <iostream> #include <algorithm> #include <cmath> #include <map> #include <vector> #include <queue> #include <functional> #include <string> #include <stack> #include <set> #include <sstream> #include <iomanip> #include <limits> using namespace std; using ll = long long; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef pair<ll, pair<ll, ll>> PP; const ll MOD = 1e9 + 7; const ll MOD2 = 998244353; const ll INF = 1 << 30; const ll INF2 = 9e18; const double INF3 = 9e14; const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }; const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 }; #define ALL(x) (x).begin(),(x).end() #define pb push_back #define fr first #define sc second int main() { ll n, x, a[2010], ans = 0; vector<ll>v[2010]; cin >> n >> x; for (int i = 0;i < n;i++)cin >> a[i]; for (int i = 0;i < n;i++) { for (int j = 0;j < n;j++) { if (i == j)v[j].pb(a[i]); else v[j].pb(a[i] + x); } } for (int i = 0;i < n;i++) { sort(ALL(v[i])); } for (int i = 0;i < n;i++) { ans += v[i][0]; } cout << ans << endl; return 0; }
File "/tmp/tmpluocx6_9/tmpulr74335.py", line 14 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s519734963
p04006
u582763758
1528567566
Python
Python (3.4.3)
py
Runtime Error
17
2940
626
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mx = 4005; const ll inf = 4e18; ll dp[mx], rdp[mx]; ll a[mx]; ll x; int n; int main(){ ios_base::sync_with_stdio(false);cin.tie(0); cin >> n >> x; for(int i = 0; i < n; i++) cin >> a[i]; copy(a,a+n,a+n); for(int i = 0; i < 2 * n; i++){ dp[i] = min((i ? dp[i-1] : inf) + x, a[i]); } for(int i = 2 * n; i--; ){ rdp[i] = min((i < 2*n-1 ? dp[i+1] : inf) + x, a[i]); } ll ans = 0; for(int i = 0; i < n; i++){ ans += min({dp[i],dp[n+i],rdp[i],rdp[n+i]}); } cout << ans << '\n'; }
File "/tmp/tmpsy0gcgmb/tmpxybsbxpt.py", line 2 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s343344576
p04006
u132291455
1477170022
Python
Python (2.7.6)
py
Runtime Error
18
2812
195
n,x=map(int,raw_input().split(" ")) a=map(int,raw_input().split(" ")) t=[i for i in a] ans=10**10 for m in range(n): t=[min(t[j],a[(j-m)%n]) for j in range(n)] s=min(x*m+sum(t),s) print s
File "/tmp/tmp_611eaeu/tmp01v6zm5u.py", line 8 print s ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s770991907
p04006
u442810826
1473156612
Python
Python (2.7.6)
py
Runtime Error
1931
139240
232
N, x = map(int, raw_input().split()) A = map(int, raw_input().split()) A = A+A b = [[A[i-j]+x*j for i in range(N,2*N)] for j in range(N)] c = [min(bb) for bb in b] d = [bb.index(cc) for cc in c] print sum(c) - x * (sum(d)-max(d))
File "/tmp/tmpcqgn81nv/tmp6j2925z9.py", line 9 print sum(c) - x * (sum(d)-max(d)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s231282511
p04006
u124139453
1473136244
Python
Python (3.4.3)
py
Runtime Error
38
3064
396
n, x = map(int, raw_input().split()) a = map(int, raw_input().split()) ans = 0 b = [] for k in range(n): if k == 0: b = a[:] else: for i in range(n): b[i] = min(a[(i-k)%n],b[i]) cost = k*x+sum(b) if k == 0: ans = cost else: ans = min(ans,cost) if ans != cost: break if ans < (k+1)*x: break print(ans)
Traceback (most recent call last): File "/tmp/tmpy_a0cx84/tmpyxe8oeq1.py", line 1, in <module> n, x = map(int, raw_input().split()) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s299481916
p04006
u124139453
1473135920
Python
Python (2.7.6)
py
Runtime Error
30
2804
399
n, x = map(int, raw_input().split()) a = map(int, raw_input().split()) ans = 0 b = [] for k in range(n): if k == 0: b = a.copy() else: for i in range(n): b[i] = min(a[(i-k)%n],b[i]) cost = k*x+sum(b) if k == 0: ans = cost else: ans = min(ans,cost) if ans != cost: break if ans < (k+1)*x: break print ans
File "/tmp/tmpf625xhhk/tmp9uwz483k.py", line 20 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s499957980
p04006
u124139453
1473134714
Python
Python (2.7.6)
py
Runtime Error
32
2812
193
n, x = map(int, raw_input().split()) a = map(int, raw_input().split()) b = a[:] for k in range(n): for i in range(n): b[i] = min(a[i-k],b[i]) ans = min(ans,k*x+sum(b)) print ans
File "/tmp/tmpxs3nuadm/tmppeg5gw8n.py", line 8 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s906934679
p04006
u601018334
1473129274
Python
Python (3.4.3)
py
Runtime Error
39
3064
412
def solve_(): import itertools N, x = map(int, input().split()) a = list(map(int, input().split())) s_cost = a.copy() cost = sum(s_cost) for k, i in itertools.product(range(1, N), range(N)): s_cost[i] = a[(i - k) % N] if s_cost > a[(i - k) % N] else s_cost[i] if i == N - 1 and cost > k*x + sum(s_cost): cost = k*x + sum(s_cost) print(cost) solve()
Traceback (most recent call last): File "/tmp/tmpuiep9uxi/tmp0q44ok18.py", line 15, in <module> solve() ^^^^^ NameError: name 'solve' is not defined. Did you mean: 'solve_'?
s804922815
p04006
u443010331
1473084208
Python
Python (2.7.6)
py
Runtime Error
31
2820
274
import math N, x = map(int, raw_input().split()) A = map(int, raw_input().split()) ans = 1e18 b = [[ans for i in range(N)]] for k in range(N): sum = k*x for i in range(N): b[i] = min(b[i], A[(i+N-k)%N]) sum += b[i] ans = min(ans, sum) print ans
File "/tmp/tmpgo34y14c/tmpwn8tmxg6.py", line 13 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s029745429
p04006
u601018334
1473069533
Python
Python (3.4.3)
py
Runtime Error
40
3188
290
N, x = list(map(int, input().split())) a = list(map(int, input().split())) s_cost = a cost = sum(s_cost) for k in xrange(0,N): s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(xrange(N)), list(xrange(N-k,N))+list(xrange(N-k)) )] cost = min(cost, k*x + sum(s_cost)) print(cost)
Traceback (most recent call last): File "/tmp/tmpb1rrzffj/tmp1dt8x21u.py", line 1, in <module> N, x = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s755121868
p04006
u601018334
1473059257
Python
Python (3.4.3)
py
Runtime Error
38
3064
444
N, x = list(map(int, input().split())) a = list(map(int, input().split())) min_index = a.index(min(a)) index_list = list(range(min_index,N)) + list(range(min_index)) cost = a.copy() c_count = [0]*N for i in range(1,N): if cost[index_list[i]] => (cost[index_list[i-1]]+x): cost[index_list[i]] = cost[index_list[i-1]]+x c_count[index_list[i]] = c_count[index_list[i-1]]+1 print(sum(cost) - sum(c_count)*x + max(c_count)*x )
File "/tmp/tmp8l9s3xna/tmp6xb44hsx.py", line 8 if cost[index_list[i]] => (cost[index_list[i-1]]+x): ^ SyntaxError: invalid syntax
s464339687
p04006
u226155577
1473043350
Python
Python (2.7.6)
py
Runtime Error
30
2804
561
n, x = map(int, raw_input().split()) A = map(int, raw_input().split())*2 ans = 10**18 for l in xrange(1, n+1): deq = [0]*n s = t = 0 res = 0 for i in xrange(n): while s<t and A[deq[t-1]] >= A[i]: t -= 1 deq[t] = i t += 1 if deq[s] == i-l+1: s += 1 for i in xrange(n, 2*n): while s<t and A[deq[t-1]] >= A[i]: t -= 1 deq[t] = i t += 1 res += A[deq[s]] if deq[s] == i-l+1: s += 1 ans = min(ans, res+x*(l-1)) print ans
File "/tmp/tmpp48j4rlc/tmpkhtn0pvh.py", line 26 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s531836362
p04006
u457552420
1473040040
Python
Python (2.7.6)
py
Runtime Error
27
2568
536
ef cast(curr, num): arr = [(x+num) % N for x in curr] return arr def transform(curr, val): ret = 0 while ((val-ret + N) % N) in curr: ret += 1 return ret N, x = map(int, raw_input().split()) a = map(int, raw_input().split()) curr = [] ans = 0 while len(curr) < N: cost = list(a) t = map(lambda x: transform(curr, x), range(N)) for i in range(N): cost[i] += t[i] * x pick = cost.index(min(cost)) curr = cast(curr, t[pick]) ans += cost[pick] curr.append(pick) print ans
File "/tmp/tmphqui3iyy/tmpn0grn1rt.py", line 1 ef cast(curr, num): ^^^^ SyntaxError: invalid syntax
s475371819
p04007
u785989355
1560153592
Python
Python (3.4.3)
py
Runtime Error
19
3316
770
H,W = list(map(int,input().split())) a = [input() for i in range(H)] b = [[] for i in range(H)] r = [[] for i in range(H)] for i in range(H): for j in range(W): if i==0: b[i].append("#") r[i].append(".") elif i==H-1: b[i].append(".") r[i].append("#") elif S[i][j]=="#": b[i].append(".") r[i].append("#") elif j%2==0: b[i].append(".") r[i].append("#") elif j%2==1: b[i].append("#") r[i].append(".") for i in range(H): ans = "" for j in range(W): ans = ans+b[i][j] print(ans) print("") for i in range(H): ans = "" for j in range(W): ans = ans+r[i][j] print(ans)
Traceback (most recent call last): File "/tmp/tmpsd191cda/tmpke8_7hsx.py", line 2, in <module> H,W = list(map(int,input().split())) ^^^^^^^ EOFError: EOF when reading a line
s572223935
p04007
u091855288
1473104898
Python
Python (2.7.6)
py
Runtime Error
28
2696
679
import numpy as np import copy a = map(int,raw_input().split()) H = a[0] W = a[1] A = [] for idx in xrange(H): A.append( list(raw_input()) ) def textMap(A): A = np.array(A, dtype='S') A[A!='0'] = '#' A[A=='0'] = '.' texts = [] for vec in A: texts.append( ''.join(vec) ) return '\n'.join(texts) def myfunc(H,W,A): A = np.array(A) A[A=='#'] = 1 A[A=='.'] = 0 A = np.array(A, dtype=np.int) T = np.zeros((H,W), dtype=np.int) O = np.zeros((H,W), dtype=np.int) T[:,0] = 1 O[:,-1] = 1 if H%2 == 0: for idx in xrange(H/2): T[idx*2,1:-1] = 1 O[idx*2+1,1:-1] = 1 else: for idx in xrange(H/2): T[idx*2,1:-1] = 1 O[idx
File "/tmp/tmp2x5yjhg0/tmpagxdbi_g.py", line 36 O[idx ^ SyntaxError: '[' was never closed
s494501457
p04008
u794173881
1591232248
Python
PyPy3 (2.4.0)
py
Runtime Error
185
43000
1073
import sys def query(num): # output print("?", num) sys.stdout.flush() # input res = input() return res ans = "" while True: if len(ans) == 0: # 最上位桁のときは1からスタート min_lim = 1 else: min_lim = 0 for char in range(min_lim, 10): tmp = ans + str(char) res = query(tmp) if res == "N": ans += str(char - 1) break else: # 見ている桁が"9"、もしくは最後の桁、もしくは桁が存在しない for char in range(min_lim, 10)[::-1]: if query(ans + str(char) + "0") == "N": ans += str(char + 1) if ans[-1] != "9": # 見ている桁が"9"でないときは必ず最後の桁 # 値が確定 print("!", ans) exit() break else: # 最後の桁が"0"、もしくは桁が存在しない print(re) print("!", ans) exit()
Traceback (most recent call last): File "/tmp/tmpuimaro0v/tmpl717_015.py", line 23, in <module> res = query(tmp) ^^^^^^^^^^ File "/tmp/tmpuimaro0v/tmpl717_015.py", line 10, in query res = input() ^^^^^^^ EOFError: EOF when reading a line
? 1
s296855272
p04008
u423585790
1590165133
Python
PyPy3 (2.4.0)
py
Runtime Error
1064
208616
406
import sys sys.setrecursionlimit(10**6) n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(1,n): edg[a[i]].append(i) ans = [0] * n ans[0] = a[0] != 0 def dfs(now): res = 0 for e in edg[now]: res = max(res, dfs(e)) if res == k - 1 and a[e] != 0 and e != 0: ans[e] = 1 res = 1 return res + 1 dfs(0) print(sum(ans))
Traceback (most recent call last): File "/tmp/tmpxpzothbi/tmp7l9jvusr.py", line 3, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s133781054
p04008
u423585790
1590163943
Python
PyPy3 (2.4.0)
py
Runtime Error
754
183276
413
import sys sys.setrecursionlimit(10**6) n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = [0] * n ans[0] = a[0] != 0 c = [1] * n def dfs(now, rank): c[now] = 0 for e in edg[now]: if c[e]: if rank == k: ans[e] = 1 dfs(e, 1) else: dfs(e, time + 1) dfs(0, 1) print(sum(ans))
Traceback (most recent call last): File "/tmp/tmp7t79uogf/tmp4zws7pxq.py", line 3, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s267170474
p04008
u423585790
1590163470
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38384
410
import sys sys.recursionlimit(10**6) n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = [0] * n ans[0] = a[0] != 0 c = [1] * n def dfs(now, time): c[now] = 0 for e in edg[now]: if c[e]: if time == k: ans[e] = 1 dfs(e, 1) else: dfs(e, time + 1) dfs(0, 0) print(sum(ans))
Traceback (most recent call last): File "/tmp/tmpk73qrpdn/tmp86pur_1u.py", line 2, in <module> sys.recursionlimit(10**6) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'sys' has no attribute 'recursionlimit'. Did you mean: 'getrecursionlimit'?
s672630112
p04008
u423585790
1590163380
Python
PyPy3 (2.4.0)
py
Runtime Error
583
106608
373
n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = [0] * n ans[0] = a[0] != 0 c = [1] * n def dfs(now, time): c[now] = 0 for e in edg[now]: if c[e]: if time == k: ans[e] = 1 dfs(e, 1) else: dfs(e, time + 1) dfs(0, 0) print(sum(ans))
Traceback (most recent call last): File "/tmp/tmpxhdcdevi/tmpozi_q9mc.py", line 1, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s817289383
p04008
u423585790
1590163020
Python
PyPy3 (2.4.0)
py
Runtime Error
564
103920
366
n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = a[0] != 0 c = [1] * n def dfs(now, time): global ans c[now] = 0 for e in edg[now]: if c[e]: if time == k: ans += 1 dfs(e, 1) else: dfs(e, time + 1) dfs(0, 0) print(int(ans))
Traceback (most recent call last): File "/tmp/tmp6qiqviao/tmptfjjow4_.py", line 1, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s692400564
p04008
u423585790
1590162888
Python
PyPy3 (2.4.0)
py
Runtime Error
569
103920
361
n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = a[0] != 0 c = [1] * n def dfs(now, time): global ans c[now] = 0 for e in edg[now]: if c[e]: if time == k: ans += 1 dfs(e, 1) else: dfs(e, time + 1) dfs(0, 0) print(ans)
Traceback (most recent call last): File "/tmp/tmpd0jvynp2/tmp8tked524.py", line 1, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s387298159
p04008
u488401358
1589624994
Python
PyPy3 (2.4.0)
py
Runtime Error
420
86640
512
N,K=map(int,input().split()) a=list(map(int,input().split())) a=[a[i]-1 for i in range(N)] ans=int((a[0]!=0)) a[0]=0 depth=[-1 for i in range(N)] depth[0]=0 def dfs(v): if depth[v]!=-1: return depth[v] depth[v]=dfs(a[v])+1 return depth[v] for i in range(1,N): depth[i]=dfs(i) if K!=1: for i in range(N): if depth[i]%K==1 and depth[i]!=1: ans+=1 print(ans) else: for i in range(N): if depth[i]!=1 and depth[i]!=0: ans+=1 print(ans)
Traceback (most recent call last): File "/tmp/tmp2ccjkm77/tmp9yjy6z2g.py", line 1, in <module> N,K=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s914803608
p04008
u528388170
1586294140
Python
Python (3.4.3)
py
Runtime Error
17
2940
1189
#include<bits/stdc++.h> using namespace std; const int SIZE = 100001; priority_queue<pair<int, int>> D;//pair(depth, id)j int P[SIZE];//parent, depth vector<int> C[SIZE];//children set<int> S; void make_D(int id = 1, int depth = 0){ D.push(make_pair(depth, id)); for (int i = 0; i < C[id].size(); i++){ make_D(C[id][i], depth + 1); } } void add_S(int x){ S.insert(x); for (int i = 0; i < C[x].size(); i++){ add_S(C[x][i]); } } int main(){ int N, K; cin >> N >> K; int ans = 0; for (int i = 1; i <= N; i++){ int ai; cin >> ai; C[ai].push_back(i); P[i] = ai; } if (P[1] != 1){ C[P[1]].erase(C[P[1]].begin()); P[1] = 1; ans++; } else C[1].erase(C[1].begin()); make_D(); while ((!D.empty()) && D.top().first > K) { pair<int, int> p = D.top();D.pop(); if (S.find(p.second) == S.end()){ cout << p.first << " " << p.second << endl; int x = p.second; for (int i = 1; i < K; i++){ x = P[x]; } add_S(x); ans++; } } cout << ans << endl; }
File "/tmp/tmpe6ckrcb3/tmp525h955t.py", line 2 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s828945171
p04008
u638795007
1584759065
Python
Python (3.4.3)
py
Runtime Error
206
23660
3594
def examA(): A, B, C = LI() ans = min(A*B*(C%2),A*C*(B%2),B*C*(A%2)) print(ans) return def examB(): class segment_(): def __init__(self, A, n, segfunc): #####単位元######要設定0or1orinf self.ide_ele = inf #################### self.num = 1 << (n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num self.segfunc = segfunc # set_val for i in range(n): self.seg[i + self.num] = A[i] # built for i in range(self.num - 1, 0, -1): self.seg[i] = self.segfunc(self.seg[2 * i], self.seg[2 * i + 1]) def update(self, k, r): k += self.num self.seg[k] = r while k: k >>= 1 self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1]) # 値xに1加算 def update1(self, k): k += self.num self.seg[k] += 1 while k: k >>= 1 self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1]) def updateneg1(self, k): k += self.num self.seg[k] -= 1 while k: k >>= 1 self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1]) def query(self, p, q): if q < p: return self.ide_ele p += self.num; q += self.num res = self.ide_ele while p < q: if p & 1 == 1: res = self.segfunc(res, self.seg[p]) p += 1 if q & 1 == 1: q -= 1 res = self.segfunc(res, self.seg[q]) p >>= 1; q >>= 1 return res N, x = LI() A = LI() Seg_min = segment_(A, N, lambda a, b: min(a,b)) ans = inf for k in range(N): cur = 0 for j in range(N): if j-k>=0: now = Seg_min.query(j-k,j+1) else: now = min(Seg_min.query(0,j+1),Seg_min.query(N-(k-j),N)) # print(now,k,j) cur += now ans = min(ans,cur+k*x) print(ans) return def examC(): ans = 0 print(ans) return def examD(): N, K = LI() A = LI() V = [[]for _ in range(N)] ans = 0 if A[0]!=1: ans += 1 A[0] = 1 for i in range(1,N): V[A[i]-1].append(i) def dfs(p,s): depth = 0 cnt = 0 for i in V[s]: d,c = dfs(s,i) depth = max(depth,d) cnt += c depth += 1 if depth==K and p!=0: depth = 0 cnt += 1 return depth,cnt _,cnt = dfs(0,0) ans += cnt print(ans) return def examE(): ans = 0 print(ans) return def examF(): ans = 0 print(ans) return import sys,copy,bisect,itertools,heapq,math from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) def LFI(): return list(map(float,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() global mod,mod2,inf,alphabet mod = 10**9 + 7 mod2 = 998244353 inf = 10**18 alphabet = [chr(ord('a') + i) for i in range(26)] if __name__ == '__main__': examD() """ """
Traceback (most recent call last): File "/tmp/tmpwbbq8aou/tmpi1wlp88d.py", line 137, in <module> examD() File "/tmp/tmpwbbq8aou/tmpi1wlp88d.py", line 85, in examD N, K = LI() ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s422784900
p04008
u141610915
1584560794
Python
PyPy3 (2.4.0)
py
Runtime Error
190
38384
4380
import sys from collections import defaultdict as dd from collections import deque as dq input = sys.stdin.readline sys.setrecursionlimimt(10 ** 6) N, K = map(int, input().split()) a = list(map(int, input().split())) if K >= N - 1: print(int(a[0] != 1)) exit(0) res = 0 if a[0] != 1: a[0] = 1 res += 1 e = dd(set) for i in range(N): e[a[i]].add(i + 1) #print(e) Q = dq([1]) d = [float("inf")] * (N + 1) d[1] = 0 while len(Q): p = Q.popleft() for q in e[p]: if d[q] > d[p] + 1: d[q] = d[p] + 1 Q.append(q) #print(d) eulbase = pow(10, 6) euler = [] depth = [0] * (N + 1) table = [0] * (N + 1) def eulerdfs(x, d): global euler global depth global table table[x] = len(euler) depth[x] = d euler.append(d * eulbase + x) for y in e[x]: if x == y: continue eulerdfs(y, d + 1) euler.append(d * eulbase + x) for i in range(len(euler) - 1, -1, -1): table[euler[i] % eulbase] = i eulerdfs(1, 0) #print(euler) #print(table) class minSegTree: def segfunc(self, x, y): return min(x, y) def __init__(self, n, ide_ele, init_val): #####単位元###### self.ide_ele = ide_ele #num:n以上の最小の2のべき乗 self.num = 2 ** (n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num #set_val for i in range(n): self.seg[i + self.num - 1] = init_val[i] #built for i in range(self.num - 2, -1, -1) : self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) def update(self, k, x): k += self.num - 1 self.seg[k] = x while k + 1: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res class maxSegTree: def segfunc(self, x, y): return max(x, y) def __init__(self, n, ide_ele, init_val): #####単位元###### self.ide_ele = ide_ele #num:n以上の最小の2のべき乗 self.num = 2 ** (n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num #set_val for i in range(n): self.seg[i + self.num - 1] = init_val[i] #built for i in range(self.num - 2, -1, -1) : self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) def update(self, k, x): k += self.num - 1 self.seg[k] = x while k + 1: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res euler.pop() minseg = minSegTree(len(euler), N * eulbase, euler) maxseg = maxSegTree(len(euler), 0, euler) #print(euler) ex = dd(list) for i in range(len(euler)): ok = i + 1 ng = len(euler) + 1 while ng - ok > 1: m = (ok + ng) // 2 if (maxseg.query(i, m) // eulbase) - (minseg.query(i, m) // eulbase) <= K: ok = m else: ng = m ex[i].append((ok, 1)) for i in range(len(euler), 0, -1): ex[i].append((i - 1, 0)) #print(ex) import heapq class dijkstra: def __init__(self, n, e): self.e = e self.n = n def path(self, s, t): d = [float("inf")] * (self.n + 1) vis = set() d[s] = 0 h = [s] while not t in vis and len(h): v = heapq.heappop(h) v1 = v % (10 ** 6) v0 = v // (10 ** 6) if v1 in vis: continue vis.add(v1) for p in self.e[v1]: d[p[0]] = min(d[p[0]], d[v1] + p[1]) if p[0] in vis: continue heapq.heappush(h, d[p[0]] * (10 ** 6) + p[0]) return d[t] dij = dijkstra(len(euler), ex) print(dij.path(0, len(euler)) - 1 + res)
Traceback (most recent call last): File "/tmp/tmpv1ic2f31/tmpl2e7eejr.py", line 5, in <module> sys.setrecursionlimimt(10 ** 6) ^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'sys' has no attribute 'setrecursionlimimt'. Did you mean: 'setrecursionlimit'?
s503969334
p04008
u141610915
1584560751
Python
PyPy3 (2.4.0)
py
Runtime Error
1063
139156
4348
import sys from collections import defaultdict as dd from collections import deque as dq input = sys.stdin.readline N, K = map(int, input().split()) a = list(map(int, input().split())) if K >= N - 1: print(int(a[0] != 1)) exit(0) res = 0 if a[0] != 1: a[0] = 1 res += 1 e = dd(set) for i in range(N): e[a[i]].add(i + 1) #print(e) Q = dq([1]) d = [float("inf")] * (N + 1) d[1] = 0 while len(Q): p = Q.popleft() for q in e[p]: if d[q] > d[p] + 1: d[q] = d[p] + 1 Q.append(q) #print(d) eulbase = pow(10, 6) euler = [] depth = [0] * (N + 1) table = [0] * (N + 1) def eulerdfs(x, d): global euler global depth global table table[x] = len(euler) depth[x] = d euler.append(d * eulbase + x) for y in e[x]: if x == y: continue eulerdfs(y, d + 1) euler.append(d * eulbase + x) for i in range(len(euler) - 1, -1, -1): table[euler[i] % eulbase] = i eulerdfs(1, 0) #print(euler) #print(table) class minSegTree: def segfunc(self, x, y): return min(x, y) def __init__(self, n, ide_ele, init_val): #####単位元###### self.ide_ele = ide_ele #num:n以上の最小の2のべき乗 self.num = 2 ** (n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num #set_val for i in range(n): self.seg[i + self.num - 1] = init_val[i] #built for i in range(self.num - 2, -1, -1) : self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) def update(self, k, x): k += self.num - 1 self.seg[k] = x while k + 1: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res class maxSegTree: def segfunc(self, x, y): return max(x, y) def __init__(self, n, ide_ele, init_val): #####単位元###### self.ide_ele = ide_ele #num:n以上の最小の2のべき乗 self.num = 2 ** (n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num #set_val for i in range(n): self.seg[i + self.num - 1] = init_val[i] #built for i in range(self.num - 2, -1, -1) : self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) def update(self, k, x): k += self.num - 1 self.seg[k] = x while k + 1: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res euler.pop() minseg = minSegTree(len(euler), N * eulbase, euler) maxseg = maxSegTree(len(euler), 0, euler) #print(euler) ex = dd(list) for i in range(len(euler)): ok = i + 1 ng = len(euler) + 1 while ng - ok > 1: m = (ok + ng) // 2 if (maxseg.query(i, m) // eulbase) - (minseg.query(i, m) // eulbase) <= K: ok = m else: ng = m ex[i].append((ok, 1)) for i in range(len(euler), 0, -1): ex[i].append((i - 1, 0)) #print(ex) import heapq class dijkstra: def __init__(self, n, e): self.e = e self.n = n def path(self, s, t): d = [float("inf")] * (self.n + 1) vis = set() d[s] = 0 h = [s] while not t in vis and len(h): v = heapq.heappop(h) v1 = v % (10 ** 6) v0 = v // (10 ** 6) if v1 in vis: continue vis.add(v1) for p in self.e[v1]: d[p[0]] = min(d[p[0]], d[v1] + p[1]) if p[0] in vis: continue heapq.heappush(h, d[p[0]] * (10 ** 6) + p[0]) return d[t] dij = dijkstra(len(euler), ex) print(dij.path(0, len(euler)) - 1 + res)
Traceback (most recent call last): File "/tmp/tmpzuoiefaf/tmp9xrpprrd.py", line 5, in <module> N, K = map(int, input().split()) ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s301392105
p04008
u693716675
1583624445
Python
Python (3.4.3)
py
Runtime Error
189
22892
493
#d tree n,k = [int(i) for i in input().split()] a = [int(i)-1 for i in input().split()] #this is directed tree so every node is not reached yet def dfs(u, d): change = 0 if d>k: d = 1 change += 1 for v in edges[u]: if u!=v: change += dfs(v, d+1) return change cnt = 0 if a[0]!=0: a[0] = 0 cnt += 1 edges = [[] for _ in range(n)] for i in range(0,n): pa = a[i] edges[a[i]].append(i) cnt += dfs(0,0) print(cnt)
Traceback (most recent call last): File "/tmp/tmpp8dyksp6/tmpqy30mc2p.py", line 2, in <module> n,k = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s261641075
p04008
u693716675
1583624395
Python
Python (3.4.3)
py
Runtime Error
186
22896
510
#d tree n,k = [int(i) for i in input().split()] a = [int(i)-1 for i in input().split()] #this is directed tree so every node is not reached yet def dfs(u, d): change = 0 if d>k: d = 1 change += 1 for v in edges[u]: if u==v: continue change += dfs(v, d+1) return change cnt = 0 if a[0]!=0: a[0] = 0 cnt += 1 edges = [[] for _ in range(n)] for i in range(0,n): pa = a[i] edges[a[i]].append(i) cnt += dfs(0,0) print(cnt)
Traceback (most recent call last): File "/tmp/tmpkxl_f8pv/tmpndez2dsm.py", line 2, in <module> n,k = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s245349810
p04008
u693716675
1583624173
Python
Python (3.4.3)
py
Runtime Error
184
22896
459
#d tree n,k = [int(i) for i in input().split()] a = [int(i)-1 for i in input().split()] #this is directed tree so every node is not reached yet def dfs(u, d): change = 0 if d>k: d = 1 change += 1 for v in edges[u]: change += dfs(v, d+1) return change cnt = 0 if a[0]!=0: cnt += 1 edges = [[] for _ in range(n)] for i in range(1,n): pa = a[i] edges[a[i]].append(i) cnt += dfs(0,0) print(cnt)
Traceback (most recent call last): File "/tmp/tmps0d2mh24/tmpe4_66rv1.py", line 2, in <module> n,k = [int(i) for i in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s670454131
p04008
u310678820
1572400112
Python
PyPy3 (2.4.0)
py
Runtime Error
422
83948
2346
class BIT: def __init__(self, n): self.N = n self.n = 1<<n.bit_length() self.data = [0] * (self.n + 1) self.num = 0#要素の個数(multisetの代用として使う場合のみ) def sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add(self, i, x): while i <= self.n: self.data[i] += x i += i & -i self.num+=x def search(self, value): if value<1: return 0 if value >self.num: return self.N+1 x,sx = 0,0#x:現在の位置, sx:1~xまでの和 step = self.n#ステップ幅.2^i while step: y = x+step sy = sx+self.data[y]#今のステップ幅で試す if sy < value:#目標より小さければx,sxを更新 x,sx = y,sy step >>= 1#ステップ幅を半分にする return x+1 def show(self): res = [] a = 0 for i in range(1, self.N+1): b = self.sum(i) if b<a: print('error') return for _ in range(a, b): res.append(i) a = b print(res) from collections import deque N, K = map(int, input().split()) a = list(map(lambda x:int(x)-1, input().split())) G = [[] for _ in range(N)] for i in range(1, N): G[a[i]].append(i) depth = [0]*N que = deque([0]) depth_to_index = [[] for _ in range(N)] depth_to_index[0].append(0) B = BIT(N) while que: v = que.pop() d = depth[v] for nv in G[v]: depth[nv] = d+1 depth_to_index[d+1].append(nv) que.append(nv) B.add(d+1, 1) if a[0] == 0: ans = 0 else: if K%(depth[a[0]]+1) == 0: ans = 0 else: ans = 1 s = set(list(range(1, N))) for i in range(N): n = B.num d = B.search(n) if d<=K: break ans+=1 v = depth_to_index[d].pop() B.add(depth[v], -1) s.remove(v) h = 1 while h<K: v = a[v] h+=1 que = deque([v]) while que: vv = que.pop() B.add(depth[vv], -1) s.remove(vv) for nv in G[vv]: if nv not in s: continue que.append(nv) print(ans)
Traceback (most recent call last): File "/tmp/tmp8j4_nxy7/tmpiyu5sv9l.py", line 46, in <module> N, K = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s145677221
p04008
u102461423
1569053874
Python
Python (3.4.3)
py
Runtime Error
577
60900
1125
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 7) N,K = map(int,readline().split()) A = [int(x)-1 for x in readline().split()] desc_edge = [set() for _ in range(N)] parent = [0] * N for i,x in enumerate(A[1:],1): # 根から葉に向かう向きに辺を持つ desc_edge[x].add(i) parent[i]=x depth = [None] * N q = [0] depth[0]=0 while q: x = q.pop() for y in desc_edge[x]: q.append(y) depth[y] = depth[x]+1 V = set(range(N)) q=[] depth_to_v = [[] for _ in range(N)] for v,x in enumerate(depth): depth_to_v[x].append(v) for d in range(N): q += depth_to_v[d] answer = 0 while q: x = q.pop() if x == 0: break if x not in V: continue if depth[x] <= K: break answer += 1 for _ in range(K-1): y = parent[y] # yの転送先を0に変更する、yの部分木は捨てる qq = [y] while qq: z = qq.pop() V.remove(z) for w in desc_edge[z]: if w in V: qq.append(w) if A[0] != 0: answer += 1 print(answer)
Traceback (most recent call last): File "/tmp/tmp6m4c37lo/tmpsqnnefs_.py", line 6, in <module> N,K = map(int,readline().split()) ^^^ ValueError: not enough values to unpack (expected 2, got 0)
s356756873
p04008
u229621546
1555374201
Python
Python (3.4.3)
py
Runtime Error
190
22904
344
N,M = map(int,input().split()) L = list(map(int,input().split())) l = [[] for i in range(N)] ans = 0 if L[0] == 1 else 1 L[0] = 0 for i in range(1,len(L)): l[L[i] - 1].append(i) def search(ind,a): global ans if a > M: ans += 1 a = 0 if len(l[ind]) == 0: return for i in l[ind]: search(i,a+1) search(0,0) print(ans)
Traceback (most recent call last): File "/tmp/tmpdutlt2a6/tmpr9e2oxu1.py", line 1, in <module> N,M = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s226688517
p04008
u316386814
1553370889
Python
Python (3.4.3)
py
Runtime Error
596
143468
899
import sys sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(sys.stdin.readline()) def SI(): return input() from collections import defaultdict def main(): N, K = LI() A = LI_() edges = defaultdict(list) for i, a in enumerate(A[1:], 1): edges[a].append(i) ans = 0 if A[0] != 0: ans += 1 def DFS(v, parent): global ans height = 0 for to in edges[v]: height = max(height, DFS(to, v) + 1) if parent != 0 and height > K - 1: height = 0 ans += 1 return height DFS(0, 0) return ans print(main())
Traceback (most recent call last): File "/tmp/tmpjsry6nbc/tmp5jed2tw3.py", line 36, in <module> print(main()) ^^^^^^ File "/tmp/tmpjsry6nbc/tmp5jed2tw3.py", line 15, in main N, K = LI() ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s558774156
p04008
u745087332
1551860939
Python
Python (3.4.3)
py
Runtime Error
277
29216
1197
# coding:utf-8 import sys from collections import defaultdict, deque INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(sys.stdin.readline()) def SI(): return input() def main(): n, k = LI() A = LI_() D = defaultdict(list) for i in range(1, n): D[A[i]].append(i) q = deque([(0, 0)]) # 首都は必ず自己ループでなければならない global res res = 0 if A[0] == 0 else 1 def DFS(v, par): global res h = 0 for to in D[v]: # print('dfs {} -> {}'.format(v+1, to+1)) # h: 葉からの距離の最大値 h = max(h, DFS(to, v)) # 根が首都ではなく,高さがk - 1の場合は首都につなぎ直す if h == k - 1 and par != 0: res += 1 h = -1 # print('Finish {} <- {}'.format(par+1, v+1)) return h + 1 DFS(0, 0) return res print(main())
Traceback (most recent call last): File "/tmp/tmp_90fjmeb/tmpxdl8w0gs.py", line 51, in <module> print(main()) ^^^^^^ File "/tmp/tmp_90fjmeb/tmpxdl8w0gs.py", line 19, in main n, k = LI() ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s338050014
p04008
u884982181
1543722795
Python
PyPy3 (2.4.0)
py
Runtime Error
1069
206372
670
import sys sys.setrecursionlimit(200000) n,k = map(int,input().split()) a = list(map(int,input().split())) ans = 0 if a[0] != 1: a[0] = 1 ans += 1 b = [[]for i in range(n)] for i in range(n): b[a[i]-1].append(i) b[0].remove(0) huka = 0 kyo = [float("inf")] * n def dfs(x,y): kyo[x] = y for i in b[x]: dfs(i,y+1) dfs(0,0) def dfs2(x,y): if kyo[x] == 0: return if y == k-1 and x != 0: kyo[x] = 0 global ans ans += 1 return kyo[x] = 0 dfs2(a[x],y+1) hukai = [] for i in range(n): hukai.append([kyo[i],i]) hukai.sort() huka = [] for i in range(n): huka.append(hukai[i][1]) huka = huka[::-1] for i in huka: dfs2(i,0) print(ans)
Traceback (most recent call last): File "/tmp/tmpgg9783m9/tmp4y283hzy.py", line 3, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s469457677
p04008
u884982181
1543720565
Python
PyPy3 (2.4.0)
py
Runtime Error
556
103024
391
n,k = map(int,input().split()) a = list(map(int,input().split())) ans = 0 if a[0] != 1: a[0] = 1 ans += 1 b = [[]for i in range(n)] for i in range(n): b[a[i]-1].append(i) b[0].remove(0) kyo = [float("inf")] * n def dfs(x,y,z): if y>k and z == 0: y= 0 z = 1 if y > k-1 and z == 1: y = 0 kyo[x] = y for i in b[x]: dfs(i,y+1,z) dfs(0,0,0) print(kyo.count(0)-1+ans)
Traceback (most recent call last): File "/tmp/tmpyjlr7yne/tmp7usi6zwf.py", line 1, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s048039210
p04011
u910358825
1601287319
Python
Python (3.8.2)
py
Runtime Error
23
8968
93
n,k,x,y=[int(input()) for i in range(n)] if k<=x: print(n*k) else: print(k*x+(n-k)*y)
Traceback (most recent call last): File "/tmp/tmp9ghirf2n/tmp_3_7isbb.py", line 1, in <module> n,k,x,y=[int(input()) for i in range(n)] ^ NameError: name 'n' is not defined
s629893841
p04011
u401183062
1601226552
Python
Python (3.8.2)
py
Runtime Error
23
8940
182
n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special
File "/tmp/tmpjfylg0ha/tmpj9qv4can.py", line 1 n, k, price, special = map(int, input().split()) IndentationError: unexpected indent
s292877404
p04011
u401183062
1601226494
Python
Python (3.8.2)
py
Runtime Error
27
9000
205
n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special print(result)
File "/tmp/tmp7yq5hdsi/tmpgpsnpjrg.py", line 1 n, k, price, special = map(int, input().split()) IndentationError: unexpected indent
s028146518
p04011
u401183062
1601226450
Python
Python (3.8.2)
py
Runtime Error
25
9064
271
def iroha(): n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special print(result) if __name__ == "__main__": iroha()
Traceback (most recent call last): File "/tmp/tmp3wodfu25/tmpgriu45ba.py", line 14, in <module> iroha() File "/tmp/tmp3wodfu25/tmpgriu45ba.py", line 2, in iroha n, k, price, special = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s736676162
p04011
u401183062
1601226308
Python
Python (3.8.2)
py
Runtime Error
24
9080
269
def iroha(): n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special print(result) if __name__ == "__main__": iroha()
Traceback (most recent call last): File "/tmp/tmpiesrjm3o/tmpr0k4bpsx.py", line 14, in <module> iroha() File "/tmp/tmpiesrjm3o/tmpr0k4bpsx.py", line 2, in iroha n, k, price, special = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s915700251
p04011
u401183062
1601226264
Python
Python (3.8.2)
py
Runtime Error
25
8944
199
n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special print(result)
File "/tmp/tmpiryppwdx/tmpdilh0c8b.py", line 2 result = 0 IndentationError: unexpected indent
s437177764
p04011
u847033024
1599987880
Python
Python (3.8.2)
py
Runtime Error
23
8956
145
a = int(input()) b = int(input()) c = int(input()) d = int(input()) x = a - b y = b * c z = x * d if a > b: print(y + z) else: print(y)
File "/tmp/tmp123a6c60/tmpta1fejs3.py", line 5 x = a - b IndentationError: unexpected indent
s629950488
p04011
u231198419
1599333978
Python
Python (3.8.2)
py
Runtime Error
26
8800
89
N,K,X,Y=[int(input()) for i in range(4)] if(K>N): N=K else: Z=K*X+(N-K)*Y print(Z)
File "/tmp/tmpv3_30xq1/tmpohkuux_h.py", line 8 Z=K*X+(N-K)*Y ^ IndentationError: expected an indented block after 'else' statement on line 5
s608595389
p04011
u546132222
1599101840
Python
Python (3.8.2)
py
Runtime Error
28
9160
340
# abc044_a # https://atcoder.jp/contests/abc044/tasks/abc044_a # 最初のK泊までは、X円 # K+1泊目以降は、Y円 # N泊連続で宿泊した際の宿泊費 # 入力 n, k, x, y = map(int, input().split()) # 処理 # x円とy円 if n > k: answer = k * x + (n - k) * y # x円のみ else: answer = n * x print(answer)
Traceback (most recent call last): File "/tmp/tmp6g5ealgo/tmp51gobdnc.py", line 10, in <module> n, k, x, y = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s493889273
p04011
u147912476
1598621439
Python
Python (3.8.2)
py
Runtime Error
22
9032
141
k, x, y, n = map(int, input().split()) if n <= k: print(n * x) else: print(k*x+(n-k)*y) # 演算子の左右に空白を入れる!
Traceback (most recent call last): File "/tmp/tmprrtyuebn/tmp791pv_26.py", line 1, in <module> k, x, y, n = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s806870973
p04011
u668271522
1598589442
Python
Python (3.8.2)
py
Runtime Error
24
9096
85
N,K,X,Y= map(int, input().split()) yen1 = K * X yen2 = (N - K) * Y print(yen1 + yen2)
Traceback (most recent call last): File "/tmp/tmpiwmp18hr/tmpby2xxjo6.py", line 1, in <module> N,K,X,Y= map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s381321669
p04011
u003505857
1598532614
Python
Python (3.8.2)
py
Runtime Error
27
9020
120
N, K, X, Y = map(int, input().split()) a = N * X b = K * X + (N - K) * Y if N <= K: print(a) else: print(b)
Traceback (most recent call last): File "/tmp/tmpf5k6ih1n/tmpxy0ye4rc.py", line 3, in <module> N, K, X, Y = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s055856568
p04011
u003505857
1598532518
Python
Python (3.8.2)
py
Runtime Error
27
9148
118
N, K, X, Y = map(int, input().split()) a = N * X b = K * X + (N - K) * Y if N < K: print(a) else: print(b)
Traceback (most recent call last): File "/tmp/tmp6k_lu95v/tmpzfycilf1.py", line 2, in <module> N, K, X, Y = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s536662385
p04011
u808569469
1598404118
Python
Python (3.8.2)
py
Runtime Error
25
9084
104
N, K, X, Y = map(int, input().split()) if N <= K: print(N * X) else: print(K * X + (N - K) * Y)
Traceback (most recent call last): File "/tmp/tmpt6u5g07p/tmp578sumzm.py", line 1, in <module> N, K, X, Y = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s174070998
p04011
u808569469
1598403962
Python
Python (3.8.2)
py
Runtime Error
24
8960
104
n, k, x, y = map(int, input().split()) if n <= k: print(n * x) else: print(k * x + (n - k) * y)
Traceback (most recent call last): File "/tmp/tmpcxh_2lcr/tmpi7z1d8g0.py", line 1, in <module> n, k, x, y = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s788929143
p04011
u808569469
1598403416
Python
Python (3.8.2)
py
Runtime Error
26
9160
110
n, k, x, y = map(int, input().split()) if n <= k: print(n * x) else: print(k * x + (n - k) * y)
Traceback (most recent call last): File "/tmp/tmpufn2pd3i/tmpf0a9f5nj.py", line 1, in <module> n, k, x, y = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s601660667
p04011
u808569469
1598402843
Python
Python (3.8.2)
py
Runtime Error
23
9060
105
n, k, x, y = map(int, input().split()) if n <= k: print(k * x) else: print(k * x + (n - k) * y)
Traceback (most recent call last): File "/tmp/tmpl1vx4tah/tmpam8nvt0a.py", line 1, in <module> n, k, x, y = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s229333446
p04011
u003505857
1598365512
Python
Python (3.8.2)
py
Runtime Error
26
9156
107
N, K, X, Y, = map(int, input().split()) if N <= K: print(N * X) else: print(K * X + (N - K) * Y)
Traceback (most recent call last): File "/tmp/tmppe8f_t9b/tmp4obfrp7t.py", line 1, in <module> N, K, X, Y, = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s242513630
p04011
u003505857
1598365369
Python
Python (3.8.2)
py
Runtime Error
27
9148
148
N, K, X, Y, = map(int, input().split()) if N <= K: answer = N * X print(answer) else: answer = K * X + (N - K) * Y print(answer)
Traceback (most recent call last): File "/tmp/tmpkhsy669q/tmpmige5sme.py", line 1, in <module> N, K, X, Y, = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line