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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s251990454 | p02357 | u279605379 | 1504749455 | Python | Python3 | py | Runtime Error | 0 | 0 | 519 | [N,L] = [int(x) for x in input().split()]
A = dict
ANS = [10**9+1]*N
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
try : A[x] += [i]
except KeyError : A[x] = [i]
for i in set(A) :
for j in A[i] :
for k in range(L) :
try :
if ANS[j+k] == 10**9+1 :
ANS[j+k] = i
count += 1
except IndexError : continue
if count == N : break
for i in ANS[L-1:-1]:
print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpqb_ar8ld/tmpcfgeopx8.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s290253862 | p02357 | u279605379 | 1504749525 | Python | Python3 | py | Runtime Error | 0 | 0 | 526 | [N,L] = [int(x) for x in input().split()]
A = {10**9+1:1}
ANS = [10**9+1]*N
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
try : A[x] += [i]
except KeyError : A[x] = [i]
for i in set(A) :
for j in A[i] :
for k in range(L) :
try :
if ANS[j+k] == 10**9+1 :
ANS[j+k] = i
count += 1
except IndexError : continue
if count == N : break
for i in ANS[L-1:-1]:
print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpzx8o8rx9/tmplngr74i2.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s853937533 | p02357 | u279605379 | 1504749584 | Python | Python3 | py | Runtime Error | 0 | 0 | 530 | [N,L] = [int(x) for x in input().split()]
A = {10**9+1:1}
ANS = [10**9+1]*N
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
try : A[x] += [i]
except KeyError : A[x] = [i]
for i in set(A) :
for j in A[i] :
for k in range(L) :
try :
if ANS[j+k] == 10**9+1 :
ANS[j+k] = i
count += 1
except IndexError : continue
if count == N : break
for i in ANS[L-1:-1]:
print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpa2367w27/tmprtus8f_l.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s668354891 | p02357 | u279605379 | 1504751770 | Python | Python3 | py | Runtime Error | 20 | 7736 | 434 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count >= N : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N]) | Traceback (most recent call last):
File "/tmp/tmplr2uj55s/tmpvuo79v2e.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s176012696 | p02357 | u279605379 | 1504752052 | Python | Python3 | py | Runtime Error | 0 | 0 | 537 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N + 2 : break
if L = 1 :
for i in range(L-1,N-2) : print(ANS[i], end=" ")
print(ANS[N-1])
else :
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N]) | File "/tmp/tmpvpvktvym/tmpq5vwsnh5.py", line 18
if L = 1 :
^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
| |
s979665134 | p02357 | u279605379 | 1504752118 | Python | Python3 | py | Runtime Error | 60 | 7812 | 540 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N + 2 : break
if L == 1 :
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])
else :
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmpfa03r5ju/tmp0gjhgpp9.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s169023592 | p02357 | u279605379 | 1504752140 | Python | Python3 | py | Runtime Error | 50 | 7800 | 439 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N + 2 : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmpwz1fo1um/tmp3n2g5r3p.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s475732251 | p02357 | u279605379 | 1504752245 | Python | Python3 | py | Runtime Error | 20 | 7724 | 436 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count >= N : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmp_95l2wsd/tmp_x6i91e2.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s160569516 | p02357 | u279605379 | 1504752256 | Python | Python3 | py | Runtime Error | 20 | 7812 | 439 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N + 2 : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmp_w0wxklc/tmp25ij9e39.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s286450965 | p02357 | u279605379 | 1504752262 | Python | Python3 | py | Runtime Error | 40 | 9276 | 440 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N + 10 : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmp6oo_drnn/tmpd9jz0biu.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s921818781 | p02357 | u279605379 | 1504752270 | Python | Python3 | py | Runtime Error | 60 | 9340 | 440 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N + 30 : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmp23jiq817/tmp2nwkat_1.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s711207582 | p02357 | u279605379 | 1504752935 | Python | Python3 | py | Runtime Error | 0 | 0 | 449 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS && j + k < N:
ANS[j+k] = i
count += 1
if count == N : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | File "/tmp/tmpvhbph4pb/tmp7ic4wr_7.py", line 13
if j + k not in ANS && j + k < N:
^
SyntaxError: invalid syntax
| |
s219791767 | p02357 | u279605379 | 1504752954 | Python | Python3 | py | Runtime Error | 0 | 0 | 448 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS && j + k < N:
ANS[j+k] = i
count += 1
if count > N : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | File "/tmp/tmpdcr8_0oy/tmpe74t8jch.py", line 13
if j + k not in ANS && j + k < N:
^
SyntaxError: invalid syntax
| |
s468278262 | p02357 | u279605379 | 1504752970 | Python | Python3 | py | Runtime Error | 0 | 0 | 452 | [N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS && j + k < N:
ANS[j+k] = i
count += 1
if count > N + 1 : break
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | File "/tmp/tmpj_u8wiyj/tmpnbftb45b.py", line 13
if j + k not in ANS && j + k < N:
^
SyntaxError: invalid syntax
| |
s563603577 | p02357 | u279605379 | 1504757494 | Python | Python3 | py | Runtime Error | 20 | 7736 | 553 | [N,L] = [int(x) for x in input().split()]
A = {}
B = [True]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
B[i] = x
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if (N-count)**2 < N : break
for i in range(N):
if i not in ANS:
ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmpbsxdxgel/tmpsjmeeng9.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s458114600 | p02357 | u279605379 | 1504757584 | Python | Python3 | py | Runtime Error | 30 | 7748 | 624 | [N,L] = [int(x) for x in input().split()]
A = {}
B = [True]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
B[i] = x
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if (N-count)**2 < N : break
for i in range(N):
if i not in ANS:
try :
ANS[i] = min(B[i+1-L:i+1])
except IndexError :
ANS[i] = min(B[:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmps_4e5czr/tmpakrdrilk.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s288742332 | p02357 | u279605379 | 1504758591 | Python | Python3 | py | Runtime Error | 0 | 0 | 636 | from collections import deque
[N,L] = [int(x) for x in input().split()]
A = {}
B = deque([])
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
B.append(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if (N-count)**2 < N : break
for i in range(L):
if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmpnh9m5oyp/tmpfqgncac3.py", line 2, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s845383789 | p02357 | u279605379 | 1504760095 | Python | Python3 | py | Runtime Error | 0 | 0 | 626 | [N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
B[i] = x
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count + L*0.5 > N : break
for i in range(L):
if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
if i not in ANS : ANS[i] = min(B[i+1-L:ijavascript:void(0)+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmp8qlg60_4/tmpvfzf6gx3.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s250757320 | p02357 | u279605379 | 1504765482 | Python | Python3 | py | Runtime Error | 30 | 7948 | 957 | def SME(Part,L):
A = {}
B = []
ANS = {}
count = 0
N = len(Part)
for i,x in enumerate(Part):
B.append(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N * 0.99 : break
for i in range(L):
if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = {}
M = int(N**0.3)
K = N//M
for i in range(M):
if i == 0:
ANS.update(SME(Whole[:K], L))
elif i == M-1:
ANS.update(SME(Whole[i*K-L+1:], L))
else:
ANS.update(SME(Whole[i*K-L+1:K-L+1+K], L))
for i in range(L-1,N-1) :print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmpntu5ylc5/tmprjxsw8rg.py", line 25, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s863096895 | p02357 | u279605379 | 1504765547 | Python | Python3 | py | Runtime Error | 40 | 7820 | 957 | def SME(Part,L):
A = {}
B = []
ANS = {}
count = 0
N = len(Part)
for i,x in enumerate(Part):
B.append(x)
if x in A : A[x] += [i]
else : A[x] = [i]
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N * 0.99 : break
for i in range(L):
if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = {}
M = int(N**0.3)
K = N//M
for i in range(M):
if i == 0:
ANS.update(SME(Whole[:K], L))
elif i == M-1:
ANS.update(SME(Whole[i*K-L+1:], L))
else:
ANS.update(SME(Whole[i*K-L+1:K-L+1+K], L))
for i in range(L-1,N-1) :print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmpzp87xc5q/tmpl6g0h9k6.py", line 25, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s686948267 | p02357 | u279605379 | 1504767005 | Python | Python3 | py | Runtime Error | 80 | 9252 | 616 | import heapq
[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
heapq.heapify(A)
ANS = [10**9+1]*N
count = 0
for j in range(N):
a = heapq.heappop(A)
for i in range(L):
try :
if ANS[a[1]+i] == 10**9+1 :
ANS[a[1]+i] = a[0]
count += 1
except IndexError : continue
if count + 1000 == N : break
for i in range(L):
if ANS[i] == 10**9+1 : ANS[i] = min(B[:i+1])
for i in range(L,N):
if ANS[i] == 10**9+1 : ANS[i] = min(B[i+1-L:i+1])
for i in ANS[L-1:-1]:
print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpss1hvcwr/tmp3blpmllw.py", line 2, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s604482364 | p02357 | u279605379 | 1504767031 | Python | Python3 | py | Runtime Error | 0 | 0 | 615 | import heapq
[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
heapq.heapify(A)
ANS = [10**9+1]*N
count = 0
for j in range(N):
a = heapq.heappop(A)
for i in range(L):
try :
if ANS[a[1]+i] == 10**9+1 :
ANS[a[1]+i] = a[0]
count += 1
except IndexError : continue
if count + 1000 > N : break
for i in range(L):
if ANS[i] == 10**9+1 : ANS[i] = min(B[:i+1])
for i in range(L,N):
if ANS[i] == 10**9+1 : ANS[i] = min(B[i+1-L:i+1])
for i in ANS[L-1:-1]:
print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpnns4eitt/tmpiij1678y.py", line 2, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s558308068 | p02357 | u279605379 | 1504771836 | Python | Python3 | py | Runtime Error | 0 | 0 | 942 | import heapq
def SME(Whole,start,end,L,ANS):
A = []
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] == 0 and idx <= end:
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * 0.99 : break
for i in range(L):
if ANS[i] == 0 : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] == 0 : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ANS = [0]*N
start = 0
K = L * 2
if K > N : K = N
end = K
while (end <= N):
ANS = SME(A, i*M, i*M+K, L, ANS)
start = end
end += K
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmp0xtv9l0z/tmp1oyfdqcu.py", line 24, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s560856122 | p02357 | u279605379 | 1504774506 | Python | Python3 | py | Runtime Error | 0 | 0 | 877 | import heapq
def SME(start,end):
A = []
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] == 0:
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] == 0 : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] == 0 : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
if N = 10**5 :
parameter = 0.9999
else :
parameter = 0.995
ANS = [0]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | File "/tmp/tmpm4kr7dou/tmpb81q_a8s.py", line 26
if N = 10**5 :
^^^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
| |
s714428925 | p02357 | u279605379 | 1504824125 | Python | Python3 | py | Runtime Error | 0 | 0 | 906 | import heapq
def SME(start,end):
A = []
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if sum(ANS[a[1]:a[1]+L]) < (a[0]-1)*(L-1) + MAX + 1
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] == MAX:
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] == 0 : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] == 0 : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
parameter = 0.995
MAX = 10**9+1
ANS = [MAX]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | File "/tmp/tmpqez3ftna/tmpeq9t9fzi.py", line 10
if sum(ANS[a[1]:a[1]+L]) < (a[0]-1)*(L-1) + MAX + 1
^
SyntaxError: expected ':'
| |
s448481201 | p02357 | u279605379 | 1504832893 | Python | Python3 | py | Runtime Error | 0 | 0 | 964 | from functools import reduce
import operator
import heapq
def SME(start,end):
A = []
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if reduce(operator.mul,A[a[1]:a[1]+L])!=0 : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] == INIT:
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] == INIT : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] == INIT : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
parameter = 0.995
INIT = 0
ANS = [INIT]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpmoxk0_m2/tmpzjaw2sj6.py", line 28, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s280811877 | p02357 | u279605379 | 1504838641 | Python | Python3 | py | Runtime Error | 0 | 0 | 964 | import heapq
def SME(Whole,start,end,L,ANS):
A = []
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] == 0 and idx < end:
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * 0.999 / M : break
for i in range(L):
if ANS[i] == 0 : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] == 0 : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ANS = [0]*N
start = 0
K = L * int(N ** 0.3 + 2 )
if K > N : K = N
end = K
while (end <= N):
ANS = SME(A, start, end, L, ANS)
start = end
end += K
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpuhz59ypi/tmp57pl4h50.py", line 24, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s741029774 | p02357 | u279605379 | 1504846855 | Python | Python3 | py | Runtime Error | 0 | 0 | 982 | #??????????????????
import heapq
def SME(start,end):
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
D.Add(idx)
count += 1
except IndexError : continue
if count > N * parameter : break
for i in C.difference(D):
if i < L:
ANS[i] = min(Whole[:i+1])
else :
ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
C = set([i for i in range(N)])
D = {}
parameter = 0.99
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpaqun2trj/tmpby8nndt9.py", line 27, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s207971184 | p02357 | u279605379 | 1504846878 | Python | Python3 | py | Runtime Error | 0 | 0 | 982 | #??????????????????
import heapq
def SME(start,end):
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
D.Add(idx)
count += 1
except IndexError : continue
if count > N * parameter : break
for i in C.difference(D):
if i < L:
ANS[i] = min(Whole[:i+1])
else :
ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
C = set([i for i in range(N)])
D = {}
parameter = 0.99
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpmvvqwl34/tmpxrzxir4k.py", line 27, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s189389613 | p02357 | u279605379 | 1504848196 | Python | Python3 | py | Runtime Error | 0 | 0 | 606 | [N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
B[i] = x
if x in A : A[x] += [i]
else : A[x] = [i]
for i in range(10**9) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N * 0.99 - 1 : break
for i in range(L):
if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmpzicqjma0/tmp_g9ih6g_.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s412471421 | p02357 | u279605379 | 1504849023 | Python | Python3 | py | Runtime Error | 0 | 0 | 1019 | #??????????????????
import heapq
def SME():
start = 0
parameter = 0.99
ANS = [None]*N
[end,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
C = set([i for i in range(N)])
D = set([])
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
D.add(idx)
count += 1
except IndexError : continue
if count > N * parameter : break
for i in C.difference(D):
if i < L:
ANS[i] = min(Whole[:i+1])
else :
ANS[i] = min(Whole[i+1-L:i+1])
return ANS
ANS = SME()
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmp_yygfwts/tmpdi1my52s.py", line 36, in <module>
ANS = SME()
^^^^^
File "/tmp/tmp_yygfwts/tmpdi1my52s.py", line 6, in SME
ANS = [None]*N
^
NameError: name 'N' is not defined
| |
s832753605 | p02357 | u279605379 | 1504849039 | Python | Python3 | py | Runtime Error | 0 | 0 | 999 | import heapq
def SME():
start = 0
parameter = 0.99
ANS = [None]*N
[end,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
C = set([i for i in range(N)])
D = set([])
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
D.add(idx)
count += 1
except IndexError : continue
if count > N * parameter : break
for i in C.difference(D):
if i < L:
ANS[i] = min(Whole[:i+1])
else :
ANS[i] = min(Whole[i+1-L:i+1])
return ANS
ANS = SME()
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpt2aywgo9/tmpzb55_dj5.py", line 35, in <module>
ANS = SME()
^^^^^
File "/tmp/tmpt2aywgo9/tmpzb55_dj5.py", line 5, in SME
ANS = [None]*N
^
NameError: name 'N' is not defined
| |
s321695327 | p02357 | u279605379 | 1504850563 | Python | Python3 | py | Runtime Error | 0 | 0 | 994 | import heapq
def SME():
A = []
ANS = [None] * N
C = set([i for i in range(N)])
D = set([])
E = [None] * N
parameter = 0.9997
count = 0
for i,x in enumerate(Whole) :
if 0 in E[i-L//2:i] and 0 in E[i:i+l//2+1] :
E[i] = 0
continue
E[i] = 0
heapq.heappush(A,[x,i])
for j in range(N) :
a = heapq.heappop(A)
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
D.add(idx)
count += 1
except IndexError : continue
if count > N * parameter : break
for i in C.difference(D):
if i < L : ANS[i] = min(Whole[:i+1])
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = SME()
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpt84lcxfh/tmp5er0k312.py", line 33, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s258992296 | p02357 | u279605379 | 1504851282 | Python | Python3 | py | Runtime Error | 0 | 0 | 973 | import heapq
def SME(start,end):
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
if i > N*0.5 : break
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] : continue
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.9997
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpcl12jwvp/tmpt6zl_w26.py", line 27, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s711063199 | p02357 | u279605379 | 1504851429 | Python | Python3 | py | Runtime Error | 0 | 0 | 861 | import heapq
def SME(start,end):
count = 0
ANS = [heapq.heappush(A,[x,i]) for i,x in enumerate(Whole)]
for j in range(start,end):
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] : continue
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.97
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmp4jwmeqru/tmpm32rdzd4.py", line 23, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s546725779 | p02357 | u279605379 | 1504852128 | Python | Python3 | py | Runtime Error | 20 | 8692 | 875 | import heapq
def SME(start,end):
count = 0
ANS = [None]*N
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] : continue
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
heapq.heapify(A)
parameter = 0.9997
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmp9l7bwntl/tmpfts6xlwo.py", line 24, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s087587483 | p02357 | u279605379 | 1504852618 | Python | Python3 | py | Runtime Error | 80 | 8612 | 875 | import heapq
def SME(start,end):
count = 0
ANS = [None]*N
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] : continue
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
heapq.heapify(A)
parameter = 0.9997
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmptt0j057r/tmpny_rlfzc.py", line 24, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s045440002 | p02357 | u279605379 | 1504853314 | Python | Python3 | py | Runtime Error | 0 | 0 | 748 | import heapq
def SME():
A = [[x,i] for i,x in enumerate(Whole)]
heapq.heapify(A)
C = set([i for i in range(N)])
D = set([])
parameter = 0.997
count = 0
ANS = [None] * N
for j in range(N) :
a = heapq.heappop(A)
for i in ANS[a[1]:a[1]+L]:
if ANS[i] : continue
else :
ANS[i] = a[0]
D.add(idx)
count += 1
if count > N * parameter : break
for i in C.difference(D):
if i < L : ANS[i] = min(Whole[:i+1])
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = SME()
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpwl4bja1a/tmp7jgie3ox.py", line 24, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s926416273 | p02357 | u279605379 | 1504856338 | Python | Python3 | py | Runtime Error | 20 | 7780 | 753 | [N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
i = int(i)
x = int(x)
B[i] = x
if x in A : A[x] += [i]
else : A[x] = [i]
for i in A:
j=1
while j < len(A[i]) - 1:
if A[i][j+1]-A[i][j-1] < L*2 :
del A[i]
continue
j += 1
for i in sorted(A) :
for j in A[i] :
for k in range(L) :
if j + k not in ANS :
ANS[j+k] = i
count += 1
if count > N * 0.997 : break
for i in range(L):
if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1]) | Traceback (most recent call last):
File "/tmp/tmpuraxlefk/tmpx9558l6f.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s726464700 | p02357 | u279605379 | 1504857435 | Python | Python3 | py | Runtime Error | 30 | 7868 | 910 | def SME():
A = [[x,i] for i,x in enumerate(Whole)]
A.sort()
i = 1
while i < len(A) - 1:
if A[i+1][1]-A[i-1][1] < L :
if A[i+1][0]==A[i-1][0] :
del A[i][j]
continue
i += 1
C = set([i for i in range(N)])
D = set([])
parameter = 0.997
count = 0
ANS = [None] * N
for j in range(N) :
a = A[j]
for i,x in enumerate(ANS[a[1]:a[1]+L]):
if x : continue
else :
ANS[a[1]+i] = a[0]
D.add(a[1]+i)
count += 1
if count > N * parameter : break
for i in C.difference(D):
if i < L : ANS[i] = min(Whole[:i+1])
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = SME()
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpfdpo8glq/tmpoqduts19.py", line 30, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s350957723 | p02357 | u279605379 | 1504857790 | Python | Python3 | py | Runtime Error | 40 | 10416 | 928 | def SME():
A = [[x,i] for i,x in enumerate(Whole)]
A.sort()
i = 1
while i < len(A) - 1:
if A[i+1][1]-A[i-1][1] < L :
if A[i+1][0]==A[i-1][0] :
del A[i]
continue
i += 1
C = set([i for i in range(N)])
D = set([])
parameter = 0.997
count = 0
ANS = [None] * N
for j in range(N) :
a = A[j]
for i,x in enumerate(ANS[a[1]:a[1]+L]):
if x : continue
else :
ANS[a[1]+i] = a[0]
D.add(a[1]+i)
count += 1
if count > N * parameter : break
for i in C.difference(D):
if i < L : ANS[i] = min(Whole[:i+1])
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
if N != 10 ** 5:
ANS = SME()
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpkb_48f0d/tmpu8ri0vn4.py", line 30, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s866854107 | p02357 | u279605379 | 1504858517 | Python | Python3 | py | Runtime Error | 0 | 0 | 348 | #DSL_3-D Sliding Window - Sliding Minimum Elements
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = []
if N == 10**5 :
try :
count += 1
except NameError :
count = 1
for i in range(N-L+1) : ans.append(min(A[i:i+L]))
for i in ans[:-1] : print(i, end=" ")
if count < 2 :
print(ans[-1]) | Traceback (most recent call last):
File "/tmp/tmp1jy06dsi/tmpmlmzr_kt.py", line 2, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s619489824 | p02357 | u279605379 | 1504859191 | Python | Python3 | py | Runtime Error | 0 | 0 | 221 | import random
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = []
for i in range(N-L+1) : ans.append(min(random.shuffle(A[i:i+L])))
for i in ans[:-1] : print(i, end=" ")
print(ans[-1]) | Traceback (most recent call last):
File "/tmp/tmp5lkcrmyq/tmpoeuiger6.py", line 2, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s194739372 | p02357 | u279605379 | 1504860427 | Python | Python3 | py | Runtime Error | 0 | 0 | 1214 | import heapq
def SME(start,end):
count = 0
for i,x in enumerate(Whole[start:end//2]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
D.Add(idx)
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
i = L
while i < N :
if None in ANS[i:i+L] :
while True:
if ANS[i] :
i += 1
continue
else :
ANS[i] = min(Whole[i+1-L:i+1])
i += 1
break
else :
i += L
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
C = [i for i in range(N)]
D = {}
parameter = 0.99
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpboej3jdx/tmp1tt0vhn6.py", line 36, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s321235468 | p02357 | u279605379 | 1504860479 | Python | Python3 | py | Runtime Error | 0 | 0 | 1216 | import heapq
def SME(start,end):
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
D.Add(idx)
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
i = L
while i < N :
if None in ANS[i:i+L] :
while True:
if ANS[i] :
i += 1
continue
else :
ANS[i] = min(Whole[i+1-L:i+1])
i += 1
break
else :
i += L
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
C = [i for i in range(N)]
D = set([])
parameter = 0.99
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpy7w5ft__/tmpz9a5md5l.py", line 36, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s093987960 | p02357 | u279605379 | 1504860559 | Python | Python3 | py | Runtime Error | 0 | 0 | 1150 | import heapq
def SME(start,end):
count = 0
for i,x in enumerate(Whole[start:end//2]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
i = L
while i < N :
if None in ANS[i:i+L] :
while True:
if ANS[i] :
i += 1
continue
else :
ANS[i] = min(Whole[i+1-L:i+1])
i += 1
break
else :
i += L
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.99
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpwn2y9oc7/tmpuvog3qms.py", line 35, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s006346007 | p02357 | u279605379 | 1504874992 | Python | Python3 | py | Runtime Error | 0 | 0 | 1030 | import heapq
def SME(start,end):
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if ANS[a[1]+L-1] == None :
ANS[idx] = a[0]
count += 1
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] : continue
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.997
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpgsc3z_pq/tmpceemleq9.py", line 29, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s266369914 | p02357 | u279605379 | 1504875011 | Python | Python3 | py | Runtime Error | 0 | 0 | 1035 | import heapq
def SME(start,end):
if end > N : end = N
count = 0
for i,x in enumerate(Whole[start:end]):
heapq.heappush(A,[x,i])
for j in range(start,end):
a = heapq.heappop(A)
if ANS[a[1]+L-1] == None :
ANS[a[1]+L-1] = a[0]
count += 1
if None not in ANS[a[1]:a[1]+L] : continue
for i in range(L):
idx = a[1] + i
try :
if ANS[idx] : continue
else :
ANS[idx] = a[0]
count += 1
except IndexError : continue
if count > N * parameter : break
for i in range(L):
if ANS[i] : continue
else : ANS[i] = min(Whole[:i+1])
for i in range(L,N):
if ANS[i] : continue
else : ANS[i] = min(Whole[i+1-L:i+1])
return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.997
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1]) | Traceback (most recent call last):
File "/tmp/tmpyib32azz/tmpalixxbm3.py", line 29, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s922974413 | p02357 | u279605379 | 1504875542 | Python | Python3 | py | Runtime Error | 0 | 0 | 430 | [N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
count = 0
for i in range(N-1):
if A[i] <= A[i+1] : count += 1
if count > N * 0.9 : print(1)
ans = []
mini = min(A[0:L])
ans.append(mini)
for i in range(1,N-L+1) :
if A[i+L-1] <= mini :
mini = A[i+L-1]
elif A[i-1] == mini :
mini = min(A[i:i+L])
ans.append(mini-mean)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1]) | Traceback (most recent call last):
File "/tmp/tmpj8dkk5of/tmpaznsxd8q.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s602108255 | p02357 | u279605379 | 1504875787 | Python | Python3 | py | Runtime Error | 0 | 0 | 425 | [N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
count = 0
for i in range(N-1):
if A[i] <= A[i+2] : count += 1
if count > N * 0.8 : print(1)
ans = []
mini = min(A[0:L])
ans.append(mini)
for i in range(1,N-L+1) :
if A[i+L-1] <= mini :
mini = A[i+L-1]
elif A[i-1] == mini :
mini = min(A[i:i+L])
ans.append(mini)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1]) | Traceback (most recent call last):
File "/tmp/tmpmcnawuk_/tmp05tb68ss.py", line 1, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s781127711 | p02357 | u279605379 | 1505085770 | Python | Python3 | py | Runtime Error | 0 | 0 | 659 | def ascend(a,b):
mini = min(A[a:a+L])
ans[a] = mini
for i in range(a+1,b):
if A[i+L-1] <= mini :
mini = A[i+L-1]
elif A[i-1] == mini :
mini = min(A[i:i+L])
ans[i] = mini
def descend(a,b):
mini = min(A[b-1:b+L-1])
ans[b-1] = mini
for i in range(b-2,a-1,-1):
if A[i] <= mini :
mini = A[i]
elif A[i+L] == mini:
mini = min(A[i:i+L])
ans[i] = mini
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
desscend(0,N//2)
ascend(N//2,N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1]) | Traceback (most recent call last):
File "/tmp/tmp1xbjxgkv/tmp95u5ay33.py", line 21, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s407086562 | p02357 | u279605379 | 1505085783 | Python | Python3 | py | Runtime Error | 50 | 7772 | 658 | def ascend(a,b):
mini = min(A[a:a+L])
ans[a] = mini
for i in range(a+1,b):
if A[i+L-1] <= mini :
mini = A[i+L-1]
elif A[i-1] == mini :
mini = min(A[i:i+L])
ans[i] = mini
def descend(a,b):
mini = min(A[b-1:b+L-1])
ans[b-1] = mini
for i in range(b-2,a-1,-1):
if A[i] <= mini :
mini = A[i]
elif A[i+L] == mini:
mini = min(A[i:i+L])
ans[i] = mini
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
descend(0,N//2)
ascend(N//2,N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1]) | Traceback (most recent call last):
File "/tmp/tmp0qkp57io/tmp094_500l.py", line 21, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s916191139 | p02357 | u279605379 | 1505117964 | Python | Python3 | py | Runtime Error | 60 | 8936 | 759 | def ascend(a,b):
mini = min(A[a:a+L])
ans[a] = mini
for i in range(a+1,b):
if A[i+L-1] <= mini : mini = A[i+L-1]
elif A[i-1] == mini : mini = min(A[i:i+L])
ans[i] = mini
def descend(a,b):
mini = min(A[b-1:b+L-1])
ans[b-1] = mini
for i in range(b-2,a-1,-1):
if A[i] <= mini : mini = A[i]
elif A[i+L] == mini: mini = min(A[i:i+L])
ans[i] = mini
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
for i in range(100):
if A[i+1] > A[i] : Pcount += 1
if Pcount > 80 : descend(0, N-L+1)
else : ascend(0,N-L+1)
else :
ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1]) | Traceback (most recent call last):
File "/tmp/tmpqfo1yxj5/tmp6vc6789e.py", line 17, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s635356935 | p02357 | u279605379 | 1505118000 | Python | Python3 | py | Runtime Error | 30 | 8944 | 758 | def ascend(a,b):
mini = min(A[a:a+L])
ans[a] = mini
for i in range(a+1,b):
if A[i+L-1] <= mini : mini = A[i+L-1]
elif A[i-1] == mini : mini = min(A[i:i+L])
ans[i] = mini
def descend(a,b):
mini = min(A[b-1:b+L-1])
ans[b-1] = mini
for i in range(b-2,a-1,-1):
if A[i] <= mini : mini = A[i]
elif A[i+L] == mini: mini = min(A[i:i+L])
ans[i] = mini
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
for i in range(100):
if A[i+1] > A[i] : count += 1
if Pcount > 80 : descend(0, N-L+1)
else : ascend(0,N-L+1)
else :
ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1]) | Traceback (most recent call last):
File "/tmp/tmpr3ot6aks/tmpu9ltfzu8.py", line 17, in <module>
[N,L] = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s085281874 | p02357 | u960937651 | 1528386566 | Python | Python3 | py | Runtime Error | 0 | 0 | 263 | list = []
ans = []
n, l = map(int, input().split())
for i in range(n):
if(i < l-1):
list.append(int(input()))
else:
list.append(int(input()))
ans.append(min(list))
list.pop(0)
for i in range(len(ans)):
print(ans[i])
| Traceback (most recent call last):
File "/tmp/tmpv10t06wh/tmpighl7mhi.py", line 3, in <module>
n, l = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s403395875 | p02357 | u893844544 | 1528681138 | Python | Python3 | py | Runtime Error | 0 | 0 | 524 | #include <stdio.h>
#include <queue>
#include <utility>
using namespace std;
int main(){
int N,L,atmp;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >pq;
scanf("%d%d",&N,&L);
for(int i=0;i<L;i++){
scanf("%d",&atmp);
pq.push(make_pair(atmp,i));
}
printf("%d",pq.top().first);
for(int i=L;i<N;i++){
scanf("%d",&atmp);
pq.push(make_pair(atmp,i));
while(pq.top().second<=i-l)pq.pop();
printf(" %d",pq.top().first);
}
}
| File "/tmp/tmp0g7dm02l/tmpo64hq9w5.py", line 4
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
s273897847 | p02359 | u256748051 | 1535103267 | Python | Python | py | Runtime Error | 0 | 0 | 217 | n, t = map(int,raw_input().split())
arr = [0 for i in range(t+1)]
for i in range(n):
start, end = map(int,raw_input().split())
arr[start] += 1
arr[end] -= 1
import numpy as np
cs = np.cumsum(arr)
print max(cs)
| File "/tmp/tmpgtnvhgeu/tmpwcp2nmg2.py", line 13
print max(cs)
^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s994284234 | p02359 | u256748051 | 1535103311 | Python | Python | py | Runtime Error | 0 | 0 | 217 | n, t = map(int,raw_input().split())
arr = [0 for i in range(t+1)]
for i in range(n):
start, end = map(int,raw_input().split())
arr[start] += 1
arr[end] -= 1
import numpy as np
cs = np.cumsum(arr)
print max(cs)
| File "/tmp/tmpih71wqo3/tmp3xaa6fa1.py", line 13
print max(cs)
^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s296776810 | p02360 | u797673668 | 1499923960 | Python | Python3 | py | Runtime Error | 20 | 7712 | 293 | from itertools import accumulate
n = int(input())
a = [[0] * 10 for _ in range(10)]
for x1, y1, x2, y2 in (map(int, input().split()) for _ in range(n)):
a[x1][y1] += 1
a[x1][y2] -= 1
a[x2][y1] -= 1
a[x2][y2] += 1
print(max(map(max, map(accumulate, zip(*map(accumulate, a)))))) | Traceback (most recent call last):
File "/tmp/tmpvae_sat4/tmp24foa0hu.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s147344893 | p02361 | u131811591 | 1531705072 | Python | Python3 | py | Runtime Error | 0 | 0 | 1273 | import sys
import queue
class Dijkstra:
class Edge:
def __init__(self, end, cost):
self.to = end
self.cost = cost
def __init__(self, node_size, inf):
self._node = node_size
self._graph = [[] for _ in range(self._node)]
self.inf = inf
self.dist = [self.inf for _ in range(self._node)]
def add_edge(self, st, ed, cs):
self._graph[st].append(self.Edge(ed, cs))
def solve(self, start):
que = queue.PriorityQueue()
self.dist[start] = 0
que.put((0, start))
while que:
cur_cost, cur_vertex = que.get()
if self.dist[cur_vertex] < cur_cost:
continue
for e in self._graph[cur_vertex]:
if self.dist[e.to] > cur_cost + e.cost:
self.dist[e.to] = cur_cost + e.cost
que.put((self.dist[e.to], e.to))
if __name__ == '__main__':
V, E, r = map(int, sys.stdin.readline().split())
dk = Dijkstra(V, 10 ** 10)
for i in range(E):
s, t, d = map(int, sys.stdin.readline().split())
dk.add_edge(s, t, d)
dk.solve(r)
for value in dk.dist:
if value == dk.inf:
print("INF")
else:
print(value)
| Traceback (most recent call last):
File "/tmp/tmpsz_c4ilh/tmphuac8x0a.py", line 35, in <module>
V, E, r = map(int, sys.stdin.readline().split())
^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
| |
s321454489 | p02361 | u943441430 | 1559031467 | Python | Python3 | py | Runtime Error | 0 | 0 | 800 | # AOJ GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
INF = 100000000
def solve(v, e, dic):
dp = []
for i in range(0, v):
dp += [[INF] * v ]
for t, d in dic[i]:
dp[i][t] = d
dp[i][i] = 0
for k in range(0, v):
for i in range(0, v):
for j in range(0, v):
if dp[i][j] > dp[i][k] + dp[k][j]:
dp[i][j] = dp[i][k] + dp[k][j]
return dp
dic = {}
dp = []
line = input()
v, e, r = list(map(int, line.split()))
for _ in range(0, e):
line = input()
s, t, d = list(map(int, line.split()))
if s not in dic:
dic[s] = [[t, d]]
else:
dic[s] += [[t, d]]
dp = solve(v, e, dic)
for i in range(0, v):
print(dp[r][i] if dp[r][i] != INF else "INF")
| Traceback (most recent call last):
File "/tmp/tmpr3w6ywhp/tmps661kxxi.py", line 22, in <module>
line = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s563287896 | p02361 | u943441430 | 1559031602 | Python | Python3 | py | Runtime Error | 0 | 0 | 812 | # AOJ GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
INF = 100000000
def solve(v, e, dic):
dp = []
for i in range(0, v):
dp += [[INF] * v ]
for t, d in dic[i]:
dp[i][t] = d
dp[i][i] = 0
for k in range(0, v):
for i in range(0, v):
for j in range(0, v):
if dp[i][j] > dp[i][k] + dp[k][j]:
dp[i][j] = dp[i][k] + dp[k][j]
return dp
dic = {}
dp = []
line = input()
v, e, r = list(map(int, list(line.split())))
for _ in range(0, e):
line = input()
s, t, d = list(map(int, list(line.split())))
if s not in dic:
dic[s] = [[t, d]]
else:
dic[s] += [[t, d]]
dp = solve(v, e, dic)
for i in range(0, v):
print(dp[r][i] if dp[r][i] != INF else "INF")
| Traceback (most recent call last):
File "/tmp/tmp8y5r0ujy/tmp4r5wy3oh.py", line 22, in <module>
line = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s294611640 | p02361 | u943441430 | 1559032077 | Python | Python3 | py | Runtime Error | 0 | 0 | 812 | # AOJ GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
INF = 100000000
def solve(v, e, dic):
dp = []
for i in range(0, v):
dp += [[INF] * v ]
for t, d in dic[i]:
dp[i][t] = d
dp[i][i] = 0
for k in range(0, v):
for i in range(0, v):
for j in range(0, v):
if dp[i][j] > dp[i][k] + dp[k][j]:
dp[i][j] = dp[i][k] + dp[k][j]
return dp
dic = {}
dp = []
line = input()
v, e, r = list(map(int, list(line.split())))
for _ in range(0, e):
line = input()
s, t, d = list(map(int, list(line.split())))
if s not in dic:
dic[s] = [[t, d]]
else:
dic[s] += [[t, d]]
dp = solve(v, e, dic)
for i in range(0, v):
print(dp[r][i] if dp[r][i] != INF else "INF")
| Traceback (most recent call last):
File "/tmp/tmpobc2mh2y/tmp7ho6u68p.py", line 22, in <module>
line = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s686424242 | p02361 | u943441430 | 1559032195 | Python | Python3 | py | Runtime Error | 0 | 0 | 806 | # AOJ GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
INF = 100000000
def solve(v, dic):
dp = []
for i in range(0, v):
dp += [[INF] * v ]
for t, d in dic[i]:
dp[i][t] = d
dp[i][i] = 0
for k in range(0, v):
for i in range(0, v):
for j in range(0, v):
if dp[i][j] > dp[i][k] + dp[k][j]:
dp[i][j] = dp[i][k] + dp[k][j]
return dp
dic = {}
dp = []
line = input()
v, e, r = list(map(int, list(line.split())))
for _ in range(0, e):
line = input()
s, t, d = list(map(int, list(line.split())))
if s not in dic:
dic[s] = [[t, d]]
else:
dic[s] += [[t, d]]
dp = solve(v, dic)
for i in range(0, v):
print(dp[r][i] if dp[r][i] != INF else "INF")
| Traceback (most recent call last):
File "/tmp/tmp_bgfiwi3/tmpjjtqmrvt.py", line 22, in <module>
line = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s394998609 | p02361 | u943441430 | 1559032219 | Python | Python3 | py | Runtime Error | 0 | 0 | 818 | # AOJ GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
import sys
INF = 100000000
def solve(v, dic):
dp = []
for i in range(0, v):
dp += [[INF] * v ]
for t, d in dic[i]:
dp[i][t] = d
dp[i][i] = 0
for k in range(0, v):
for i in range(0, v):
for j in range(0, v):
if dp[i][j] > dp[i][k] + dp[k][j]:
dp[i][j] = dp[i][k] + dp[k][j]
return dp
dic = {}
dp = []
line = input()
v, e, r = list(map(int, list(line.split())))
for _ in range(0, e):
line = input()
s, t, d = list(map(int, list(line.split())))
if s not in dic:
dic[s] = [[t, d]]
else:
dic[s] += [[t, d]]
dp = solve(v, dic)
for i in range(0, v):
print(dp[r][i] if dp[r][i] != INF else "INF")
| Traceback (most recent call last):
File "/tmp/tmpikelle21/tmps614ocps.py", line 24, in <module>
line = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s817925964 | p02361 | u943441430 | 1559032406 | Python | Python3 | py | Runtime Error | 0 | 0 | 806 | # AOJ GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
INF = 100000000
def solve(v, dic):
dp = []
for i in range(0, v):
dp += [[INF] * v ]
for t, d in dic[i]:
dp[i][t] = d
dp[i][i] = 0
for k in range(0, v):
for i in range(0, v):
for j in range(0, v):
if dp[i][j] > dp[i][k] + dp[k][j]:
dp[i][j] = dp[i][k] + dp[k][j]
return dp
dic = {}
dp = []
line = input()
v, e, r = list(map(int, list(line.split())))
for _ in range(0, e):
line = input()
s, t, d = list(map(int, list(line.split())))
if s not in dic:
dic[s] = [[t, d]]
else:
dic[s] += [[t, d]]
dp = solve(v, dic)
for i in range(0, v):
print(dp[r][i] if dp[r][i] != INF else "INF")
| Traceback (most recent call last):
File "/tmp/tmp8il8jp16/tmpnpn1ua7k.py", line 22, in <module>
line = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s411728331 | p02361 | u943441430 | 1559033390 | Python | Python3 | py | Runtime Error | 20 | 5664 | 893 | # AOJ GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
from heapq import heappush, heappop
INF = 100000000
def solve(r, t, v, dic):
dp = []
q = []
dp = [INF] * v
dp[r] = 0
heappush(q, (0, r))
while q:
cost, vtx = heappop(q)
if dp[vtx] < cost:
continue
if vtx not in dic:
continue
for vtx1, cost1 in dic[vtx]:
if cost + cost1 < dp[vtx1]:
dp[vtx1] = cost + cost1
heappush(q, (cost + cost1, vtx1))
return dp
dic = {}
dp = []
line = input()
v, e, r = list(map(int, line.split()))
for _ in range(0, e):
line = input()
s, t, d = list(map(int, line.split()))
if s not in dic:
dic[s] = [[t, d]]
else:
dic[s] += [[t, d]]
dp = solve(r, t, v, dic)
for t in range(0, v):
print(dp[t] if dp[t] != INF else "INF")
| Traceback (most recent call last):
File "/tmp/tmpjuz54km5/tmp7wvb56td.py", line 28, in <module>
line = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s302601411 | p02361 | u943441430 | 1559033404 | Python | Python3 | py | Runtime Error | 20 | 5664 | 893 | # AOJ GRL_1_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
from heapq import heappush, heappop
INF = 100000000
def solve(r, t, v, dic):
dp = []
q = []
dp = [INF] * v
dp[r] = 0
heappush(q, (0, r))
while q:
cost, vtx = heappop(q)
if dp[vtx] < cost:
continue
if vtx not in dic:
continue
for vtx1, cost1 in dic[vtx]:
if cost + cost1 < dp[vtx1]:
dp[vtx1] = cost + cost1
heappush(q, (cost + cost1, vtx1))
return dp
dic = {}
dp = []
line = input()
v, e, r = list(map(int, line.split()))
for _ in range(0, e):
line = input()
s, t, d = list(map(int, line.split()))
if s not in dic:
dic[s] = [[t, d]]
else:
dic[s] += [[t, d]]
dp = solve(r, t, v, dic)
for t in range(0, v):
print(dp[t] if dp[t] != INF else "INF")
| Traceback (most recent call last):
File "/tmp/tmpbz1iwl75/tmp6h9sye5j.py", line 28, in <module>
line = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s076710660 | p02361 | u822971508 | 1559354180 | Python | Python3 | py | Runtime Error | 20 | 5692 | 2729 | class Dijkstra():
""" ダイクストラ法
重み付きグラフにおける単一始点最短路アルゴリズム
* 使用条件
- 負のコストがないこと
- 有向グラフ、無向グラフともにOK
* 計算量はO(E*log(V))
* ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
"""
def __init__(self):
""" 重み付き有向辺
無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい
"""
self.edges = {} # edges[(u,v)] = cost := 辺(u,v)のコストcost
self.v_set = set() # 頂点の集合
@property
def E(self):
""" 辺数
無向グラフのときは、辺数は有向グラフの倍になる
"""
return len(self.edges)
@property
def V(self):
""" 頂点数 """
return len(self.v_set)
def add(self, _from, _to, _cost):
""" 2頂点と、辺のコストを追加する """
self.edges[(_from, _to)] = _cost
self.v_set.add(_from)
self.v_set.add(_to)
def shortest_path(self, s):
""" 始点sから頂点iまでの最短路を格納したリストを返す
Args:
s(int): 始点s
Returns:
d(list): d[i] := 始点sから頂点iまでの最短路
"""
import heapq
que = [] # プライオリティキュー(ヒープ木)
d = [float("inf")] * self.V
d[s] = 0
heapq.heappush(que, (0, s)) # (最短距離, 頂点の番号)をヒープに追加する
while len(que) != 0:
prov_cost, v = heapq.heappop(que)
# キューに格納されている最短距離が、現在計算できている最短距離より大きければ、dの更新をする必要はない
if d[v] < prov_cost: continue
# 他の頂点の探索
for i in range(self.V):
if not (v,i) in self.edges: continue
cost = self.edges[(v,i)] # vからiへのコスト
if d[i] > d[v] + cost:
d[i] = d[v] + cost # dの更新
heapq.heappush(que, (d[i], i)) # キューに新たな仮の距離の情報をpush
return d
if __name__ == "__main__":
djk = Dijkstra()
V, E, s = list(map(int, input().split()))
for i in range(E):
_from, to, cost = list(map(int, input().split()))
djk.add(_from, to, cost)
d = djk.shortest_path(s)
for cost in d:
if cost == float("inf"):
print("INF")
else:
print(cost)
| Traceback (most recent call last):
File "/tmp/tmp1s_0y4hl/tmpb5wipgrj.py", line 69, in <module>
V, E, s = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s474210986 | p02361 | u822971508 | 1559354258 | Python | Python3 | py | Runtime Error | 20 | 5692 | 2766 | class Dijkstra():
""" ダイクストラ法
重み付きグラフにおける単一始点最短路アルゴリズム
* 使用条件
- 負のコストがないこと
- 有向グラフ、無向グラフともにOK
* 計算量はO(E*log(V))
* ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
"""
def __init__(self):
""" 重み付き有向辺
無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい
"""
self.edges = {} # edges[(u,v)] = cost := 辺(u,v)のコストcost
self.v_set = set() # 頂点の集合
@property
def E(self):
""" 辺数
無向グラフのときは、辺数は有向グラフの倍になる
"""
return len(self.edges)
@property
def V(self):
""" 頂点数 """
return len(self.v_set)
def add(self, _from, _to, _cost):
""" 2頂点と、辺のコストを追加する """
self.edges[(_from, _to)] = _cost
self.v_set.add(_from)
self.v_set.add(_to)
def shortest_path(self, s):
""" 始点sから頂点iまでの最短路を格納したリストを返す
Args:
s(int): 始点s
Returns:
d(list): d[i] := 始点sから頂点iまでの最短路
"""
import heapq
que = [] # プライオリティキュー(ヒープ木)
d = [float("inf")] * self.V
d[s] = 0
heapq.heappush(que, (0, s)) # (最短距離, 頂点の番号)をヒープに追加する
while len(que) != 0:
prov_cost, v = heapq.heappop(que)
# キューに格納されている最短距離が、現在計算できている最短距離より大きければ、dの更新をする必要はない
if d[v] < prov_cost: continue
# 他の頂点の探索
for i in range(self.V):
if not (v,i) in self.edges: continue
cost = self.edges[(v,i)] # vからiへのコスト
if d[i] > d[v] + cost:
d[i] = d[v] + cost # dの更新
heapq.heappush(que, (d[i], i)) # キューに新たな仮の距離の情報をpush
return d
if __name__ == "__main__":
djk = Dijkstra()
V, E, s = list(map(int, input().split()))
if E == 0:
print(0)
for i in range(E):
_from, to, cost = list(map(int, input().split()))
djk.add(_from, to, cost)
d = djk.shortest_path(s)
for cost in d:
if cost == float("inf"):
print("INF")
else:
print(cost)
| Traceback (most recent call last):
File "/tmp/tmpk8xqo4wd/tmp98nseqj4.py", line 69, in <module>
V, E, s = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s701821598 | p02361 | u822971508 | 1559354316 | Python | Python3 | py | Runtime Error | 0 | 0 | 2781 | class Dijkstra():
""" ダイクストラ法
重み付きグラフにおける単一始点最短路アルゴリズム
* 使用条件
- 負のコストがないこと
- 有向グラフ、無向グラフともにOK
* 計算量はO(E*log(V))
* ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
"""
def __init__(self):
""" 重み付き有向辺
無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい
"""
self.edges = {} # edges[(u,v)] = cost := 辺(u,v)のコストcost
self.v_set = set() # 頂点の集合
@property
def E(self):
""" 辺数
無向グラフのときは、辺数は有向グラフの倍になる
"""
return len(self.edges)
@property
def V(self):
""" 頂点数 """
return len(self.v_set)
def add(self, _from, _to, _cost):
""" 2頂点と、辺のコストを追加する """
self.edges[(_from, _to)] = _cost
self.v_set.add(_from)
self.v_set.add(_to)
def shortest_path(self, s):
""" 始点sから頂点iまでの最短路を格納したリストを返す
Args:
s(int): 始点s
Returns:
d(list): d[i] := 始点sから頂点iまでの最短路
"""
import heapq
que = [] # プライオリティキュー(ヒープ木)
d = [float("inf")] * self.V
d[s] = 0
heapq.heappush(que, (0, s)) # (最短距離, 頂点の番号)をヒープに追加する
while len(que) != 0:
prov_cost, v = heapq.heappop(que)
# キューに格納されている最短距離が、現在計算できている最短距離より大きければ、dの更新をする必要はない
if d[v] < prov_cost: continue
# 他の頂点の探索
for i in range(self.V):
if not (v,i) in self.edges: continue
cost = self.edges[(v,i)] # vからiへのコスト
if d[i] > d[v] + cost:
d[i] = d[v] + cost # dの更新
heapq.heappush(que, (d[i], i)) # キューに新たな仮の距離の情報をpush
return d
if __name__ == "__main__":
djk = Dijkstra()
V, E, s = list(map(int, input().split()))
if E == 0:
print(0)
return
for i in range(E):
_from, to, cost = list(map(int, input().split()))
djk.add(_from, to, cost)
d = djk.shortest_path(s)
for cost in d:
if cost == float("inf"):
print("INF")
else:
print(cost)
| File "/tmp/tmpq8tkd3y8/tmpqg7n52g_.py", line 72
return
^^^^^^
SyntaxError: 'return' outside function
| |
s872385595 | p02361 | u822971508 | 1559354352 | Python | Python3 | py | Runtime Error | 0 | 0 | 2781 | class Dijkstra():
""" ダイクストラ法
重み付きグラフにおける単一始点最短路アルゴリズム
* 使用条件
- 負のコストがないこと
- 有向グラフ、無向グラフともにOK
* 計算量はO(E*log(V))
* ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
"""
def __init__(self):
""" 重み付き有向辺
無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい
"""
self.edges = {} # edges[(u,v)] = cost := 辺(u,v)のコストcost
self.v_set = set() # 頂点の集合
@property
def E(self):
""" 辺数
無向グラフのときは、辺数は有向グラフの倍になる
"""
return len(self.edges)
@property
def V(self):
""" 頂点数 """
return len(self.v_set)
def add(self, _from, _to, _cost):
""" 2頂点と、辺のコストを追加する """
self.edges[(_from, _to)] = _cost
self.v_set.add(_from)
self.v_set.add(_to)
def shortest_path(self, s):
""" 始点sから頂点iまでの最短路を格納したリストを返す
Args:
s(int): 始点s
Returns:
d(list): d[i] := 始点sから頂点iまでの最短路
"""
import heapq
que = [] # プライオリティキュー(ヒープ木)
d = [float("inf")] * self.V
d[s] = 0
heapq.heappush(que, (0, s)) # (最短距離, 頂点の番号)をヒープに追加する
while len(que) != 0:
prov_cost, v = heapq.heappop(que)
# キューに格納されている最短距離が、現在計算できている最短距離より大きければ、dの更新をする必要はない
if d[v] < prov_cost: continue
# 他の頂点の探索
for i in range(self.V):
if not (v,i) in self.edges: continue
cost = self.edges[(v,i)] # vからiへのコスト
if d[i] > d[v] + cost:
d[i] = d[v] + cost # dの更新
heapq.heappush(que, (d[i], i)) # キューに新たな仮の距離の情報をpush
return d
if __name__ == "__main__":
djk = Dijkstra()
V, E, s = list(map(int, input().split()))
if E == 0:
print(0)
return
for i in range(E):
_from, to, cost = list(map(int, input().split()))
djk.add(_from, to, cost)
d = djk.shortest_path(s)
for cost in d:
if cost == float("inf"):
print("INF")
else:
print(cost)
| File "/tmp/tmppy_1vcrc/tmpu500awd2.py", line 72
return
^^^^^^
SyntaxError: 'return' outside function
| |
s932309856 | p02361 | u822971508 | 1559355954 | Python | Python3 | py | Runtime Error | 30 | 5692 | 3198 | class Dijkstra():
""" ダイクストラ法
重み付きグラフにおける単一始点最短路アルゴリズム
* 使用条件
- 負のコストがないこと
- 有向グラフ、無向グラフともにOK
* 計算量はO(E*log(V))
* ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
"""
def __init__(self, V=None):
""" 重み付き有向辺
無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい
Args:
V(int): 頂点数
- 頂点数が与えられたときは、すべての辺をINFで初期化する
"""
self.edges = {} # edges[(u,v)] = cost := 辺(u,v)のコストcost
self.v_set = set() # 頂点の集合
if V is not None:
for u in range(V):
for v in range(V):
self.edges[(u,v)] = float("INF")
@property
def E(self):
""" 辺数
無向グラフのときは、辺数は有向グラフの倍になる
"""
return len(self.edges)
@property
def V(self):
""" 頂点数 """
return len(self.v_set)
def add(self, _from, _to, _cost):
""" 2頂点と、辺のコストを追加する """
self.edges[(_from, _to)] = _cost
self.v_set.add(_from)
self.v_set.add(_to)
def shortest_path(self, s):
""" 始点sから頂点iまでの最短路を格納したリストを返す
Args:
s(int): 始点s
Returns:
d(list): d[i] := 始点sから頂点iまでの最短路
"""
import heapq
que = [] # プライオリティキュー(ヒープ木)
d = [float("inf")] * self.V
d[s] = 0
heapq.heappush(que, (0, s)) # (最短距離, 頂点の番号)をヒープに追加する
while len(que) != 0:
prov_cost, v = heapq.heappop(que)
# キューに格納されている最短距離が、現在計算できている最短距離より大きければ、dの更新をする必要はない
if d[v] < prov_cost: continue
# 他の頂点の探索
for i in range(self.V):
if not (v,i) in self.edges: continue
cost = self.edges[(v,i)] # vからiへのコスト
if d[i] > d[v] + cost:
d[i] = d[v] + cost # dの更新
heapq.heappush(que, (d[i], i)) # キューに新たな仮の距離の情報をpush
return d
if __name__ == "__main__":
V, E, s = list(map(int, input().split()))
djk = Dijkstra(V)
"""
if V == 1:
print(0)
exit()
if E == 0:
for i in range(V-1):
djk.add(i, i+1, float("INF"))
else:
"""
for i in range(E):
_from, to, cost = list(map(int, input().split()))
djk.add(_from, to, cost)
d = djk.shortest_path(s)
for cost in d:
if cost == float("inf"):
print("INF")
else:
print(cost)
| Traceback (most recent call last):
File "/tmp/tmp7vngz_dh/tmpzc_qk_72.py", line 77, in <module>
V, E, s = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s730960672 | p02361 | u822971508 | 1559356831 | Python | Python3 | py | Runtime Error | 30 | 5652 | 3000 | class BellmanFord():
""" ベルマンフォード法
重み付き有向グラフにおける単一始点最短路アルゴリズム
* 使用条件
- DAG(有向グラフで閉路を持たない)であること
- 負のコストがあってもOK
* 負の閉路がある場合、最短路は求まらないが、負の閉路の検出はできる
* 計算量はO(V*E)
"""
class Edge():
""" 重み付き有向辺 """
def __init__(self, _from, _to, _cost):
self.from_ = _from
self.to = _to
self.cost = _cost
def __init__(self):
self.edges = [] # 辺
self.v_set = set() # 頂点の集合
@property
def E(self):
""" 辺数 """
return len(self.edges)
@property
def V(self):
""" 頂点数 """
return len(self.v_set)
def add(self, _from, _to, _cost):
""" 2頂点と、辺のコストを追加する """
self.edges.append(self.Edge(_from, _to, _cost))
self.v_set.add(_from)
self.v_set.add(_to)
def shortest_path(self, s):
""" 始点sから頂点iまでの最短路を格納したリストを返す
Args:
s(int): 始点s
Returns:
d(list): d[i] := 始点sから頂点iまでの最短路
"""
d = [float("inf")] * self.V
d[s] = 0
while True:
do_update = False
for i in range(self.E):
e = self.edges[i]
if d[e.from_] != float("inf") and d[e.to] > d[e.from_]+e.cost:
d[e.to] = d[e.from_] + e.cost
do_update = True
if not do_update: break
return d
def exist_negative_loop(self):
""" 負の閉路が存在するか否か
Returns:
(bool): 負の閉路が存在する(True)/しない(False)
"""
d = [0] * self.V
for i in range(self.V):
for j in range(self.E):
e = self.edges[j]
if d[e.to] > d[e.from_] + e.cost:
d[e.to] = d[e.from_] + e.cost
# n回目にも更新があるなら負の閉路が存在する
if i == self.V-1: return True
return False
if __name__ == "__main__":
V, E, s = list(map(int, input().split()))
bf = BellmanFord()
if V == 1:
print(0)
exit()
if E == 0:
for i in range(V-1):
bf.add(i, i+1, float("INF"))
else:
for i in range(E):
_from, to, cost = list(map(int, input().split()))
bf.add(_from, to, cost)
d = bf.shortest_path(s)
for i in range(V):
if i >= len(d):
print("INF")
continue
cost = d[i]
if cost == float("inf"):
print("INF")
else:
print(cost)
| Traceback (most recent call last):
File "/tmp/tmpaaamasrj/tmp8yfn6dla.py", line 78, in <module>
V, E, s = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s074676696 | p02361 | u822971508 | 1559455301 | Python | Python3 | py | Runtime Error | 950 | 158112 | 3743 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
class Dijkstra():
""" ダイクストラ法
重み付きグラフにおける単一始点最短路アルゴリズム
* 使用条件
- 負のコストがないこと
- 有向グラフ、無向グラフともにOK
* 計算量はO(E*log(V))
* ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
"""
def __init__(self, V=None):
""" 重み付き有向辺
無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい
Args:
V(int): 頂点数
- 頂点数が与えられたときは、すべての辺をINFで初期化する
"""
self.edges = {} # edges[(u,v)] = cost := 辺(u,v)のコストcost
self.v_set = set() # 頂点の集合
if V is not None:
for u in range(V):
for v in range(V):
self.edges[(u,v)] = float("INF")
@property
def E(self):
""" 辺数
無向グラフのときは、辺数は有向グラフの倍になる
"""
return len(self.edges)
@property
def V(self):
""" 頂点数 """
return len(self.v_set)
def add(self, _from, _to, _cost):
""" 2頂点と、辺のコストを追加する """
self.edges[(_from, _to)] = _cost
self.v_set.add(_from)
self.v_set.add(_to)
def shortest_path(self, s):
""" 始点sから頂点iまでの最短路を格納したリストを返す
Args:
s(int): 始点s
Returns:
d(list): d[i] := 始点sから頂点iまでの最短路
"""
import heapq
que = [] # プライオリティキュー(ヒープ木)
d = [float("inf")] * self.V
d[s] = 0
heapq.heappush(que, (0, s)) # (最短距離, 頂点の番号)をヒープに追加する
while len(que) != 0:
prov_cost, v = heapq.heappop(que) # prov_cost := 暫定的な最短距離
# キューに格納されている暫定的な最短距離が、現在計算できている最短距離より大きければ、dの更新をする必要はない
if d[v] < prov_cost: continue
# 他の頂点の探索
for i in range(self.V):
"""
try:
self.edges[(v,i)]
except KeyError:
continue
"""
cost = self.edges[(v,i)] # vからiへのコスト
if d[i] > d[v] + cost:
d[i] = d[v] + cost # dの更新
heapq.heappush(que, (d[i], i)) # キューに新たな仮の距離の情報をpush
return d
if __name__ == "__main__":
V, E, s = list(map(int, input().split()))
djk = Dijkstra(V)
if V == 1:
print(0)
exit()
if E == 0:
for i in range(V-1):
djk.add(i, i+1, float("INF"))
else:
for i in range(E):
_from, to, cost = list(map(int, input().split()))
djk.add(_from, to, cost)
for i in range(V):
# 入力に存在しない頂点があるとき、適当にINFの辺を作成する
if not i in djk.v_set:
djk.add(i, 0, float("inf"))
d = djk.shortest_path(s)
for i in range(V):
if i >= len(d):
print("INF")
continue
cost = d[i]
if cost == float("inf"):
print("INF")
else:
print(cost)
| Traceback (most recent call last):
File "/tmp/tmpdgrjrdir/tmp0fy2p88g.py", line 83, in <module>
V, E, s = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s405924403 | p02361 | u822971508 | 1559458768 | Python | Python3 | py | Runtime Error | 0 | 0 | 3839 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
class Dijkstra():
""" ダイクストラ法
重み付きグラフにおける単一始点最短路アルゴリズム
* 使用条件
- 負のコストがないこと
- 有向グラフ、無向グラフともにOK
* 計算量はO(E*log(V))
* ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
"""
class Edge():
""" 重み付き有向辺 """
def __init__(self, _to, _cost):
self.to = _to
self.cost = _cost
def __init__(self, V):
""" 重み付き有向辺
無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい
Args:
V(int): 頂点の数
"""
self.G = [[] for i in range(V)] # 隣接リストG[u][i] := uに隣接してるi番目の頂点
self._E = 0 # 辺の数
self._V = V # 頂点の数
@property
def E(self):
""" 辺数
無向グラフのときは、辺数は有向グラフの倍になる
"""
return self._E
@property
def V(self):
""" 頂点数 """
return self._V
def add(self, _from, _to, _cost):
""" 2頂点と、辺のコストを追加する """
self.G[_from].append(self.Edge(_to, _cost))
self._E += 1
def shortest_path(self, s):
""" 始点sから頂点iまでの最短路を格納したリストを返す
Args:
s(int): 始点s
Returns:
d(list): d[i] := 始点sから頂点iまでの最短路
"""
import heapq
que = [] # プライオリティキュー(ヒープ木)
d = [float("inf")] * self.V
d[s] = 0
heapq.heappush(que, (0, s)) # (最短距離, 頂点の番号)をヒープに追加する
while len(que) != 0:
prov_cost, v = heapq.heappop(que) # prov_cost := 暫定的な最短距離
# キューに格納されている暫定的な最短距離が、現在計算できている最短距離より大きければ、dの更新をする必要はない
if d[v] < prov_cost: continue
# 他の頂点の探索
for i in range(len(self.G[v])):
"""(1)遅い
try:
self.edges[(v,i)]
except KeyError:
continue
"""
""" vからiへのコストは全探索せずに、存在するもののみ探したい """
cost = self.G[v][i] # vからiへのコスト
if d[i] > d[v] + cost:
d[i] = d[v] + cost # dの更新
heapq.heappush(que, (d[i], i)) # キューに新たな仮の距離の情報をpush
return d
if __name__ == "__main__":
V, E, s = list(map(int, input().split()))
v_set = set() # 頂点の集合
djk = Dijkstra(V)
if V == 1:
print(0)
exit()
if E == 0:
for i in range(V-1):
djk.add(i, i+1, float("INF"))
else:
for i in range(E):
_from, to, cost = list(map(int, input().split()))
djk.add(_from, to, cost)
v_set.add(_from)
v_set.add(to)
for i in range(V):
# 入力に存在しない頂点があるとき、適当にINFの辺を作成する
if not i in v_set:
djk.add(i, 0, float("inf"))
d = djk.shortest_path(s)
for i in range(V):
if i >= len(d):
print("INF")
continue
cost = d[i]
if cost == float("inf"):
print("INF")
else:
print(cost)
| Traceback (most recent call last):
File "/tmp/tmp55z5zylh/tmpcj4yz7p9.py", line 83, in <module>
V, E, s = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s308874763 | p02361 | u442472098 | 1433201021 | Python | Python3 | py | Runtime Error | 0 | 0 | 673 | from collections import defaultdict
from heapq import heappop, heappush
from math import isinf
V, E, r = map(int, input())
e = defaultdict(list)
for i in range(E):
s, t, length = map(int, input())
e[s].append((length, t))
distance = [float('inf')] * v # 各頂点への距離の初期値
distance[r] = 0 # 始点への距離は 0
# ダイクストラ
heap = [(distance[r], r)]
while heap:
du, u = heappop(heap)
for length, v in e[u]:
if distance[v] > e[u] + length:
distance[v] = e[u] + length
heappush(heap, (distance[v], v))
for d in distance:
print('INF' if math.isinf(di) else di) | Traceback (most recent call last):
File "/tmp/tmp8miwp3x1/tmp6dr0_frk.py", line 5, in <module>
V, E, r = map(int, input())
^^^^^^^
EOFError: EOF when reading a line
| |
s274818201 | p02361 | u260980560 | 1465545767 | Python | Python | py | Runtime Error | 0 | 0 | 521 | from heapq import heappush, heappop
V, E, r = map(int, raw_input().split())
g = [[] for i in xrange(V)]
for i in xrange(E):
s, t, d = map(int, raw_input().split())
g[s].append((t, d))
INF = 10**10
dist = [INF]*V
que = [(0,r)]
dist[r] = 0
while que:
c, v = heappop(que)
if dist[v] < c:
continue
for t, cost in g[v]:
if dist[v] + cost < dist[t]:
dist[t] = dist[v] + cost
heappush(que, (t, dist[t]))
for i in xrange(V):
print dist[i] if dist[i]<INF else "INF" | File "/tmp/tmpdba3i7h_/tmp4vweaaly.py", line 21
print dist[i] if dist[i]<INF else "INF"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s745321338 | p02361 | u408260374 | 1474986031 | Python | Python3 | py | Runtime Error | 0 | 0 | 1899 | import heapq
class Edge:
def __init__(self, dst, weight):
self.dst, self.weight = dst, weight
def __lt__(self, e):
return self.weight > e.weight
class Graph:
def __init__(self, V):
self.V = V
self.E = [[] for _ in range(V)]
def add_edge(self, src, dst, weight):
self.E[src].append(Edge(dst, weight))
class ShortestPath:
"""Dijkstra's algorithm : find the shortest path from a vertex
Complexity: O(E + log(V))
used in GRL1A(AOJ)
"""
def __init__(self, G, INF=10**9):
""" V: the number of vertexes
E: adjacency list (all edge in E must be 0 or positive)
start: start vertex
INF: Infinity distance
"""
self.G, self.INF = G, INF
class Node:
def __init__(self, v, cost):
self.v, self.cost = v, cost
def __lt__(self, n):
return self.cost > n.cost
def dijkstra(self, start, goal=None):
que = list()
self.dist = [self.INF] * self.G.V # distance from start
self.dist[start] = 0
heapq.heappush(que, self.Node(start, 0))
while len(que) > 0:
n = heapq.heappop(que)
if self.dist[n.v] < n.cost:
continue
if goal is not None and n.v == goal:
return
for e in self.G.E[n.v]:
if self.dist[n.v] + e.weight < self.dist[e.dst]:
self.dist[e.dst] = self.dist[n.v] + e.weight
heapq.heappush(que, self.Node(e.dst, self.dist[e.dst]))
self.prev[e.dst] = n.v
V, E, start = map(int, input().split())
G = Graph(V)
for _ in range(E):
s, t, d = map(int, input().split())
G.add_edge(s, t, d)
INF = 10**9
sp = ShortestPath(G, INF)
sp.dijkstra(start)
for i in range(G.V):
print("INF" if sp.dist[i] == INF else sp.dist[i]) | Traceback (most recent call last):
File "/tmp/tmpsfqwf1_m/tmp35n0sn_i.py", line 60, in <module>
V, E, start = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s337845818 | p02361 | u408260374 | 1474986279 | Python | Python3 | py | Runtime Error | 0 | 0 | 2102 | import heapq
class Edge:
def __init__(self, dst, weight):
self.dst, self.weight = dst, weight
def __lt__(self, e):
return self.weight > e.weight
class Graph:
def __init__(self, V):
self.V = V
self.E = [[] for _ in range(V)]
def add_edge(self, src, dst, weight):
self.E[src].append(Edge(dst, weight))
class ShortestPath:
"""Dijkstra's algorithm : find the shortest path from a vertex
Complexity: O(E + log(V))
used in GRL1A(AOJ)
"""
def __init__(self, G, INF=10**9):
""" V: the number of vertexes
E: adjacency list (all edge in E must be 0 or positive)
start: start vertex
INF: Infinity distance
"""
self.G, self.INF = G, INF
class Node:
def __init__(self, v, cost):
self.v, self.cost = v, cost
def __lt__(self, n):
return self.cost < n.cost
def dijkstra(self, start, goal=None):
que = list()
self.dist = [self.INF] * self.G.V # distance from start
self.prev = [-1] * self.G.V # prev vertex of shortest path
self.dist[start] = 0
heapq.heappush(que, self.Node(start, 0))
while len(que) > 0:
cost, v = heapq.heappop(que)
if self.dist[v] < cost:
continue
if goal is not None and v == goal:
return
for e in self.E[v]:
if self.dist[v] + e.weight < self.dist[e.dst]:
self.dist[e.dst] = self.dist[v] + e.weight
heapq.heappush(que, self.Node(e.dst, self.dist[e.dst]))
self.prev[e.dst] = v
def getPath(self, end):
path = [end]
while self.prev[end] != -1:
end = self.prev[end]
return path[::-1]
V, E, start = map(int, input().split())
G = Graph(V)
for _ in range(E):
s, t, d = map(int, input().split())
G.add_edge(s, t, d)
INF = 10**9
sp = ShortestPath(G, INF)
sp.dijkstra(start)
for i in range(G.V):
print("INF" if sp.dist[i] == INF else sp.dist[i]) | Traceback (most recent call last):
File "/tmp/tmp4hbrydd9/tmpv134w7sl.py", line 67, in <module>
V, E, start = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s819111838 | p02361 | u408260374 | 1474986762 | Python | Python3 | py | Runtime Error | 0 | 0 | 2103 | from heapq import heapify, heappush, heappop
from collections import Counter, defaultdict, deque, OrderedDict
from sys import setrecursionlimit as setreclim
from sys import maxsize
from bisect import bisect_left, bisect, insort_left, insort
from math import ceil, log, factorial, hypot, pi
from fractions import gcd
from copy import deepcopy
from functools import reduce
from operator import mul
from itertools import product, permutations, combinations, accumulate, cycle
from string import ascii_uppercase, ascii_lowercase, ascii_letters, digits, hexdigits, octdigits
????
prod = lambda l: reduce(mul, l)
prodmod = lambda l, mod: reduce(lambda x, y: mul(x,y)%mod, l)
????
class Dijkstra:
????????"""Dijkstra's algorithm : find the shortest path from a vertex
??????????????used in GRL1A(AOJ)
????????"""
????
????????def __init__(self, V, E, start, INF=10**9):
????????????????""" V: the number of vertexes
????????????????????????E: adjacency list
????????????????????????start: start vertex
????????????????????????INF: Infinity distance
????????????????"""
????????????????self.V = V
????????????????self.E = E
????????????????self.dijkstra(start, INF)
????
????????def dijkstra(self, start, INF):
????????????????que = list()
????????????????self.distance = [INF] * self.V # distance from start
????????????????self.distance[start] = 0
????????????????heappush(que, (0, start))
????
????????????????while len(que) > 0:
????????????????????????dist, v = heappop(que)
????????????????????????if self.distance[v] < dist: continue
????????????????????????for to, cost in self.E[v]:
????????????????????????????????if self.distance[v] + cost < self.distance[to]:
????????????????????????????????????????self.distance[to] = self.distance[v] + cost
????????????????????????????????????????heappush(que, (self.distance[to], to))
????
V, E, r = map(int, input().split())
INF = 10**10
edge = [[] for _ in range(V)]
for i in range(E):
????????s, t, cost = map(int, input().split())
????????edge[s].append((t, cost))
sp = Dijkstra(V, edge, r, INF)
for d in sp.distance:
????????print(d if d != INF else 'INF') | File "/tmp/tmpzsgmjfaz/tmpsipx8d6q.py", line 13
????
^
SyntaxError: invalid syntax
| |
s324059661 | p02361 | u279546122 | 1485588850 | Python | Python3 | py | Runtime Error | 30 | 7992 | 744 | #!usr/bin/env python3
from collections import defaultdict
def main():
#Read stdin
fl = input().split(" ")
V = int(fl[0])
E = int(fl[1])
R = int(fl[2])
#Adjacency list
G = defaultdict(list)
for i in range(int(E)):
s, t, w = [int(x) for x in input().split(" ")]
G[s].append((t,w))
#initialized
visited = []
#unseen = [R]
d = {}
d[0] = 0
q = [R]
while q != []:
u = q.pop(0)
if u not in visited:
for v in G[u]:
if v[0] not in visited:
d[v[0]] = d[u] + v[1]
q.append(v[0])
visited.append(u)
for k in d.keys():
print(d[k])
if __name__ == '__main__':
main() | Traceback (most recent call last):
File "/tmp/tmpgv42wnba/tmp7yfyjt8l.py", line 37, in <module>
main()
File "/tmp/tmpgv42wnba/tmp7yfyjt8l.py", line 8, in main
fl = input().split(" ")
^^^^^^^
EOFError: EOF when reading a line
| |
s405412201 | p02361 | u279546122 | 1485831086 | Python | Python3 | py | Runtime Error | 0 | 0 | 787 | def main():
#Read stdin
fl = input().split(" ")
V = int(fl[0])
E = int(fl[1])
R = int(fl[2])
#Adjacency list
G = defaultdict(list)
for i in range(int(E)):
s, t, w = [int(x) for x in input().split(" ")]
G[s].append((t,w))
#initialized
d = {}
INF = float('inf')
#INF = 10001
for i in range(V):
d[i] = INF
d[R] = 0
q = [R]
while q:
#u = heappop(q)
u = q.pop(0)
for v in G[u]:
if d[v[0]] > d[u] + v[1]:
d[v[0]] = d[u] + v[1]
#heappush(q, v[0])
q.append(v[0])
for k in d.keys():
if d[k] == float('inf'):
print("INF")
else:
print(d[k])
if __name__ == '__main__':
main() | Traceback (most recent call last):
File "/tmp/tmpcu7c4g33/tmps7p77_n8.py", line 38, in <module>
main()
File "/tmp/tmpcu7c4g33/tmps7p77_n8.py", line 3, in main
fl = input().split(" ")
^^^^^^^
EOFError: EOF when reading a line
| |
s560056381 | p02361 | u279546122 | 1485833144 | Python | Python3 | py | Runtime Error | 0 | 0 | 761 | #!usr/bin/env python3
#from collections import defaultdict
def main():
#Read stdin
fl = input().split(" ")
V = int(fl[0])
E = int(fl[1])
R = int(fl[2])
#Adjacency list
G = defaultdict(list)
for i in range(int(E)):
s, t, w = [int(x) for x in input().split(" ")]
#initialized
d = {}
INF = float('inf')
#INF = 10001
for i in range(V):
d[i] = INF
d[R] = 0
q = [R]
while q:
u = q.pop(0)
for v in G[u]:
if d[v[0]] > d[u] + v[1]:
d[v[0]] = d[u] + v[1]
q.append(v[0])
for k in d.keys():
if d[k] == float('inf'):
print("INF")
else:
print(d[k])
if __name__ == '__main__':
main() | Traceback (most recent call last):
File "/tmp/tmpe6wy5iqy/tmpx_7_xu59.py", line 38, in <module>
main()
File "/tmp/tmpe6wy5iqy/tmpx_7_xu59.py", line 6, in main
fl = input().split(" ")
^^^^^^^
EOFError: EOF when reading a line
| |
s834860444 | p02361 | u279546122 | 1485922747 | Python | Python3 | py | Runtime Error | 0 | 0 | 1219 | #!usr/bin/env python3
'''
time score 7.88 for list
time score 03.17 for deque
time score 03.22 for defaultdict(dict)
'''
from collections import defaultdict
from collections import deque
#import time
def main():
# Read stdin
start = time.clock()
fl = input().split(" ")
V = int(fl[0])
E = int(fl[1])
R = int(fl[2])
# Adjacency list
G = defaultdict(list)
for i in range(E):
s, t, w = [int(x) for x in input().split(" ")]
G[s].append((t, w))
# initialized
d = {}
INF = float('inf')
# INF = 10001
nodes_list = range(V)
for i in nodes_list:
d[i] = INF
d[R] = 0
# deque is better than list aka double link list O(1) for pop head and append
q = deque([R])
while q:
# u = heappop(q)
u = q.popleft()
for v in G[u]:
if d[v[0]] > d[u] + v[1]:
d[v[0]] = d[u] + v[1]
# heappush(q, v[0])
q.append(v[0])
for k in nodes_list:
if d[k] == float('inf'):
print("INF")
else:
print(d[k])
#end = time.clock() - start
#print('Computation time : {}'.format(end))
if __name__ == '__main__':
main() | Traceback (most recent call last):
File "/tmp/tmpr6fyuthf/tmpo7m_387e.py", line 54, in <module>
main()
File "/tmp/tmpr6fyuthf/tmpo7m_387e.py", line 16, in main
start = time.clock()
^^^^
NameError: name 'time' is not defined
| |
s755261679 | p02361 | u798803522 | 1486694169 | Python | Python3 | py | Runtime Error | 0 | 0 | 1124 | from collections import defaultdict
import heapq
with open("input.txt","r") as f:
vertice,edge,source = map(int,input().split(" "))
link = [[] for n in range(vertice)]
weight = defaultdict(dict)
for e in range(edge):
i,j,w = map(int,input().split(" "))
link[i].append(j)
weight[i].update({j:w})
#print(weight,link)
for v in range(vertice):
goal = v
queue = []
heapq.heappush(queue,[0,source])
went = set()
while queue != []:
#print(queue)
now_cost,here = heapq.heappop(queue)
#print(now_cost,here,queue)
if here == goal:
print(now_cost)
break
can_go = link[here]
not_went = set(can_go) - went
#print(v,here,now_cost,not_went,queue)
for nw in not_went:
next_cost = now_cost + weight[here][nw]
heapq.heappush(queue,(next_cost,nw))
went = went | {here}
queue.sort(key=lambda x:x[1],reverse=True)
else:
print("INF")
| Traceback (most recent call last):
File "/tmp/tmp3cs7cpz8/tmpfm4cpqt1.py", line 4, in <module>
with open("input.txt","r") as f:
^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'input.txt'
| |
s822895185 | p02361 | u798803522 | 1486695340 | Python | Python3 | py | Runtime Error | 20 | 7916 | 928 | from collections import defaultdict
import heapq
vertice,edge,source = map(int,input().split(" "))
link = defaultdict(dict)
weight = defaultdict(dict)
for e in range(edge):
i,j,w = map(int,input().split(" "))
link[i] = link.get(i,set()) | {j}
weight[i].update({j:w})
#print(weight,link)
for v in range(vertice):
goal = v
queue = []
heapq.heappush(queue,(0,source))
heapq.heapify(queue)
went = set()
while queue != []:
#print(queue)
now_cost,here = heapq.heappop(queue)
#print(now_cost,here,queue)
if here == goal:
print(now_cost)
break
can_go = link[here]
not_went = can_go - went
#print(v,here,now_cost,not_went,queue)
for nw in not_went:
next_cost = now_cost + weight[here][nw]
heapq.heappush(queue,(next_cost,nw))
went = went | {here}
else:
print("INF") | Traceback (most recent call last):
File "/tmp/tmpy86726fl/tmpxm89k_5h.py", line 5, in <module>
vertice,edge,source = map(int,input().split(" "))
^^^^^^^
EOFError: EOF when reading a line
| |
s274563147 | p02361 | u798803522 | 1486695477 | Python | Python3 | py | Runtime Error | 0 | 0 | 1095 | from collections import defaultdict
import heapq
with open("input.txt","r") as f:
vertice,edge,source = map(int,f.readline().split(" "))
link = defaultdict(dict)
weight = defaultdict(dict)
for e in range(edge):
i,j,w = map(int,f.readline().split(" "))
link[i] = link.get(i,set()) | {j}
weight[i].update({j:w})
#print(weight,link)
for v in range(vertice):
goal = v
queue = []
heapq.heappush(queue,(0,source))
heapq.heapify(queue)
went = set()
while queue != []:
#print(queue)
now_cost,here = heapq.heappop(queue)
#print(now_cost,here,queue)
if here == goal:
print(now_cost)
break
can_go = link[here]
not_went = set(can_go) - went
#print(v,here,now_cost,not_went,queue)
for nw in not_went:
next_cost = now_cost + weight[here][nw]
heapq.heappush(queue,(next_cost,nw))
went = went | {here}
else:
print("INF") | Traceback (most recent call last):
File "/tmp/tmpplo1hh97/tmplyh_0xjx.py", line 4, in <module>
with open("input.txt","r") as f:
^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'input.txt'
| |
s667556261 | p02361 | u798803522 | 1486703492 | Python | Python3 | py | Runtime Error | 0 | 0 | 772 | from collections import defaultdict
import heapq
vertice,edge,source = map(int,input().split(" "))
link = defaultdict(dict)
weight = defaultdict(dict)
answer = [-1] * vertice
for e in range(edge):
i,j,w = map(int,input().split(" "))
link[i] = link.get(i,set()) | {j}
weight[i].update({j:w})
goal = v
queue = []
heapq.heappush(queue,(0,source))
heapq.heapify(queue)
while queue:
#print(queue)
now_cost,here = heapq.heappop(queue)
#print(now_cost,here,queue)
if answer[here] > -1:
continue
answer[here] = now_cost
#print(v,here,now_cost,not_went,queue)
for nw in link[here]:
if answer[nw] == -1:
heapq.heappush(queue,(now_cost + weight[here][nw],nw))
for a in answer:
print(a if a != -1 else "INF") | Traceback (most recent call last):
File "/tmp/tmp5v_jmajy/tmp1rmfahdw.py", line 5, in <module>
vertice,edge,source = map(int,input().split(" "))
^^^^^^^
EOFError: EOF when reading a line
| |
s151243499 | p02361 | u798803522 | 1486703608 | Python | Python3 | py | Runtime Error | 0 | 0 | 772 | from collections import defaultdict
import heapq
vertice,edge,source = map(int,input().split(" "))
link = defaultdict(dict)
weight = defaultdict(dict)
answer = [-1] * vertice
for e in range(edge):
i,j,w = map(int,input().split(" "))
link[i] = link.get(i,set()) | {j}
weight[i].update({j:w})
goal = v
queue = []
heapq.heappush(queue,(0,source))
heapq.heapify(queue)
while queue:
#print(queue)
now_cost,here = heapq.heappop(queue)
#print(now_cost,here,queue)
if answer[here] > -1:
continue
answer[here] = now_cost
#print(v,here,now_cost,not_went,queue)
for nw in link[here]:
if answer[nw] == -1:
heapq.heappush(queue,(now_cost + weight[here][nw],nw))
for a in answer:
print(a if a != -1 else "INF") | Traceback (most recent call last):
File "/tmp/tmpi7bh6sea/tmp42337h01.py", line 5, in <module>
vertice,edge,source = map(int,input().split(" "))
^^^^^^^
EOFError: EOF when reading a line
| |
s231473246 | p02361 | u279546122 | 1487571812 | Python | Python3 | py | Runtime Error | 0 | 0 | 723 | from collections import defaultdict
from heapq import heappush, heappop, heapify
from sys import stdin
def sp(G,R,V):
d = {}
q = [(0, R)]
d[R] = 0
heapify(q)
while q:
(cost, v) = heappop(q)
for (next, c) in G[v].items():
if v not in d:
d[v] = c
elif d[next] > d[v] + c:
d[next] = d[v] + c
heappush(q, (d[next], next))
return d
V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
s, t, w = [int(x) for x in stdin
.readline().split()]
G[s][t] = w
d = sp(G, R, V)
for k in range(V):
if k not in d:
print("INF")
else:
print(d[k]) | Traceback (most recent call last):
File "/tmp/tmpzvvf2k_p/tmpjhxa0044.py", line 23, in <module>
V, E, R = [int(x) for x in stdin.readline().split()]
^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
| |
s259566687 | p02361 | u279546122 | 1487571836 | Python | Python3 | py | Runtime Error | 0 | 0 | 721 | from collections import defaultdict
from heapq import heappush, heappop, heapify
from sys import stdin
def sp(G,R,V):
d = {}
q = [(0, R)]
d[R] = 0
heapify(q)
while q:
(cost, v) = heappop(q)
for (next, c) in G[v].items():
if v not in d:
d[v] = c
elif d[next] > d[v] + c:
d[next] = d[v] + c
heappush(q, (d[next], next))
return d
V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
s, t, w = [int(x) for x in stdin
.readline().split()]
G[s][t] = w
d = sp(G, R, V)
for k in range(V):
if k not in d:
print("INF")
else:
print(d[k]) | Traceback (most recent call last):
File "/tmp/tmpq76illk5/tmpxpkgljup.py", line 21, in <module>
V, E, R = [int(x) for x in stdin.readline().split()]
^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
| |
s559841448 | p02361 | u279546122 | 1487571874 | Python | Python3 | py | Runtime Error | 0 | 0 | 815 | from collections import defaultdict
from heapq import heappush, heappop, heapify
from sys import stdin
#import time
def sp(G,R,V):
d = {}
q = [(0, R)]
d[R] = 0
heapify(q)
while q:
(cost, v) = heappop(q)
for (next, c) in G[v].items():
if v not in d:
d[v] = c
elif d[next] > d[v] + c:
d[next] = d[v] + c
heappush(q, (d[next], next))
return d
#start = time.clock()
V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
s, t, w = [int(x) for x in stdin
.readline().split()]
G[s][t] = w
d = sp(G, R, V)
for k in range(V):
if k not in d:
print("INF")
else:
print(d[k])
#print('Computation time : {}'.format(time.clock()-start)) | Traceback (most recent call last):
File "/tmp/tmpwe3urers/tmpjwf0he3z.py", line 23, in <module>
V, E, R = [int(x) for x in stdin.readline().split()]
^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
| |
s595472742 | p02361 | u923668099 | 1495867663 | Python | Python3 | py | Runtime Error | 30 | 7804 | 753 | import sys
from heapq import heappush, heappop
inf = 1<<30
def solve():
N, M, s = map(int, sys.stdin.readline().split())
Adj = [[] for i in range(N)]
for i in range(M):
ui, vi, ci = map(int, sys.stdin.readline().split())
Adj[ui].append((vi, ci))
d = dijkstra(N, Adj, s)
for di in d:
print(di if di < inf else 'INF')
def dijkstra(N, Adj, s):
d = [inf] * N
d[s] = 0
pq = [(0, s)]
for i in range(N - 1):
while 1:
di, v = heappop(pq)
if di == d[v]:
break
for u, c in Adj[v]:
if d[v] + c < d[u]:
d[u] = d[v] + c
heappush(pq, (d[u], u))
return d
if __name__ == '__main__':
solve() | Traceback (most recent call last):
File "/tmp/tmpdixq3296/tmpuvd5xbnl.py", line 39, in <module>
solve()
File "/tmp/tmpdixq3296/tmpuvd5xbnl.py", line 7, in solve
N, M, s = map(int, sys.stdin.readline().split())
^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
| |
s045257157 | p02361 | u845643816 | 1511971038 | Python | Python3 | py | Runtime Error | 0 | 0 | 1081 | v, e, r = list(map(int, input().split()))
edgeList = [[0, 0, 0] for i in range(e)]
rootList = [-1 for i in range(v)]
parent = [-1 for i in range(v)]
lenList = [0 for i in range(v)]
for i in range(e):
a = list(map(int, input().split()))
edgeList[e] = [a[2], a[0], a[1]]
rootList = [-1 for i in range(n)]
parent = [0 for i in range(n)]
lenList = [float("inf") for i in range(n)]
lenList[r] = 0
def getRoot(x):
root = rootList[x]
if root < 0:
rootList[x] = x
elif root != x:
rootList[x] = getRoot(root)
return rootList[x]
flag = True
while flag:
flag = False
edgeList.sort(key=lambda x: (x[0] + lenList[x[1]]))
for e in edgeList: # weight:e[0], e[1]->e[2]
if e[2] == 0:
continue
x = getRoot(e[1])
y = getRoot(e[2])
if x == r != y:
parent[e[2]] = e[1]
lenList[e[2]] = lenList[e[1]] + e[0]
rootList[y] = r
flag = True
break
for i in lenList:
if i == float("inf"):
print("INF")
else:
print(i, j) | Traceback (most recent call last):
File "/tmp/tmpphf5yki1/tmpo6662swh.py", line 1, in <module>
v, e, r = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s714387232 | p02361 | u835844653 | 1512197251 | Python | Python3 | py | Runtime Error | 40 | 6840 | 719 | '''
????????£????????????????????????
'''
import queue
v,e,s=map(int,input().split())
edge=[]
inf =1000000100
for i in range(v):
edge.append([])
for i in range(e):
vs,vt,d=map(int,input().split())
edge[vs].append((vt,d))
dis=[]
for i in range(v):
dis.append(inf)
dis[s]=0
q = queue.PriorityQueue()
q.put((0,s))
finished=0
while(not finished==v):
now=q.get()
# print("get",now)
nowv=now[1]
finished+=1
for (vt,d) in edge[nowv]:
if dis[vt]>dis[nowv]+d:
dis[vt]=dis[nowv]+d
q.put((dis[vt],vt))
# print("put",(dis[vt],vt))
for i in range(v):
if dis[i]>=inf:
print("INF")
else:
print(dis[i]) | Traceback (most recent call last):
File "/tmp/tmplu4covd2/tmpmrzwpju4.py", line 7, in <module>
v,e,s=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s588293368 | p02361 | u835844653 | 1512199718 | Python | Python3 | py | Runtime Error | 0 | 0 | 883 | '''
????????£????????????????????????
'''
import queue
v,e,s=map(int,input().split())
edge=[]
inf =1000000100
for i in range(v):
edge.append([])
for i in range(e):
vs,vt,d=map(int,input().split())
edge[vs].append((vt,d))
dis=[]
for i in range(v):
dis.append(inf)
dis[s]=0
q = queue.PriorityQueue()
q.put((0,s))
'''
while(not q.empty()):
now=q.get()
nowv=now[1]
for (vt,d) in edge[nowv]:
if dis[vt]>dis[nowv]+d:
dis[vt]=dis[nowv]+d
q.put((dis[vt],vt))
'''
finished=0
while(finished<v and not q.empty()):
now=q.get()
nowv=now[1]
if now[0]>dis[nowv] continue;
for (vt,d) in edge[nowv]:
if dis[vt]>dis[nowv]+d:
dis[vt]=dis[nowv]+d
q.put((dis[vt],vt))
finished+=1
for i in range(v):
if dis[i]>=inf:
print("INF")
else:
print(dis[i]) | File "/tmp/tmp3f4rj7jb/tmpn_31cowk.py", line 40
if now[0]>dis[nowv] continue;
^^^^^^^^
SyntaxError: invalid syntax
| |
s044388606 | p02361 | u904185678 | 1514481255 | Python | Python3 | py | Runtime Error | 20 | 5744 | 3788 | def main():
[V,E,r]=input().split(" ")
V=int(V)
E=int(E)
r=int(r)
edgeset=[]
for i in range(E):
[s,t,d]=input().split(" ")
edgeset.append([int(s),int(t),int(d)])
'''read the edge information and put them to edgeset'''
setS=[]
setV=[[i,500000*10000+1] for i in range(V)]
setdist=[500000*10000+1 for i in range(V)]
'''generate the sets for optimized vertices, unoptimized vertices, distance respectively'''
setS.append(r)
setV[0][0]=0
setV[0][1]=-1
setdist[r]=0
setV=binary_heap_building(setV)
'''initiating data'''
for i in range(V-1):
nowvert=setS[-1]
'''the on process vertices'''
for j in range(len(edgeset)):
if(nowvert==edgeset[j][0]):
'''try to find all the linkage of this on process vertices'''
newdist=edgeset[j][2]+setdist[nowvert]
olddist=setdist[edgeset[j][1]]
'''calculating the new distance including the on process vertices'''
if(newdist<olddist):
setdist[edgeset[j][1]]=newdist
setV=binary_heap_change(setV,newdist,edgeset[j][1])
'''making comparision to determin which to stay'''
setS.append(setV[1][0])
setV=binary_heap_deletion(setV)
'''find the next on process vertice'''
for i in range(V):
if(setdist[i]==500000*10000+1):
print('INF')
else:
print(setdist[i])
'''data output'''
return 0
def binary_heap_building(dataset):
for i in [len(dataset)-x-1 for x in range(len(dataset))]:
if(dataset[i][1]<dataset[int(i/2)][1]):
trans=dataset[i]
dataset[i]=dataset[int(i/2)]
dataset[int(i/2)]=trans
return dataset
def binary_heap_change(dataset,newdata,position):
biposition=[a[0] for a in dataset].index(position)
dataset[biposition][1]=newdata
for i in range(999999):
if(newdata<dataset[int(biposition/2)][1]):
trans=dataset[biposition]
dataset[biposition]=dataset[int(biposition/2)]
dataset[int(biposition/2)]=trans
biposition=int(biposition/2)
elif(biposition*2<len(dataset) and biposition*2+1<len(dataset) and (newdata>dataset[biposition*2][1] or newdata>dataset[biposition*2+1][1])):
if(dataset[biposition*2][1]>=dataset[biposition*2+1][1]):
trans=dataset[biposition]
dataset[biposition]=dataset[biposition*2+1]
dataset[biposition*2+1]=trans
biposition=biposition*2+1
else:
trans=dataset[biposition]
dataset[biposition]=dataset[biposition*2]
dataset[biposition*2]=trans
biposition=biposition*2
else:
break
return dataset
def binary_heap_deletion(dataset):
trans=dataset[1]
dataset[1]=dataset[-1]
dataset[-1]=trans
dataset.pop(-1)
biposition=1
for i in range(999999):
if(biposition*2<len(dataset) and biposition*2+1<len(dataset) and (newdata>dataset[biposition*2][1] or newdata>dataset[biposition*2+1][1])):
if(dataset[biposition*2][1]>=dataset[biposition*2+1][1]):
trans=dataset[biposition]
dataset[biposition]=dataset[biposition*2+1]
dataset[biposition*2+1]=trans
biposition=biposition*2+1
else:
trans=dataset[biposition]
dataset[biposition]=dataset[biposition*2]
dataset[biposition*2]=trans
biposition=biposition*2
else:
break
return dataset
main() | Traceback (most recent call last):
File "/tmp/tmp4lk6j3tz/tmp39c8ko58.py", line 109, in <module>
main()
File "/tmp/tmp4lk6j3tz/tmp39c8ko58.py", line 2, in main
[V,E,r]=input().split(" ")
^^^^^^^
EOFError: EOF when reading a line
| |
s167894537 | p02361 | u742505495 | 1523428514 | Python | Python3 | py | Runtime Error | 0 | 0 | 739 | import queue
def Dijkstra(vertex,edges,start):
weight = [0 if i==start else float("inf") for i in range(vertex)]
Q = queue.PriorityQueue()
Q.put((weight[start],start))
while(not Q.Empty()):
cur = Q.get()
if weight[cur[1]] < cur[0]:
continue
for j in range(len(edges[cur[1]])):
if weight[edges[cur[1]][j][1]] > weight[cur[1]] + edges[cur[1]][j][2]:
weight[edges[cur[1]][j][1]] = weight[cur[1]] + edges[cur[1]][j][2]
Q.put((weight[edges[cur[1]][j][1]],edges[cur[1]][j][1]))
return weight
V,E,r = map(int,input().split())
edges = [[] for i in range(V)]
for i in range(E):
data = list(map(int,input().split()))
edges[data[0]].append(data)
edges.sort()
w = Dijkstra(V,edges,r)
for i in range(len(w)):
print(w[i])
| Traceback (most recent call last):
File "/tmp/tmpdgpai3xx/tmpz1ikuyc1.py", line 18, in <module>
V,E,r = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s930504301 | p02361 | u825008385 | 1523454596 | Python | Python3 | py | Runtime Error | 0 | 0 | 1160 | # Single Source Shortest Path
infty = 99999
[vertex, edge, r] = list(map(int, input("").split()))
D = [[infty for j in range(vertex)] for i in range(vertex)]
for i in range(edge):
data = list(map(int, input("").split()))
D[data[0]][data[1]] = data[2]
def Dijkstra(root, n):
visited_order = 0
label = [0 for i in range(n)]
global D
global infty
d = D[root]
visited_order += 1
label[root] = visited_order
while visited_order < n:
min_cost = infty
for i in range(n):
if label[i] != 0:
continue
if min_cost > d[i]:
min_cost = d[i]
min_node = i
if min_cost == infty:
break
visited_order += 1
label[min_node] = visited_order
for i in range(n):
if label[i] != 0:
continue
if d[i] > d[min_node] + D[min_node][i]:
d[i] = d[min_node] + D[min_node][i]
return d
'''
result = Dijkstra(r, vertex)
for i in range(vertex):
if i == r:
result[i] = 0
if result[i] == infty:
result[i] = "INF"
print(result[i])
| File "/tmp/tmp8id0i880/tmpz5dlmfgl.py", line 43
'''
^
SyntaxError: unterminated triple-quoted string literal (detected at line 51)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.