s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s618148243
p03599
u642905089
1505614824
Python
Python (3.4.3)
py
Runtime Error
17
3064
668
a,b,c,d,e,f = list(map(int,input().split())) a *= 100 b *= 100 def node(w,s): return s/w w,s = 0,0 w += a nodelist = [] nodelistapd = nodelist.append nodedict = {} enode = node(100+e, e) while(1): if w >= f:break if node(w+d,s+d) <= enode: s += d w += d elif node(w+c,s+c) <= enode...
s072674453
p03599
u979554218
1505614680
Python
Python (3.4.3)
py
Runtime Error
17
3064
771
a, b, c, d, e, f = [int(x) for x in input().strip().split()] a *= 100 b *= 100 if f < a + c: print("0 0") raise SystemExit water_cands = set() t = 0 while t <= f: water_cands.add(t) u = t + b while u <= f: water_cands.add(u) u += b t += a rat, wat, sug = 0.0, 0, 0 for w in wate...
s600589484
p03600
u454093752
1601024641
Python
PyPy3 (7.3.0)
py
Runtime Error
146
82112
1529
import heapq import sys N = int(input()) A = [] for i in range(N): B = list(map(int, input().split())) A.append(B) T = {} for i in range(N): for j in range(i, N): if i != j: T[(i, j)] = A[i][j] T = sorted(T.items(), key = lambda x:x[1], reverse=True) def dijkstra(V, start, Cost): ...
s930621102
p03600
u454093752
1601023718
Python
PyPy3 (7.3.0)
py
Runtime Error
175
82176
1127
import heapq import sys N = int(input()) A = [] for i in range(N): B = list(map(int, input().split())) A.append(B) T = {} for i in range(N): for j in range(i, N): if i != j: T[(i, j)] = A[i][j] T = sorted(T.items(), key = lambda x:x[1]) def dijkstra(V, start, Cost): routes = [flo...
s589606257
p03600
u819135704
1598815247
Python
Python (3.8.2)
py
Runtime Error
139
38288
310
import numpy as np N = int(input()) A = np.array([input().split() for _ in range(N)], dtype=np.int64) fill_diagonal(A, 10**9) ans = 0 for i in range(N): for j in range(i+1,N): d = np.min(A[i]+A[j]) if A[i][j] < d: ans += A[i][j] elif d < A[i][j]: print(-1) exit() print(ans)
s619612328
p03600
u074220993
1598414341
Python
Python (3.8.2)
py
Runtime Error
2206
18408
536
N = int(input()) A = [[(int(x),True) for x in input().split()] for _ in range(N)] ans = 0 for k in range(N): for i in range(N): if i == k: continue for j in range(i+1,N): if j == k: continue Aikj = A[i][k][0] + A[k][j][0] if A[i][j][0] > Aikj: ans...
s653502202
p03600
u074220993
1598414116
Python
Python (3.8.2)
py
Runtime Error
2206
18424
547
import sys N = int(input()) A = [[(int(x),True) for x in input().split()] for _ in range(N)] ans = 0 for k in range(N): for i in range(N): if i == k: continue for j in range(i+1,N): if j == k: continue Aikj = A[i][k][0] + A[k][j][0] if A[i][j][0] > Aikj: ...
s305127512
p03600
u074220993
1598413997
Python
Python (3.8.2)
py
Runtime Error
130
18316
545
import sys N = int(input()) A = [[(int(x),True) for x in input().split()] for _ in range(N)] for k in range(N): for i in range(N): if i == k: continue for j in range(i+1,N): if j == k: continue Aikj = A[i][k][0] + A[k][j][0] if A[i][j][0] > Aikj: ...
s871527530
p03600
u074220993
1598413581
Python
Python (3.8.2)
py
Runtime Error
129
18248
560
import sys N = int(input()) A = [[(int(x),True) for x in input().split()] for _ in range(N)] for k in range(N): for i in range(N): if i == k: continue for j in range(i+1,N): if j == k: continue Aikj = A[i][k][0] + A[k][j][0] if A[i][j][0] > Aikj: ...
s743618239
p03600
u786020649
1596154400
Python
Python (3.8.2)
py
Runtime Error
2206
34148
2197
import sys from copy import deepcopy from collections import defaultdict readline=sys.stdin.readline read=sys.stdin.read from collections import defaultdict from heapq import heapify,heappop,heappush class Graph(): def __init__(self, vertices, edges, weighted=True, directed=False): self.vertices=vertices ...
s724802872
p03600
u786020649
1596152922
Python
Python (3.8.2)
py
Runtime Error
2206
16440
730
import sys from copy import deepcopy from collections import defaultdict readline=sys.stdin.readline read=sys.stdin.read def main(): n=int(readline()) a=[list(map(int,l.split())) for l in read().splitlines()] cost=deepcopy(a) for k in range(n): for i in range(n): for j in range(n): ...
s388393951
p03600
u786020649
1596152333
Python
Python (3.8.2)
py
Runtime Error
24
8848
665
import sys import deepcopy from copy readline=sys.stdin.readline read=sys.stdin.read def main(): n=int(readline()) a=[list(map(int,lst)) for lst in read().splitlines()] cost=deepcopy(a) for k in range(n): for i in range(n): for j in range(n): cost[i][j]=min(cost[i][j...
s207010889
p03600
u786020649
1596152183
Python
Python (3.8.2)
py
Runtime Error
2206
32052
844
import sys from collections import defaultdict readline=sys.stdin.readline read=sys.stdin.read def main(): n=int(readline()) a=[list(map(int,sys.stdin.readline().split())) for _ in range(n)] wts=dict(((i,j),a[i][j]) for i in range(n) for j in range(n)) cost=defaultdict(int) cost.update(wts) for...
s280603010
p03600
u786020649
1596151646
Python
Python (3.8.2)
py
Runtime Error
2206
32152
844
import sys from collections import defaultdict readline=sys.stdin.readline read=sys.stdin.read def main(): n=int(readline()) a=[list(map(int,sys.stdin.readline().split())) for _ in range(n)] wts=dict(((i,j),a[i][j]) for i in range(n) for j in range(n)) cost=defaultdict(int) cost.update(wts) for...
s138423935
p03600
u786020649
1596150906
Python
Python (3.8.2)
py
Runtime Error
2206
31932
844
import sys from collections import defaultdict readline=sys.stdin.readline read=sys.stdin.read def main(): n=int(readline()) a=[list(map(int,sys.stdin.readline().split())) for _ in range(n)] wts=dict(((i,j),a[i][j]) for i in range(n) for j in range(n)) cost=defaultdict(int) cost.update(wts) for...
s555448009
p03600
u786020649
1596150695
Python
Python (3.8.2)
py
Runtime Error
2207
44864
837
import sys from collections import defaultdict readline=sys.stdin.readline read=sys.stdin.read def main(): n=int(readline()) a=[list(map(int,sys.stdin.readline().split())) for _ in range(n)] wts=dict(((i,j),a[i][j]) for i in range(n) for j in range(n)) cost=defaultdict(int) cost.update(wts) for...
s080954227
p03600
u223663729
1595086644
Python
Python (3.8.2)
py
Runtime Error
170
37560
468
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall import numpy as np N = int(input()) A = np.loadtxt(open(0), dtype=np.int) D = csgraph_from_dense(A) D = floyd_warshall(D, directed=False) if (A == D).all(): ans = 0 D += np.identity(N, int) * (1 << 60) for i in range(N): for j in ...
s249100056
p03600
u279493135
1595071967
Python
PyPy3 (7.3.0)
py
Runtime Error
100
74840
1541
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement from operator import itemgetter, mul from copy import deepcopy from s...
s468194062
p03600
u227082700
1591479300
Python
PyPy3 (2.4.0)
py
Runtime Error
218
40940
422
n=int(input()) a=[list(map(int,input().split()))for _ in range(n)] b=[i.copy() for i in a] c=[n*[1]for _ in range(n)] for k in range(n): for i in range(n): for j in range(n): b[i][j]=min(b[i][j],b[i][k]+b[k][j]) if a[i][j]==a[i][k]+a[k][j]: if i!=j and i!=k and j!=k: c[i][j]=0 if a!=...
s075620098
p03600
u936985471
1591476844
Python
PyPy3 (2.4.0)
py
Runtime Error
208
40940
1076
import sys readline = sys.stdin.readline N = int(readline()) A = [None] * N for i in range(N): A[i] = list(map(int,readline().split())) # まずワーシャルフロイド表を作る # ワーシャルフロイド表より大きな数値が元の表にあったら、最短距離の表ではないので-1 # 最短距離の表になっているのであれば、 # A[1][3]に行くときにA[1][2] + A[2][3]となるのであれば、 # A[1][3]のほうだけansに記録していく import numpy as np from sc...
s868263312
p03600
u606878291
1591245220
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
654
from itertools import product, combinations import numpy as np N = int(input()) dp = np.zeros(shape=(N, N), dtype=int) for i in range(N): dp[i] = np.array(list(map(int, input().split(' ')))) original = dp.copy() for k, i in product(range(N), repeat=2): dp[i] = np.minimum(dp[i], dp[i][k] + dp[k]) if np.all...
s998322347
p03600
u892487306
1590536476
Python
PyPy3 (2.4.0)
py
Runtime Error
248
40940
1135
def warshall_floyd(N, A): dist = A.copy() for k in range(N): for i in range(N): for j in range(N): if dist[i][j] > dist[i][k] + dist[k][j]: dist[i][j] = dist[i][k] + dist[k][j] return dist def main(): N = int(input()) A = [list(map(int, input...
s346183371
p03600
u780962115
1589638474
Python
PyPy3 (2.4.0)
py
Runtime Error
175
38640
807
#restoring read network ans=0 import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import floyd_warshall n=int(input()) mat=np.array([[0 for i in range(n)] for j in range(n)],dtype=np.int) data=np.array([[0 for i in range(n)] for j in range(n)],dtype=np.int) for _ in range(n): x=list(ma...
s239152984
p03600
u316464887
1589076528
Python
Python (3.4.3)
py
Runtime Error
144
23240
2748
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): ...
s039790323
p03600
u358254559
1587755992
Python
PyPy3 (2.4.0)
py
Runtime Error
224
40940
187
n=int(input()) a=[list(map(int,input().split())) for i in range(n)] from scipy.sparse.csgraph import floyd_warshall wf=floyd_warshall(a) if not (a==wf).all() : print(-1) exit()
s087698102
p03600
u709304134
1587596636
Python
PyPy3 (2.4.0)
py
Runtime Error
241
43500
726
N = int(input()) INF = 10**10 cost = [[INF]*N for _ in range(N)] for u in range(N): C = list(map(int, input().split())) for v in range(N): if u==v: # INFのままにする continue cost[u][u] = C[u] ans = 0 for u in range(N): for v in range(j+1,N): mn = INF # u-w-vのような経路の中で最小の距離を求...
s363738952
p03600
u709304134
1587596601
Python
PyPy3 (2.4.0)
py
Runtime Error
261
44780
726
N = int(input()) INF = 10**10 cost = [[INF]*N for _ in range(N)] for u in range(N): C = list(map(int, input().split())) for v in range(N): if u==v: # INFのままにする continue cost[u][v] = C[u] ans = 0 for u in range(N): for v in range(j+1,N): mn = INF # u-w-vのような経路の中で最小の距離を求...
s572054225
p03600
u898967808
1587432815
Python
PyPy3 (2.4.0)
py
Runtime Error
238
40940
493
n = int(input()) INF = 10**12 A = [] for i in range(n): A.append(list(map(int,input().split()))) B = [[1]*n for _ in range(n)] G = A.copy() for k in range(n): for i in range(n): for j in range(n): G[i][j] = min(G[i][j], G[i][k]+G[k][j]) if not (i==j or j==k or k==i): if G[i][j] == G[i][k]...
s917863136
p03600
u691018832
1586814591
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38256
993
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from scipy.sparse import csr_matrix from scipy.sparse.csgraph import floyd_warshall n = int(readline()) memo_graph = [list(map(int, readline().split())) for _ in range(n)]...
s426015402
p03600
u298297089
1586313556
Python
PyPy3 (2.4.0)
py
Runtime Error
185
38256
640
from scipy.sparse.csgraph import dijkstra as di n = int(input()) grid = [list(map(int, input().split())) for i in range(n)] dgrid = di(grid) ans = [[0 for i in range(n)] for j in range(n)] for i in range(n): for j in range(n): if grid[i][j] != dgrid[i][j]: print(-1) exit() ans = 0 ...
s099924446
p03600
u731448038
1585679663
Python
PyPy3 (2.4.0)
py
Runtime Error
534
44764
340
n = int(input()) A = [list(map(int, input().split())) for _ in range(n)] ans = 0 cannot = 0 for i in range(n-1): for j in range(i+1,n): detour = min([A[i][k] + A[k][j] for k in range(n) if k!=i and k!=j]) if detour<A[i][j]: cannot = 1 elif detour>A[i][j]: ans += A[i][j] if cannot: print(-1)...
s399041610
p03600
u731448038
1585679566
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38512
333
n = int(intpu()) A = [list(map(int, input().split())) for _ in range(n)] ans = 0 cannot = 0 for i in range(n): for j in range(n): detour = min([A[i][k] + A[k][j] for k in range(n) if k!=i and k!=j]) if detour<A[i][j]: cannot = 1 elif detour>A[i][j]: ans += A[i][j] if cannot: print(-1) else:...
s813275468
p03600
u476604182
1583955570
Python
Python (3.4.3)
py
Runtime Error
18
3064
368
N, *L = map(int, open('0').read().split()) cost = [] for i, m in enumerate(zip(*[iter(L)]*N)): cost.append(list(m)) cost[i][i] = 10**10 ans = 0 for i in range(N): for j in range(i): m = min(cost[i][k]+cost[k][j] for k in range(N)) if m<cost[i][j]: print(-1) import sys sys.exit() if m...
s873571990
p03600
u893063840
1583244944
Python
Python (3.4.3)
py
Runtime Error
2109
20820
670
from scipy.sparse.csgraph import floyd_warshall from scipy.sparse import csr_matrix import numpy as np n = int(input()) a = [list(map(int, input().split())) for _ in range(n)] a = np.array(a) g = csr_matrix(a) dist = floyd_warshall(g) bl = dist == a if bl.all(): sm = dist.sum() for u in range(n): ...
s783534207
p03600
u372144784
1581192918
Python
PyPy3 (2.4.0)
py
Runtime Error
190
40284
938
import sys import itertools read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(readline()) lst1 = [list(map(int,readline().split())) for i in range(n)] from scipy.sparse.csgraph import shortest_path,floyd_warshall from scipy.sparse import csr_matrix lc = c...
s282213954
p03600
u285022453
1577122459
Python
Python (3.4.3)
py
Runtime Error
17
3064
545
def Warshall_Floyd(edges,N): import copy d=copy.deepcopy(edges) for k in range(N): for i in range(N): for j in range(N): d[i][j]=min(d[i][j],d[i][k]+d[k][j]) return d import sys input=sys.stdin.readline.rstrip() N=int(input()) A=[list(map(int, input().split())) for i in range(N)] B=Warshall_F...
s021857070
p03600
u310678820
1574797189
Python
PyPy3 (2.4.0)
py
Runtime Error
229
41068
663
import sys inf = float('inf') N = int(input()) d = [list(map(int, input().split())) for _ in range(N)] edges = [] for i in range(N): for j in range(i+1, N): edges.append((A[i][j], i, j)) edges.sort() for i in range(N): d[i][i] = 0 ans=0 for a in range(N): for b in range(N): flag = True ...
s535306030
p03600
u532966492
1574395587
Python
Python (3.4.3)
py
Runtime Error
1025
17996
475
def main(): import numpy as np import scipy.sparse.csgraph as sp n=int(input()) p=np.array([np.array(list(map(int,input().split()))) for _ in [0]*n]) ans=0 d=np.full((n,n),0) for i in range(n): for j in range(i+1,n): b=p[i][j] if b!=np.sort(p[i]+p[j])[2]: ...
s914181303
p03600
u163320134
1570942282
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38384
1537
from scipy.sparse.csgraph import dijkstra class UnionFind(): def __init__(self,n): self.n=n self.root=[-1]*(n+1) self.rank=[0]*(n+1) def FindRoot(self,x): if self.root[x]<0: return x else: self.root[x]=self.FindRoot(self.root[x]) return self.root[x] def Unite(self,x,y): ...
s373075636
p03600
u163320134
1570941828
Python
Python (3.4.3)
py
Runtime Error
394
26712
604
from scipy.sparse.csgraph import dijkstra n=int(input()) arr=[list(map(int,input().split())) for _ in range(n)] edge=[] for i in range(n): for j in range(n): if i>=j: continue edge.append((arr[i][j],(i,j))) edge=sorted(edge,key=lambda x:x[0]) g=[[float('inf')]*n for _ in range(n)] ans=0 for i in range(...
s064461264
p03600
u803848678
1568405343
Python
PyPy3 (2.4.0)
py
Runtime Error
183
38384
360
for k in range(n): for i in range(n): for j in range(n): if a[i][k] + a[k][j] < a[i][j]: print(-1) exit() elif a[i][k] + a[k][j] == a[i][j] and i!=k!=j: b[i][j] = 0 ans = 0 for i in range(n): for j in range(n): if b[i][j]: ...
s368444566
p03600
u314906167
1566296371
Python
PyPy3 (2.4.0)
py
Runtime Error
516
46556
414
inf = float("inf") N = int(input()) A = [] for _ in range(N): a = [int(s) for s in input().split()] A.append(a) d = [a[:] for a in A] ans = 0 for i in range(N - 1): for j in range(i + 1, N): dmin = min([d[i][k] + d[k][j] for k in range(N) if k not in (i, j)]) if d[i][j] > dmin: p...
s945100115
p03600
u895515293
1560019446
Python
PyPy3 (2.4.0)
py
Runtime Error
229
41308
116
N=int(input()) MP=[list(map(int,input().split())) for i in range(N)] MP2=[] for li in MP: MP2.append(li.copy())
s999495696
p03600
u895515293
1560019375
Python
PyPy3 (2.4.0)
py
Runtime Error
217
40940
116
N= int(input()) MP=[list(map(int,input().split())) for i in range(N)] MP2=[] for li in MP: MP2.append(li.copy())
s999970297
p03600
u895515293
1560019327
Python
PyPy3 (2.4.0)
py
Runtime Error
229
41948
148
N= int(input()) MP=[list(map(int,input().split())) for i in range(N)] MP2=[] for li in MP: MP2.append(li.copy()) MP3=[[-1]*N for _ in range(N)]
s429679461
p03600
u895515293
1560019313
Python
PyPy3 (2.4.0)
py
Runtime Error
222
41180
564
N= int(input()) MP=[list(map(int,input().split())) for i in range(N)] MP2=[] for li in MP: MP2.append(li.copy()) MP3=[[-1]*N for _ in range(N)] # ワーシャルフロイド for k in range(N): for i in range(N): for j in range(N): cand = MP2[i][k] + MP2[k][j] if cand <= MP2[i][j]: ...
s915344165
p03600
u895515293
1560018314
Python
PyPy3 (2.4.0)
py
Runtime Error
248
42076
991
N= int(input()) MP=[list(map(int,input().split())) for i in range(N)] MP2=[] for li in MP: MP2.append(li.copy()) MP3=[[-1]*N for _ in range(N)] # ワーシャルフロイド for k in range(N): for i in range(N): for j in range(N): cand = MP2[i][k] + MP2[k][j] if cand <= MP2[i][j]: ...
s493610206
p03600
u895515293
1560018248
Python
PyPy3 (2.4.0)
py
Runtime Error
259
43868
991
N= int(input()) MP=[list(map(int,input().split())) for i in range(N)] MP2=[] for li in MP: MP2.append(li.copy()) MP3=[[-1]*N for _ in range(N)] # ワーシャルフロイド for k in range(N): for i in range(N): for j in range(N): cand = MP2[i][k] + MP2[k][j] if cand <= MP2[i][j]: ...
s288370259
p03600
u619819312
1554483963
Python
Python (3.4.3)
py
Runtime Error
17
3064
460
from scipy.sparse.csgraph import floyd_warshall as wf n=int(input()) s=[list(map(float,input().split()))for i in range(n)] a=wf(s,directed=False).tolist() if s!=a: print(-1) else: c=0 for i in range(n-1): for j in range(i+1,n): for d in range(n): if d!=i and d!=j: ...
s605451002
p03600
u619819312
1554483870
Python
Python (3.4.3)
py
Runtime Error
2109
20248
450
from scipy.sparse.csgraph import floyd_warshall as wf n=int(input()) s=[list(map(float,input().split()))for i in range(n)] a=wf(s,directed=False).tolist() if s!=a: print(-1) else: c=0 for i in range(n-1): for j in range(i+1,n): for d in range(n): if d!=i and d!=j: ...
s579200103
p03600
u171366497
1554172530
Python
Python (3.4.3)
py
Runtime Error
41
6644
492
N=int(input()) dist=[list(map(int,input().split())) for i in range(N)] ans=sum([sum(dist[i]) for i in range(N)]) ans//=2 for i in range(N): if ans<0:break for j in range(i+1,N): if ans<0:break for k in range(j+1,N): S=sum([dist[i][j],dist[i][k],dist[j][k]])/2 M=max([dist[...
s073700158
p03600
u145035045
1548473399
Python
PyPy3 (2.4.0)
py
Runtime Error
1719
125532
617
INF = 10 ** 20 n = int(input()) edges = [list(map(int, input().split())) for _ in range(n)] dist = [[INF] * n for _ in range(n)] edgeList = [] for i in range(n): for j in range(i, n): edgeList.append((edges[i][j], i, j)) edgeList.sort() for k in range(n): for i in range(n): for j in range(n): ...
s023151163
p03600
u332906195
1548368716
Python
Python (3.4.3)
py
Runtime Error
2104
6896
1483
# -*- coding: utf-8 -*- n = int(input()) a = [] for i in range(n): a_list = list(map(int, input().split())) a_dict = {i:e for i,e in enumerate(a_list[:i])} a.append(a_dict) if n == 1: print("-1") exit() elif n == 2: print(a[0][1]) exit() # Minimam total path length min_total = 0 for i...
s258883886
p03600
u920299620
1541895709
Python
Python (3.4.3)
py
Runtime Error
20
3064
479
G=[] for _ in range(n): tmp=list(map(int,input().split())) G.append(tmp) Dij=Dijkstra() for i in range(n): result=Dij.dijkstra(G,i) dis=result[0] pre=result[1] for j in range(n): if(dis[j] < G[i][j]): print(-1) sys.exit() if(dis[j] == G[i][j] and pre[j]!=...
s879633336
p03600
u824237520
1541098570
Python
Python (3.4.3)
py
Runtime Error
2104
6644
449
n = int(input()) dp = [[int(x) for x in input().split()] for _ in range(n)] if n == 1: print(0) exit() ans = 0 for i in range(n - 1): for j in range(i + 1, n): temp = [] for k in range(n): if k != i and k != j: temp.append(dp[i][k] + dp[k][j]) if min(te...
s040933660
p03600
u824237520
1541098386
Python
Python (3.4.3)
py
Runtime Error
2104
6644
449
n = int(input()) dp = [[int(x) for x in input().split()] for _ in range(n)] if n == 1: print(0) exit() ans = 0 for i in range(n - 1): for j in range(i + 1, n): temp = [] for k in range(n): if k != i and k != j: temp.append(dp[i][k] + dp[k][j]) if min(te...
s822929429
p03600
u729707098
1535670382
Python
Python (3.4.3)
py
Runtime Error
705
21628
445
import numpy as np from scipy.sparse.csgraph import floyd_warshall n = int(input()) a = np.array([[int(i) for i in input().split()] for i in range(n)]) d,ans = floyd_warshall(a,directed=False),0 if any(a[i][j]!=d[i][j] for i in range(n) for j in range(n)): ans = -1 else: inf = float("inf") for i in range(n): a[i][i] ...
s487874082
p03600
u631277801
1535055181
Python
Python (3.4.3)
py
Runtime Error
234
17024
809
from scipy.sparse.csgraph import floyd_warshall import numpy as np file = open("ABC074D.txt", "r") n = int(file.readline()) graph = np.array([[0 for _ in range(n)] for _ in range(n)], dtype=float) for i in range(n): graph[i] = np.array(list(map(int, file.readline().split()))) # ワーシャルフロイドで最短距離出す shortest = fl...
s115147031
p03600
u419686324
1531198142
Python
Python (3.4.3)
py
Runtime Error
2104
8692
373
n = int(input()) a = [list(map(int, input().split())) for i in range(0, n)] ans = 0 for u in range(n): for v in range(u + 1, n): dist = a[u][v] cd = min([a[u][i] + a[i][v] for i in [x for x in range(0, n) if x != u and x != v]]) if dist > cd: print(-1) exit(0) ...
s339784088
p03600
u419686324
1531197958
Python
Python (3.4.3)
py
Runtime Error
2104
8420
529
n = int(input()) a = [list(map(int, input().split())) for i in range(n)] at = list(map(list, zip(*a))) if a != at: print(-1) exit(0) import itertools from array import array aa = array('L', itertools.chain(*a)) ans = 0 for u in range(n): un = u * n for v in range(u + 1, n): dist = aa[un + ...
s729311572
p03600
u419686324
1531197694
Python
Python (3.4.3)
py
Runtime Error
17
3064
528
n = int(input()) a = [list(map(int, input().split())) for i in range(n)] at = list(map(list, zip(*a))) if a != at: print(-1) exit(0) import itertools from array import array aa = array('L', itertools.chain(*a)) ans = 0 for u in range(n): un = u * n for v in range(u + 1, n): dist = aa[un + ...
s606106174
p03600
u419686324
1531197553
Python
Python (3.4.3)
py
Runtime Error
17
3064
532
n = int(input()) a = [list(map(int, input().split())) for i in range(n)] at = list(map(list, zip(*a))) if a != at: print(-1) exit(0) import itertools from array import array aa = array('L', itertools.chain(*a)) ans = 0 for u in range(n): un = u * n for v in range(u + 1, n): dist = aa[un + ...
s367088602
p03600
u419686324
1531192382
Python
Python (3.4.3)
py
Runtime Error
2104
7540
458
n = int(input()) a = [list(map(int, input().split())) for i in range(0, n)] at = list(map(list, zip(*a))) if a != at: print(-1) exit(0) dr = list() for u in range(n): for v in range(u + 1, n): dist = a[u][v] cd = min([a[u][i] + a[i][v] for i in [x for x in range(0, n) if x != u and x !=...
s017028540
p03600
u419686324
1531191787
Python
Python (3.4.3)
py
Runtime Error
2104
7540
542
n = int(input()) a = [list(map(int, input().split())) for i in range(0, n)] at = list(map(list, zip(*a))) if a != at: print(-1) exit(0) for u in range(0, n): for v in range(u + 1, n): for i in range(0, n): if a[u][v] > a[u][i] + a[i][v]: print(-1) e...
s046681640
p03600
u808427016
1529460569
Python
Python (3.4.3)
py
Runtime Error
2104
8692
396
N = int(input()) A = [[int(_) for _ in input().split()] for i in range(N)] def calc(N, A): r = 0 for i in range(0, N): for j in range(i + 1, N): a = A[i][j] d = min(A[i][k] + A[k][j] for k in range(0, N) if k != i and k != j) if a > d: return -1 ...
s493064524
p03600
u281303342
1524534649
Python
PyPy3 (2.4.0)
py
Runtime Error
169
38640
591
N = int(input()) A,B,Ans = [],[],0 for i in range(N): x = list(map(int,input().split())) A.append(x.copy()) B.append(x.copy()) for k in range(N): for i in range(N): for j in range(N): B[i][j] = min(B[i][j],B[i][k]+ B[k][j]) if A!=B: print(-1) else: for i in range(N): ...
s698369388
p03600
u274555984
1505958112
Python
Python (3.4.3)
py
Runtime Error
2112
25728
2409
import numpy as np def read_data(): try: LOCAL_FLAG import codecs import os lines = [] file_path = os.path.join(os.path.dirname(__file__), 'data.dat') with codecs.open(file_path, 'r', 'utf-8') as f: n_lines = int(f.readline()) for i in range(...
s785502681
p03600
u429843511
1505757073
Python
Python (3.4.3)
py
Runtime Error
983
29528
452
import numpy as np import scipy.sparse.csgraph as graph N = int(input()) G = np.array([list(map(int, input().split())) for i in range(N)]) G2 = graph.floyd_warshall(G, directed=False) if np.any(G != G2): print(-1) else: c = [2*10**9]*N d = np.diag(c) G += d ans = 0 for i in range(N): ...
s388200122
p03600
u429843511
1505757024
Python
Python (3.4.3)
py
Runtime Error
945
28652
468
import numpy as np import scipy.sparse.csgraph as graph N = int(input()) G = np.array([list(map(int, input().split())) for i in range(N)], dtype = 'int32') G2 = graph.floyd_warshall(G, directed=False) if np.any(G != G2): print(-1) else: c = [2*10**9]*N d = np.diag(c) G += d ans = 0 for i in r...
s787089022
p03600
u429843511
1505756909
Python
Python (3.4.3)
py
Runtime Error
748
21932
469
import numpy as np import scipy.sparse.csgraph as graph N = int(input()) G = np.array([list(map(int, input().split())) for i in range(N)], dtype = 'int64') G2 = graph.floyd_warshall(G, directed=False) if np.any(G != G2): print(-1) else: c = [2*10**9]*N d = np.diag(c) G += d ans = 0 for i in r...
s436388685
p03600
u667084803
1505708460
Python
Python (3.4.3)
py
Runtime Error
39
6644
628
def Warshall_Floyd(edges,N): """頂点N個のグラフ上の隣接行列edgesが与えられたとき, 2点間の最短距離距離を隣接行列で返す""" for k in range(N): for i in range(N): for j in range(N): edges[i][j]=min(edges[i][j],edges[i][k]+d[k][j]) return edges import sys N=int(input()) A=[list(map(int,input().split())) for i in range(N)] B=Warshall...
s835842383
p03600
u667084803
1505701937
Python
Python (3.4.3)
py
Runtime Error
2104
6644
475
import sys from sys import stdin input = stdin.readline N=int(input()) edges=[list(map(int,input().split())) for i in range(N)] for k in range(N): for i in range(N): for j in range(i): if edges[i][j]>edges[i][k]+edges[k][j]: print(-1) sys.exit() ans=0 for i in range(N): for j in range(i)...
s590882724
p03600
u667084803
1505701919
Python
Python (3.4.3)
py
Runtime Error
2104
6644
473
import sys from sys import stdin input = stdin.readline N=int(input()) edges=[list(map(int,input().split())) for i in range(N)] for k in range(N): for i in range(N): for j in range(i): if edges[i][j]>edges[i][k]+edges[k][j]: print(-1) sys.exit() ans=0 for i in range(N): for j in range(i)...
s742716313
p03600
u667084803
1505701195
Python
Python (3.4.3)
py
Runtime Error
17
2940
521
def Warshall_Floyd(edges,N): """頂点N個のグラフ上の隣接行列edges(空欄はinfとせよ)が与えられたとき, 2点間の最短距離距離を隣接行列で返す""" for k in range(0:N:2): for i in range(N): for j in range(i): if edges[i][j]>edges[i][k]+edges[k][j]: return 1 return 0 import sys from sys import stdin input = stdin.readline N=int(input()) A=[list...
s576238046
p03600
u429843511
1505678767
Python
Python (3.4.3)
py
Runtime Error
45
7156
584
import copy INF = float('inf') N = int(input()) a = [] for i in range(N): a.append(list(map(int, input().split()))) flag = 0 length = 0 for i in range(N): for j in range(N): muda = 0 for k in range(N): if k == i or k == j: continue mix = b[i][k] + b[k][j...
s514867955
p03600
u163703551
1505626585
Python
Python (3.4.3)
py
Runtime Error
17
3064
730
import sys sys.stdin = open('d1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(input()) def read_str(): return input() def solve(): n = read_int() d = [read_int_list() for i in range(n)] res =...
s324039298
p03600
u238510421
1505616728
Python
Python (3.4.3)
py
Runtime Error
44
6644
946
n = int(input()) a_all = [] for i in range(n): a_list = input().split() a_list = [int(a) for a in a_list] a_all.append(a_list) a_array = np.array(a_all) for i in range(n): a_array[i][:i] = 0 a_goukeiyou = np.copy(a_array) huseiritsu = 0 for i in range(n-2): for j in range(i+1,n-1): fo...
s516611654
p03600
u943004959
1505615991
Python
Python (3.4.3)
py
Runtime Error
17
3064
1652
def print_path(prev, cost): for i in range(len(prev)): print("%d, prev = %d, cost = %d" % (i, prev[i], cost[i])) def get_path(start, goal, prev): path = [] now = goal path.append(now) while True: path.append(prev[now]) if prev[now] == start: break now = prev[now] ...
s526157386
p03601
u023229441
1599858750
Python
PyPy3 (7.3.0)
py
Runtime Error
112
74672
468
a,b,c,d,e,mv=map(int,input().split()) for i in range(31): for j in range(31): if i+j==0:continue for k in range(31): for l in range(31): water=100*(a*i+b*j) sugar=k*c+l*d if water+sugar > mv: break pp= 1...
s375139102
p03601
u023229441
1599858673
Python
Python (3.8.2)
py
Runtime Error
25
9196
445
a,b,c,d,e,mv=map(int,input().split()) ans=0 for i in range(31): for j in range(31): for k in range(31): for l in range(31): water=100*(a*i+b*j) sugar=k*c+l*d if water+sugar > mv: break pp= 100*sugar/(water+sugar)...
s633007321
p03601
u730769327
1595043716
Python
Python (3.8.2)
py
Runtime Error
33
9152
532
a,b,c,d,e,f=map(int,input().split()) dp=[0]*(f+1) w=[] s=[] for i in range(f+1): if i%(a*100)==0:dp[i]=i if i%(b*100)==0:dp[i]=i if i>a*100 and dp[i-a*100]:dp[i]=i if i>a*100 and dp[i-b*100]:dp[i]=i for i in dp: if i:w.append(i) m=w[-1]*e//100+1 dp=[0]*(m) for i in range(m): if i%c==0:dp[i]=i if i%d==0:dp...
s399617999
p03601
u189023301
1590789847
Python
Python (3.4.3)
py
Runtime Error
20
3188
908
import bisect a, b, c, d, e, f = map(int, input().split()) a = a * 100 b = b * 100 g = f * e // 100 wtr = [0] * f sgr = [0] * g wtr[0] = 1 sgr[0] = 1 wtr_l = [] sgr_l = [] def comb(lmt, tgt, lis): for i in range(lmt - tgt): if lis[i] != 0: lis[i + tgt] = 1 comb(f, a, wtr) comb(f, b, wtr) com...
s865558195
p03601
u222668979
1590513804
Python
Python (3.4.3)
py
Runtime Error
90
12560
590
from itertools import product a, b, c, d, e, f = map(int, input().split()) lima = [100 * a * i for i in range(f // (100 * a) + 1)] limb = [100 * b * i for i in range(f // (100 * b) + 1)] setw = set([i + j for i, j in product(lima, limb) if 0 < i + j <= f]) limc = [c * i for i in range(f // c + 1)] limd = [d * i for i...
s925973825
p03601
u222668979
1590513682
Python
Python (3.4.3)
py
Runtime Error
86
12628
671
from itertools import product a, b, c, d, e, f = map(int, input().split()) lima = [100 * a * i for i in range(f // (100 * a) + 1)] limb = [100 * b * i for i in range(f // (100 * b) + 1)] setw = set([i + j for i, j in product(lima, limb) if 0 < i + j <= f]) limc = [c * i for i in range(f // c + 1)] limd = [d * i for i...
s253120005
p03601
u993435350
1581733511
Python
Python (3.4.3)
py
Runtime Error
28
3064
1152
A,B,C,D,E,F = map(int,input().split()) conc = 0 total = 0 for a in range(0,31): for b in range(0,31): water = (A * a + B * b) * 100 if water > F: break else: for c in range(3001): water = (A * a + B * b) * 100 if water == 0: break #探索中の水の量に溶かせられる砂糖の...
s145940317
p03601
u377989038
1579349833
Python
Python (3.4.3)
py
Runtime Error
59
3188
590
a, b, c, d, e, f = map(int, input().split()) limit = 100 * e / (100 + e) mx = -1 waters = set() for i in range(0, f // a + 1, 100 * a): for j in range(0, (f - i * a) // b + 1, 100 * b): waters.add(i + j) sugars = set() for i in range(0, f // c + 1, c): for j in range(0, (f - c) // d + 1, d): s...
s540086103
p03601
u634461820
1564427062
Python
PyPy3 (2.4.0)
py
Runtime Error
228
43628
534
A,B,C,D,E,F = list(map(int,input().split())) tmp = 0 for i in range(30): a = A*i if a*100 >= F: break for j in range(30): b = B*j if a+b == 0: continue w = (a+b)*100 if w >= F: break for k in range(3000): c = C*k for l in range(3000): d = D*l s = c+...
s870703495
p03601
u367130284
1556506557
Python
Python (3.4.3)
py
Runtime Error
1988
90464
688
a,b,c,d,e,f=map(int,input().split()) maxsugar=f*e/(100+e) maxwater=f*100/(100+e) #print(maxsugar,maxwater) sugar=[] for i in range(int(maxsugar)//min(c,d)+2): for j in range(int(maxsugar)//min(c,d)+2): x=i*c+j*d if x<=maxsugar: sugar.append(x) #print(sugar) water=[] for i in range(int(ma...
s775938903
p03601
u310678820
1554329218
Python
Python (3.4.3)
py
Runtime Error
406
83636
544
import fractions as frac a, b, c, d, e, f = map(int, input().split()) memo=[[(-1, -1)]*10000 for i in range(1000)] func = lambda t: frac.Fraction(t[0], t[1]) if t[1]>0 else -10 def dp(s, w): if w*e<s or w*100+s>f: return (-1, -1) m=memo[s][w] if m[0]>0: return memo[s][w] p0=(s,w) p1...
s573522384
p03601
u310678820
1554328339
Python
Python (3.4.3)
py
Runtime Error
433
83636
529
import fractions as frac a, b, c, d, e, f = map(int, input().split()) memo=[[(-1, -1)]*10000 for i in range(1000)] func = lambda t: frac.Fraction(t[0], t[1] ) def dp(s, w): if w*e<s or w*100+s>f: return (-1, -1) m=memo[s][w] if m[0]>0: return memo[s][w] p0=(s,w) p1=dp(s, w+a) ...
s030308789
p03601
u001024152
1549244225
Python
PyPy3 (2.4.0)
py
Runtime Error
3200
742960
615
# C sugar water from collections import deque def noudo(water, sugar): if water+sugar==0: return 0 return 100*sugar/(water+sugar) A,B,C,D,E,F = map(int, input().split()) q = deque([(0,0)]) # water, sugar max_noudo = 0 ans = None while q: water,sugar = q.popleft() cur = noudo(water, sugar) if cur>ma...
s379438644
p03601
u004025573
1547182720
Python
Python (3.4.3)
py
Runtime Error
35
3192
1388
a, b, c, d, e, f = map(int, input().split()) dp_w = [[0 for j in range(31)] for i in range(3)] for j in range(31): if j<a: dp_w[1][j] = dp_w[0][j] elif j==a: dp_w[1][j] = 1 else: if dp_w[0][j]==1 or dp_w[1][j-a]==1: dp_w[1][j] = 1 for j in range(31): if j<b: ...
s823991834
p03601
u200030766
1542320322
Python
Python (3.4.3)
py
Runtime Error
130
3188
682
A, B, C, D, E, F=map(int, input().split()) for i in range(31): w=100*A*i s=0 if s+w>F: break for j in range(31): w=100*A*i+100*B*j s=0 if s+w>F: break for k in range(3001): w=100*A*i+100*B*j s=C*k if s+w>F: ...
s506631543
p03601
u761989513
1539971418
Python
Python (3.4.3)
py
Runtime Error
79
3188
568
a, b, c, d, e, f = map(int, input().split()) x = set() y = set() for A in range(0, f + 1, 100 * a): for B in range(0, f + 1, 100 * b): if A + B > f: break if A + B: x.add(A + B) for C in range(0, f + 1, c): for D in range(0, f + 1, d): if C + D > f: br...
s100124734
p03601
u761989513
1539971332
Python
Python (3.4.3)
py
Runtime Error
97
3828
488
a, b, c, d, e, f = map(int, input().split()) x = set() y = set() for A in range(0, f + 1, 100 * a): for B in range(0, f + 1, 100 * b): if A + B: x.add(A + B) for C in range(0, f + 1, c): for D in range(0, f + 1, d): y.add(C + D) ans = 0 for X in x: for Y in y: if X + Y <=...
s913818401
p03601
u478870821
1535528658
Python
PyPy3 (2.4.0)
py
Runtime Error
327
42604
671
from sys import exit, setrecursionlimit, stderr from functools import reduce from itertools import * from collections import * from bisect import * from heapq import * def read(): return int(input()) def reads(): return [int(x) for x in input().split()] maxd = -1 ans = None A, B, C, D, E, F = reads() for i, j,...
s617161764
p03601
u478870821
1535528588
Python
PyPy3 (2.4.0)
py
Runtime Error
318
42476
670
from sys import exit, setrecursionlimit, stderr from functools import reduce from itertools import * from collections import * from bisect import * from heapq import * def read(): return int(input()) def reads(): return [int(x) for x in input().split()] maxd = 0 ans = None A, B, C, D, E, F = reads() for i, j, ...
s490109945
p03601
u062147869
1534400411
Python
PyPy3 (2.4.0)
py
Runtime Error
175
39024
540
import sys a,b,c,d,e,f=map(int,input().split()) ans=0 s=0 t=0 for i in range(f//100+1): if i==0 and j==0: continue w=(f-100*a*i)//100 for j in range(w+1): x=a*i+b*j for k in range(x*e//c+1): if k==0 and l==0: continue v=(x*e-c*k)//d ...
s953927911
p03601
u062147869
1534400312
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38384
485
import sys a,b,c,d,e,f=map(int,input().split()) ans=0 s=0 t=0 for i in range(f//100+1): if i==0 and j==0: continue w=(f-100*a*i)//100 for j in range(w+1): x=a*i+b*j for k in range(x*e//c+1): v=(x*e-c*k)//d for l in range(v+1): y=c*k+d*l ...
s203655039
p03601
u941884460
1528900404
Python
PyPy3 (2.4.0)
py
Runtime Error
196
40432
361
A,B,C,D,E,F=map(int,input().split()) conc = 0.0 liq,sug=0,0 for a in range(31): for b in range(16): for c in range(31): for d in range(16): if 100*a+100*b+c+d <= F and c+d <= (a+b)*E: if conc < 100*(c+d)/(100*(a+b)+c+d): conc = 100*(c+d)/(100*(a+b)+c+d) liq = 100*(...