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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s785404664 | p02536 | u956318161 | 1601347963 | Python | Python (3.8.2) | py | Runtime Error | 207 | 12900 | 914 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmpzodr5jo9/tmpt7o7e3wq.py", line 35, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s402772266 | p02536 | u043048943 | 1601347928 | Python | PyPy3 (7.3.0) | py | Runtime Error | 265 | 75204 | 1337 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmpph0b20nl/tmphc2hm0hu.py", line 55, in <module>
main()
File "/tmp/tmpph0b20nl/tmphc2hm0hu.py", line 49, in main
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s738106742 | p02536 | u956318161 | 1601346717 | Python | Python (3.8.2) | py | Runtime Error | 213 | 10448 | 949 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmpvqeb5712/tmpx10irl24.py", line 35, in <module>
n,m= map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s074818380 | p02536 | u097700948 | 1601338245 | Python | Python (3.8.2) | py | Runtime Error | 295 | 18196 | 387 | N, M = map(int, input().split())
parents = [i for i in range(N+1)]
def find(x):
if x == parents[x]:
return x
else:
x = find(parents[x])
return x
def same(x, y):
if x==y:
pass
else:
parents[x] = y
for _ in range(M):
A, B = map(int, input().split())
x... | Traceback (most recent call last):
File "/tmp/tmpa7_w79wu/tmp_iq02xx0.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s542290645 | p02536 | u097700948 | 1601338070 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9068 | 357 | N, M = map(int, input().split())
def find(x):
if x == parents[x]:
return x
else:
x = find(parents[x])
return x
def same(x, y):
if x==y:
pass
else:
parents[x] = y
for _ in range(M):
A, B = map(int, input().split())
x, y = find(A), find(B)
same(x,... | Traceback (most recent call last):
File "/tmp/tmpzhyr64t_/tmpl5wp74xs.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s797076963 | p02536 | u329319441 | 1601323546 | Python | Python (3.8.2) | py | Runtime Error | 669 | 597628 | 718 | import sys
sys.setrecursionlimit(int(1e9))
class uft:
def __init__(self, N):
self.__N = N
self.__arr = [-1] * (N + 1)
def fp(self, x):
if self.__arr[x] < 0:
return x
else:
self.__arr[x] = self.fp(self.__arr[x])
return self.__arr[x]
def add(self, x, y):
if x == y:
ret... | Traceback (most recent call last):
File "/tmp/tmpp1q8g9bc/tmpxbhgitld.py", line 32, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s579331142 | p02536 | u329319441 | 1601322948 | Python | Python (3.8.2) | py | Runtime Error | 660 | 597680 | 714 | import sys
sys.setrecursionlimit(int(1e9))
class uft:
def __init__(self, N):
self.__N = N
self.__arr = [-1] * (N + 1)
def fp(self, x):
if self.__arr[x] < 0:
return x
else:
self.__arr[x] = self.fp(self.__arr[x])
return self.__arr[x]
def add(self, x, y):
if x == y:
ret... | Traceback (most recent call last):
File "/tmp/tmp55l1mkvd/tmpg99t0bqq.py", line 32, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s872426833 | p02536 | u035453792 | 1601319057 | Python | Python (3.8.2) | py | Runtime Error | 150 | 10796 | 519 | import collections
n,m = map(int,input().split())
ans = [0]*n
ans[0]=1
for _ in range(m):
a,b = map(int,input().split())
if ans[a]==0 and ans[b]==0:
if a<b:
ans[a]=a
ans[b]=a
else:
ans[a]=b
ans[b]=b
elif ans[a]!=0 and ans[b]!=0:
if ans[... | Traceback (most recent call last):
File "/tmp/tmpt0b8v2mh/tmpbxbvy287.py", line 2, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s813420999 | p02536 | u989306199 | 1601312475 | Python | Python (3.8.2) | py | Runtime Error | 188 | 12884 | 1381 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmpw94pdzna/tmphtbaxfd7.py", line 58, in <module>
solve()
File "/tmp/tmpw94pdzna/tmphtbaxfd7.py", line 50, in solve
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s888962650 | p02536 | u989306199 | 1601312097 | Python | PyPy3 (7.3.0) | py | Runtime Error | 281 | 75004 | 1381 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmpgvqofjas/tmpsgjhd90a.py", line 58, in <module>
solve()
File "/tmp/tmpgvqofjas/tmpsgjhd90a.py", line 50, in solve
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s548695202 | p02536 | u999799597 | 1601307107 | Python | Python (3.8.2) | py | Runtime Error | 312 | 10732 | 902 | # https://atcoder.jp/contests/atc001/tasks/unionfind_a
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 s... | Traceback (most recent call last):
File "/tmp/tmpcliay5iq/tmpys_w6d1u.py", line 39, in <module>
main()
File "/tmp/tmpcliay5iq/tmpys_w6d1u.py", line 31, in main
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s510391774 | p02536 | u200916944 | 1601306159 | Python | PyPy3 (7.3.0) | py | Runtime Error | 216 | 104860 | 699 | (N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines() if len(x)>1]
class UnionFind:
def __init__(self, n):
self.par=[i for i in range(n)]
def root(self, x):
if self.par[x] == x:
return x
return self.par[x] == self.root(self.par[x])
def union(self, x, y):
... | Traceback (most recent call last):
File "/tmp/tmp7bl66z1n/tmpyyrmq488.py", line 1, in <module>
(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines() if len(x)>1]
^^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s265911914 | p02536 | u329319441 | 1601304138 | Python | Python (3.8.2) | py | Runtime Error | 639 | 597836 | 702 | import sys
sys.setrecursionlimit(int(1e9))
N, M = map(int, input().split())
class uft:
def __init__(self, N):
self.__N = N
self.__arr = [-1] * (N + 1)
def fp(self, x):
if self.__arr[x] < 0:
return x
else:
self.__arr[x] = self.fp(self.__arr[x])
return self.__arr[x]
def add(self, x... | Traceback (most recent call last):
File "/tmp/tmpeku_w49v/tmpdyezffv1.py", line 3, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s130458910 | p02536 | u329319441 | 1601303128 | Python | Python (3.8.2) | py | Runtime Error | 158 | 11376 | 659 | N, M = map(int, input().split())
class uft:
def __init__(self, N):
self.__N = N
self.__arr = [-1] * (N + 1)
def fp(self, x):
if self.__arr[x] < 0:
return x
else:
self.__arr[x] = self.fp(self.__arr[x])
return self.__arr[x]
def add(self, x, y):
if x > y:
x, y = y, x
i... | Traceback (most recent call last):
File "/tmp/tmpxpgvolv3/tmpwcodt0v4.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s899072385 | p02536 | u329319441 | 1601302908 | Python | Python (3.8.2) | py | Runtime Error | 155 | 11584 | 629 | N, M = map(int, input().split())
class uft:
def __init__(self, N):
self.__N = N
self.__arr = [-1] * (N + 1)
def fp(self, x):
if self.__arr[x] < 0:
return x
else:
self.__arr[x] = self.fp(self.__arr[x])
return self.__arr[x]
def add(self, x, y):
if x > y:
x, y = y, x
p... | Traceback (most recent call last):
File "/tmp/tmpv3xqjkzv/tmp1354kik7.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s769741906 | p02536 | u200916944 | 1601301621 | Python | PyPy3 (7.3.0) | py | Runtime Error | 162 | 94268 | 293 | (N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines() if len(x)>1]
d={}
g=0
for a,b in AB:
if a in d:
d[b] = d[a]
elif b in d:
b[a] = d[b]
else:
g += 1
d[a] = d[b] = g
for i in range(1,N+1):
if not i in d:
g += 1
print(g - 1) | Traceback (most recent call last):
File "/tmp/tmp64qla7vw/tmp4dc_5weu.py", line 1, in <module>
(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines() if len(x)>1]
^^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s831506898 | p02536 | u329319441 | 1601297721 | Python | Python (3.8.2) | py | Runtime Error | 156 | 11504 | 627 | N, M = map(int, input().split())
class uft:
def __init__(self, N):
self.__N = N
self.__arr = [-1] * (N + 1)
def fp(self, x):
if self.__arr[x] < 0:
return x
else:
self.__arr[x] = self.fp(self.__arr[x])
return self.__arr[x]
def add(self, x, y):
if x > y:
x, y = y, x
p... | Traceback (most recent call last):
File "/tmp/tmp6tyylq8z/tmp1r0z1b1_.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s203272530 | p02536 | u329319441 | 1601297176 | Python | Python (3.8.2) | py | Runtime Error | 151 | 11468 | 626 | N, M = map(int, input().split())
class uft:
def __init__(self, N):
self.__N = N
self.__arr = [-1] * (N + 1)
def fp(self, x):
if self.__arr[x] < 0:
return x
else:
self.__arr[x] = self.fp(self.__arr[x])
return self.__arr[x]
def add(self, x, y):
if x > y:
x, y = y, x
p... | Traceback (most recent call last):
File "/tmp/tmpvorrzjhj/tmp9zbvzve_.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s870828200 | p02536 | u515740713 | 1601290469 | Python | PyPy3 (7.3.0) | py | Runtime Error | 97 | 68892 | 1791 | # -*- coding: Shift-JIS -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
class UnionFind:
"""素集合を木構造として管理する。"""
def __init__(self, n):
self.parent = [-1] * n
self.n = n
self.cnt = n
... | SyntaxError: encoding problem: Shift-JIS
| |
s701044040 | p02536 | u318233626 | 1601264504 | Python | Python (3.8.2) | py | Runtime Error | 501 | 596748 | 657 | import sys
sys.setrecursionlimit(4100000)
def find(Data, x):
if Data[x] < 0:
return x
else:
Data[x] = find(Data, x)
return Data[x]
def unite(Data, a, b):
a, b = find(Data, a), find(Data, b)
if a != b:
if Data[a] < Data[b]:
Data[a] = Data[a] + Data[b]
... | Traceback (most recent call last):
File "/tmp/tmpguku4zm3/tmprodfs8gh.py", line 21, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s830360219 | p02536 | u318233626 | 1601264242 | Python | Python (3.8.2) | py | Runtime Error | 483 | 596720 | 657 | import sys
sys.setrecursionlimit(4100000)
def find(Data, x):
if Data[x] < 0:
return x
else:
Data[x] = find(Data, x)
return Data[x]
def unite(Data, a, b):
a, b = find(Data, a), find(Data, b)
if a != b:
if Data[a] > Data[b]:
Data[a] = Data[a] + Data[b]
... | Traceback (most recent call last):
File "/tmp/tmps1nvmbm1/tmpzjqey1fe.py", line 21, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s103874241 | p02536 | u318233626 | 1601264000 | Python | Python (3.8.2) | py | Runtime Error | 486 | 596780 | 629 | import sys
sys.setrecursionlimit(4100000)
def find(Data, x):
if Data[x] < 0:
return x
else:
Data[x] = find(Data, x)
return Data[x]
def unite(Data, a, b):
a, b = find(Data, a), find(Data, b)
if a != b:
if Data[a] > Data[b]:
Data[a] = Data[a] + Data[b]
... | Traceback (most recent call last):
File "/tmp/tmpc0m3r81p/tmpb2yuv2_i.py", line 21, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s660541168 | p02536 | u185193776 | 1601263865 | Python | Python (3.8.2) | py | Runtime Error | 728 | 69072 | 1274 | class DFS:
def __init__(self, n, cons):
nodes = [DFSNode(i) for i in range(n)]
for i, j in cons:
nodes[i].addAdjacent(nodes[j])
self.nodes = nodes
def clearVisited(self):
for node in self.nodes:
node.visited = False
def execute(self, rootId):
... | Traceback (most recent call last):
File "/tmp/tmp31fbgugm/tmpsvr7advi.py", line 42, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s354583611 | p02536 | u318233626 | 1601263845 | Python | Python (3.8.2) | py | Runtime Error | 570 | 596772 | 629 | import sys
sys.setrecursionlimit(4100000)
def find(Tree, x):
if Tree[x] < 0:
return x
else:
Tree[x] = find(Tree, x)
return Tree[x]
def unite(Tree, a, b):
a, b = find(Tree, a), find(Tree, b)
if a != b:
if Tree[a] > Tree[b]:
Tree[a] = Tree[a] + Tree[b]
... | Traceback (most recent call last):
File "/tmp/tmp3darr3ys/tmp_ewy82lq.py", line 21, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s310690666 | p02536 | u318233626 | 1601263769 | Python | Python (3.8.2) | py | Runtime Error | 43 | 10716 | 586 | def find(Tree, x):
if Tree[x] < 0:
return x
else:
Tree[x] = find(Tree, x)
return Tree[x]
def unite(Tree, a, b):
a, b = find(Tree, a), find(Tree, b)
if a != b:
if Tree[a] > Tree[b]:
Tree[a] = Tree[a] + Tree[b]
Tree[b] = a
else:
... | Traceback (most recent call last):
File "/tmp/tmpc8mc_uo6/tmp5i6htr08.py", line 18, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s738722178 | p02536 | u283312187 | 1601261167 | Python | PyPy3 (7.3.0) | py | Runtime Error | 270 | 108992 | 2556 | import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
from future_builtins import ascii, filter, hex, map, oct, zip
range = xrange
BUFSIZE = 8192
class FastIO(BytesIO):
newlines = 0
def __init__(self, file):
self._file = file
self._fd = file.fileno()
self.writa... | Traceback (most recent call last):
File "/tmp/tmpujip7j_q/tmpc3rx9lmv.py", line 103, in <module>
main()
File "/tmp/tmpujip7j_q/tmpc3rx9lmv.py", line 99, in main
solve()
File "/tmp/tmpujip7j_q/tmpc3rx9lmv.py", line 68, in solve
n, m = map(int, input().split())
^^^^
ValueError: not enough values to ... | |
s424337707 | p02536 | u473172054 | 1601257871 | Python | Python (3.8.2) | py | Runtime Error | 289 | 12008 | 225 | f = lambda x: x if p[x]<0 else f(p[x])
N,M = map(int,input().split())
p = [-1]*N
for _ in range(M):
A,B = map(lambda x:f(int(x)-1),input().split())
if A==B: continue
p[A] += p[B]
p[B] = A
print(sum(i<0 for i in p)-1)
| Traceback (most recent call last):
File "/tmp/tmpb1y1tyyh/tmp_4pzmwbk.py", line 2, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s832026335 | p02536 | u414558682 | 1601257867 | Python | Python (3.8.2) | py | Runtime Error | 203 | 12944 | 1547 | 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):
... | Traceback (most recent call last):
File "/tmp/tmp_wr24_3w/tmp47wbyo1g.py", line 56, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s986312976 | p02536 | u473172054 | 1601257510 | Python | Python (3.8.2) | py | Runtime Error | 118 | 35364 | 861 | n, m = map(int, input().split())
class MakeSet():
def __init__(self, x):
self.parent = x
self.rank = 0
def Union(x, y, par):
xRoot = Find(x, par)
yRoot = Find(y, par)
if par[xRoot].rank > par[yRoot].rank:
par[yRoot].parent = xRoot
elif par[xRoot].rank < par[yRoot].rank:
... | Traceback (most recent call last):
File "/tmp/tmpvuf44dlr/tmp33iumbns.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s116586893 | p02536 | u602740328 | 1601255940 | Python | Python (3.8.2) | py | Runtime Error | 189 | 10832 | 242 | f = lambda x: x if p[x]<0 else f(p[x])
N,M = map(int,input().split())
p = [-1]*N
for _ in range(M):
A,B = map(lambda x:f(int(x)),input().split())
if A==B: continue
elif A<B: A,B=B,A
p[A] += p[B]
p[B] = A
print(sum(i<0 for i in p)-1) | Traceback (most recent call last):
File "/tmp/tmpq92cey84/tmpohu6srdv.py", line 2, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s414958892 | p02536 | u602740328 | 1601253420 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 30368 | 517 | from collections import deque
N,M = map(int,input().split())
E = {i: [] for i in range(N)}
for m in range(M):
A,B = map(int,input().split())
E[A].append(B)
E[B].append(A)
q = deque([0])
checked = [False]*N
ans = 0
while q and not(all(checked)):
n = q.popleft()
if checked[n]: continue
checked[n] = True
... | Traceback (most recent call last):
File "/tmp/tmp8nlt9kpv/tmpt8n62c_z.py", line 2, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s628412421 | p02536 | u295013286 | 1601250920 | Python | Python (3.8.2) | py | Runtime Error | 212 | 13460 | 408 | n,m=map(int, input().split())
roads=[]
for _ in range(m):
a,b=map(int, input().split())
if a<b:
roads.append([a,b].sort())
else:
roads.append([b,a].sort())
group=[i for i in range(n)]
group2=[]
while group2!=group:
group2=group
for road in roads:
group[road[1]-1]=group[road[0]-1]
counter=1
... | Traceback (most recent call last):
File "/tmp/tmpwci_3suh/tmp8rhzuq03.py", line 1, in <module>
n,m=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s220991940 | p02536 | u295013286 | 1601250664 | Python | Python (3.8.2) | py | Runtime Error | 207 | 13592 | 362 | n,m=map(int, input().split())
roads=[]
for _ in range(m):
a,b=map(int, input().split())
roads.append([a,b].sort())
group=[i for i in range(n)]
group2=[]
while group2!=group:
group2=group
for road in roads:
group[road[1]-1]=group[road[0]-1]
counter=1
for i in range(n-1):
if group[i]!=group[i+1]:
... | Traceback (most recent call last):
File "/tmp/tmpj_ejg__5/tmposr_t4nr.py", line 1, in <module>
n,m=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s820538946 | p02536 | u295013286 | 1601250137 | Python | Python (3.8.2) | py | Runtime Error | 208 | 13692 | 281 | n,m=map(int, input().split())
roads=[]
for _ in range(m):
a,b=map(int, input().split())
roads.append([a,b].sort())
group=[i for i in range(n)]
group2=[]
while group2!=group:
group2=group
for road in roads:
group[road[1]]=group[road[0]]
print(group[-1])
| Traceback (most recent call last):
File "/tmp/tmpivbx56p6/tmps54opm0d.py", line 1, in <module>
n,m=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s612806450 | p02536 | u200916944 | 1601249227 | Python | PyPy3 (7.3.0) | py | Runtime Error | 235 | 86580 | 367 | #(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines()]
N,M=map(int,input().split())
AB=[list(map(int, input().split())) for _ in range(M)]
d={}
g=0
for a,b in AB:
if a in d:
d[b] = d[a]
elif b in d:
b[a] = d[b]
else:
g += 1
d[a] = d[b] = g
for i in range(1,N+1):
... | Traceback (most recent call last):
File "/tmp/tmpxeie6zl7/tmp0dxnlpl9.py", line 2, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s573739976 | p02536 | u200916944 | 1601249039 | Python | PyPy3 (7.3.0) | py | Runtime Error | 156 | 93476 | 281 | (N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines()]
d={}
g=0
for a,b in AB:
if a in d:
d[b] = d[a]
elif b in d:
b[a] = d[b]
else:
g += 1
d[a] = d[b] = g
for i in range(1,N+1):
if not i in d:
g += 1
print(g - 1) | Traceback (most recent call last):
File "/tmp/tmp9zrc9nv9/tmps8r1gfc5.py", line 1, in <module>
(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines()]
^^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s532987802 | p02536 | u200916944 | 1601247889 | Python | PyPy3 (7.3.0) | py | Runtime Error | 118 | 89676 | 305 | N,M=map(int, input().split())
AB=list(map(int, open(0).read().split()))
ss=[set()]
for i in range(0, len(AB), 2):
a=AB[i]
b=AB[i+1]
for s in ss:
if a in s or b in s:
s.add(a)
s.add(b)
break
else:
ss.add(set([a,b]))
print(N - len(ss) - M) | Traceback (most recent call last):
File "/tmp/tmpf7xqgvc2/tmpa4rp85bd.py", line 1, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s267807134 | p02536 | u098436028 | 1601241816 | Python | PyPy3 (7.3.0) | py | Runtime Error | 174 | 72248 | 131 | N,M=map(int,input().split())
L=[0]*N
for i in range(M):
A,B=map(int,input().split())
L[A] +=1
L[B] +=1
print(L.count(0)) | Traceback (most recent call last):
File "/tmp/tmpxz7c7p6c/tmpnzkcq_ht.py", line 1, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s265170739 | p02536 | u306950978 | 1601241538 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 13132 | 1316 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmpjrwb6p1_/tmpo1bwrmxm.py", line 48, in <module>
n, m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s619853089 | p02536 | u306950978 | 1601241049 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 74776 | 800 | def find(n):
if root[n] < 0:
return n
else:
root[n] = find(root[n])
return root[n]
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return
if root[x] > root[y]:
x, y = y, x
root[x] += root[y]
root[y] = x
def size(x):
return -root[find(x)]
... | Traceback (most recent call last):
File "/tmp/tmpi2uk5vou/tmp_0u1v0rt.py", line 38, in <module>
n , m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s385405212 | p02536 | u722868069 | 1601240557 | Python | Python (3.8.2) | py | Runtime Error | 1633 | 36544 | 1404 | #最も上にいる親をたどる
# xは自分自身の番号を示す。
# r[x]は自分の親を示す。親がいない場合は-1を示す。
def root(x):
# case parent
if r[x] < 0:
return x
# case child
else:
return root(r[x])
#from operator import itemgetter
n, m = map(int, input().split())
road = [list(map(int,input().split())) for i in range(m)]
#root -1は上がいない、そのほかは親をもちその数字を表す。
... | Traceback (most recent call last):
File "/tmp/tmplxvgjy3x/tmpzdbb4gt_.py", line 14, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s603480141 | p02536 | u722868069 | 1601240369 | Python | Python (3.8.2) | py | Runtime Error | 2636 | 163652 | 1401 | #最も上にいる親をたどる
# xは自分自身の番号を示す。
# r[x]は自分の親を示す。親がいない場合は-1を示す。
def root(x):
# case parent
if r[x] < 0:
return x
# case child
else:
return root(r[x])
#from operator import itemgetter
n, m = map(int, input().split())
road = [list(map(int,input().split())) for i in range(m)]
#root -1は上がいない、そのほかは親をもちその数字を表す。
... | Traceback (most recent call last):
File "/tmp/tmp31db2xmf/tmp3ih_3b2w.py", line 14, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s041441999 | p02536 | u998741086 | 1601240163 | Python | Python (3.8.2) | py | Runtime Error | 316 | 22368 | 1642 | #!/usr/bin/env python
n, m = map(int, input().split())
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]
for i in range(m):
a[i], b[i] = map(int, input().split())
class UnionFind():
def __init__(self, n):
self.n = n
self.par = [i for i in range(n)]
self.rank = [0 for _ in range(n)]... | Traceback (most recent call last):
File "/tmp/tmpwhhodngv/tmptl2vc4fn.py", line 3, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s926611680 | p02536 | u959139907 | 1601237934 | Python | PyPy3 (7.3.0) | py | Runtime Error | 274 | 85948 | 2801 | # There are N cities numbered 1 through N, and M bidirectional roads numbered 1
# through M. Road i connects City A_i and City B_i.
#
# Snuke can perform the following operation zero or more times:
#
# * Choose two distinct cities that are not directly connected by a road, and
# build a new road between the two c... | Traceback (most recent call last):
File "/tmp/tmpgcgteh97/tmpwyr8g5sf.py", line 34, in <module>
N, M = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s747758447 | p02536 | u227082700 | 1601236729 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8884 | 785 | class UnionFind:
def __init__(self, n):
self.n = [-1]*n
self.r = [0]*n
self.co = n
def find(self, x):
if self.n[x] < 0:
return x
else:
return self.n[x] = self.find(self.n[x])
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.... | File "/tmp/tmph02hjdy3/tmpdgmwn7rw.py", line 11
return self.n[x] = self.find(self.n[x])
^
SyntaxError: invalid syntax
| |
s981296089 | p02536 | u722868069 | 1601233912 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 36652 | 1404 | #最も上にいる親をたどる
# xは自分自身の番号を示す。
# r[x]は自分の親を示す。親がいない場合は-1を示す。
def root(x):
# case parent
if r[x] < 0:
return x
# case child
else:
return root(r[x])
#from operator import itemgetter
n, m = map(int, input().split())
road = [list(map(int,input().split())) for i in range(m)]
#root -1は上がいない、そのほかは親をもちその数字を表す。
... | Traceback (most recent call last):
File "/tmp/tmpwp6infeg/tmpsb4juh76.py", line 14, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s777254569 | p02536 | u637289184 | 1601232690 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9152 | 1267 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmpw05j9ppl/tmpq5san3yo.py", line 47, in <module>
uf = UnionFind(N)
^
NameError: name 'N' is not defined
| |
s967930499 | p02536 | u637289184 | 1601232586 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9164 | 1271 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmp6ze84zsz/tmphidttayz.py", line 1, in <module>
class UnionFind():
File "/tmp/tmp6ze84zsz/tmphidttayz.py", line 47, in UnionFind
uf = UnionFind(N)
^^^^^^^^^
NameError: name 'UnionFind' is not defined
| |
s527989132 | p02536 | u539367121 | 1601231006 | Python | Python (3.8.2) | py | Runtime Error | 531 | 116768 | 410 | import sys
sys.setrecursionlimit(10**5)
n,m=map(int,input().split())
g=[[] for i in range(10**5+10)]
for i in range(m):
a,b=map(lambda x:int(x)-1, input().split())
g[a].append(b)
g[b].append(a)
chk=[-1]*n
def dfs(s,v,cnt):
for u in g[s]:
if u==v: continue;
chk[u]=cnt
dfs(u,s,cnt)
cnt=0
for i in r... | Traceback (most recent call last):
File "/tmp/tmp1jlgse3o/tmpfmq2npcs.py", line 4, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s245931131 | p02536 | u722868069 | 1601230976 | Python | Python (3.8.2) | py | Runtime Error | 442 | 36488 | 1320 | #最も上にいる親をたどる
# xは自分自身の番号を示す。
# r[x]は自分の親を示す。親がいない場合は-1を示す。
def root(x):
# case parent
if r[x] < 0:
return x
# case child
else:
return root(r[x])
#from operator import itemgetter
n, m = map(int, input().split())
road = [list(map(int,input().split())) for i in range(m)]
#root -1は上がいない、そのほかは親をもちその数字を表す。
... | Traceback (most recent call last):
File "/tmp/tmp929adlpv/tmpnpdl567z.py", line 14, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s987763131 | p02536 | u591808161 | 1601229286 | Python | PyPy3 (7.3.0) | py | Runtime Error | 268 | 90864 | 2251 | import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return... | Traceback (most recent call last):
File "/tmp/tmpztpu9bmv/tmpcwc8c6cy.py", line 88, in <module>
main()
File "/tmp/tmpztpu9bmv/tmpcwc8c6cy.py", line 84, in main
V, M = MI()
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s199484924 | p02536 | u439063038 | 1601226414 | Python | PyPy3 (7.3.0) | py | Runtime Error | 617 | 545516 | 472 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * n
def find(x):
if root[x] < 0:
return x
else:
x = find(x)
return x
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
root[x] += root[y]
root[y] = x
... | Traceback (most recent call last):
File "/tmp/tmp0__umcgb/tmp4i2ohykd.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s470544947 | p02536 | u439063038 | 1601225855 | Python | PyPy3 (7.3.0) | py | Runtime Error | 634 | 557200 | 484 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * n
def find(x):
if root[x] < 0:
return x
else:
root[x] = find(x)
return root[x]
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
root[x] += root[y]
root[y]... | Traceback (most recent call last):
File "/tmp/tmpdw1lnjfc/tmpex1m65bo.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s693710538 | p02536 | u439063038 | 1601225620 | Python | PyPy3 (7.3.0) | py | Runtime Error | 637 | 557412 | 509 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * (110000)
def find(x):
if root[x] < 0:
return x
else:
root[x] = find(x)
return root[x]
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
root[x] += root[y]
... | Traceback (most recent call last):
File "/tmp/tmpa08p5g2n/tmpbkk097ld.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s915578296 | p02536 | u439063038 | 1601225464 | Python | PyPy3 (7.3.0) | py | Runtime Error | 652 | 557128 | 486 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * (110000)
def find(x):
if root[x] >= 0:
root[x] = find(x)
return root[x]
else:
return x
def unite(x, y):
x = find(x)
y = find(y)
if x != y:
root[x] += root[y]
root[y] = x... | Traceback (most recent call last):
File "/tmp/tmp_b4_977t/tmpscs_2bsd.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s725710333 | p02536 | u792720861 | 1601225459 | Python | Python (3.8.2) | py | Runtime Error | 547 | 12920 | 558 | class UnionFind():
def __init__(self, n):
self.p = list(range(n))
def find(self, x):
if self.p[x] == x: return x
self.p[x] = self.find(self.p[x])
return self.p[x]
def unite(self, x, y):
x, y = self.find(x), self.find(y)
if x != y: self.p[x] = y
N,M = ... | Traceback (most recent call last):
File "/tmp/tmp7jgy17wa/tmp2hnyt7cm.py", line 14, in <module>
N,M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s136627115 | p02536 | u439063038 | 1601225242 | Python | PyPy3 (7.3.0) | py | Runtime Error | 636 | 557500 | 486 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * (110000)
def find(x):
if root[x] >= 0:
root[x] = find(x)
return root[x]
else:
return x
def unite(a, b):
a = find(a)
b = find(b)
if a != b:
root[a] += root[b]
root[b] = a... | Traceback (most recent call last):
File "/tmp/tmphczlup1w/tmpc54d8nz4.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s987712688 | p02536 | u439063038 | 1601224447 | Python | PyPy3 (7.3.0) | py | Runtime Error | 729 | 657808 | 499 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * (1100000)
def find(x):
if root[x] >= 0:
root[x] = find(x)
return root[x]
else:
return x
def unite(a, b):
a = find(a)
b = find(b)
if a != b:
root[a] += root[b]
root[b] = ... | Traceback (most recent call last):
File "/tmp/tmp5upuwy18/tmpnjaw23ol.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s736798817 | p02536 | u439063038 | 1601224066 | Python | PyPy3 (7.3.0) | py | Runtime Error | 110 | 69520 | 460 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * (110000)
def find(x):
if root[x] >= 0:
r = find(x)
root[x] = r
return r
def unite(a, b):
a = find(a)
b = find(b)
if a != b:
root[a] += root[b]
root[b] = a
for _ in range(m... | Traceback (most recent call last):
File "/tmp/tmpko0d69wa/tmpdz4ms3zp.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s432817345 | p02536 | u439063038 | 1601224007 | Python | PyPy3 (7.3.0) | py | Runtime Error | 145 | 69128 | 377 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * (110000)
def find(x):
if root[x] >= 0:
r = find(x)
root[x] = r
return r
def unite(a, b):
a = find(a)
b = find(b)
if a != b:
root[a] += root[b]
root[b] = a
for _ in range(m... | Traceback (most recent call last):
File "/tmp/tmpkj4jwomw/tmpow8u84pm.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s348601070 | p02536 | u439063038 | 1601223706 | Python | PyPy3 (7.3.0) | py | Runtime Error | 270 | 74836 | 742 | n, m = map(int, input().split())
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]
d... | Traceback (most recent call last):
File "/tmp/tmpqoxx5vlx/tmp4ljo7yha.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s636120362 | p02536 | u439063038 | 1601223400 | Python | PyPy3 (7.3.0) | py | Runtime Error | 634 | 544948 | 445 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
root = [-1] * (110000)
def find(x):
if root[x] > 0:
x = find(x)
return x
def unite(a, b):
a = find(a)
b = find(b)
if a != b:
root[a] += root[b]
root[b] = a
for _ in range(m):
a, b = ma... | Traceback (most recent call last):
File "/tmp/tmpkq3_y85w/tmp44ryrm66.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s397791238 | p02536 | u439063038 | 1601223179 | Python | PyPy3 (7.3.0) | py | Runtime Error | 122 | 73800 | 402 | n, m = map(int, input().split())
root = [-1] * (110000)
def find(x):
if root[x] > 0:
x = find(x)
return x
def unite(a, b):
a = find(a)
b = find(b)
if a != b:
root[a] += root[b]
root[b] = a
for _ in range(m):
a, b = map(int, input().split())
unite(a, b)
an... | Traceback (most recent call last):
File "/tmp/tmpz3kqlhqq/tmprhk1gpb8.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s073814805 | p02536 | u252828980 | 1601221448 | Python | Python (3.8.2) | py | Runtime Error | 343 | 26988 | 399 | N, M = map(int, input().split())
AB = [[] for _ in range(N)]
for _ in range(M):
a,b = map(lambda x: int(x)-1, input().split())
AB[a].append(b)
AB[b].append(a)
def dfs(v):
visited[v] = 1
for i in AB[v]:
if visited[i]:
continue
dfs(i)
visited = [0]*N
cnt = 0
for i in ran... | Traceback (most recent call last):
File "/tmp/tmp410sw6xx/tmpiqp486l9.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s767234047 | p02536 | u252828980 | 1601221264 | Python | Python (3.8.2) | py | Runtime Error | 327 | 27084 | 449 | n,m = map(int,input().split())
L = [[] for _ in range(n)]
for i in range(m):
a,b = map(lambda x:int(x)-1,input().split())
L[a].append(b)
L[b].append(a)
def dfs(i):
if visited[i]:
return
visited[i] = True
for j in L[i]:
if visited[j]:
continue
dfs(j)
... | Traceback (most recent call last):
File "/tmp/tmpb61gctf4/tmp90xqqu23.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s961184850 | p02536 | u252828980 | 1601221201 | Python | Python (3.8.2) | py | Runtime Error | 344 | 26936 | 415 | n,m = map(int,input().split())
L = [[] for _ in range(n)]
for i in range(m):
a,b = map(lambda x:int(x)-1,input().split())
L[a].append(b)
L[b].append(a)
def dfs(i):
visited[i] = True
for j in L[i]:
if visited[j]:
continue
dfs(j)
visited = [False]*n
cnt = 0
... | Traceback (most recent call last):
File "/tmp/tmppnm4ld2s/tmpwyyxj_qu.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s443125052 | p02536 | u423966555 | 1601218292 | Python | Python (3.8.2) | py | Runtime Error | 286 | 26336 | 507 | def dfs(v):
visited[v] = 1
for i in AB[v]:
if visited[i]:
continue
dfs(i)
def main():
N, M = map(int, input().split())
AB = [[] for _ in range(N)]
for _ in range(M):
a,b = map(lambda x: int(x)-1, input().split())
AB[a].append(b)
AB[b].append(a)
... | Traceback (most recent call last):
File "/tmp/tmpfcvljs1n/tmpockmkk1k.py", line 27, in <module>
main()
File "/tmp/tmpfcvljs1n/tmpockmkk1k.py", line 9, in main
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s504817234 | p02536 | u423966555 | 1601218162 | Python | Python (3.8.2) | py | Runtime Error | 308 | 27340 | 531 | def main():
N, M = map(int, input().split())
AB = [[] for _ in range(N)]
for _ in range(M):
a,b = map(lambda x: int(x)-1, input().split())
AB[a].append(b)
AB[b].append(a)
def dfs(v):
visited[v] = 1
for i in AB[v]:
if visited[i]:
conti... | Traceback (most recent call last):
File "/tmp/tmpjem8ahsd/tmpja6c379x.py", line 27, in <module>
main()
File "/tmp/tmpjem8ahsd/tmpja6c379x.py", line 2, in main
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s724414509 | p02536 | u423966555 | 1601218046 | Python | Python (3.8.2) | py | Runtime Error | 296 | 27220 | 521 | def main():
N, M = map(int, input().split())
AB = [[] for _ in range(N)]
for _ in range(M):
a,b = map(lambda x: int(x)-1, input().split())
AB[a].append(b)
AB[b].append(a)
def dfs(v):
if visited[v]:
return
visited[v] = 1
for i in AB[v]:
... | Traceback (most recent call last):
File "/tmp/tmpfg3e0bzr/tmprh97rrug.py", line 27, in <module>
main()
File "/tmp/tmpfg3e0bzr/tmprh97rrug.py", line 2, in main
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s014461715 | p02536 | u344813796 | 1601213998 | Python | Python (3.8.2) | py | Runtime Error | 194 | 18436 | 411 | m,n=map(int,input().split())
par=[i for i in range(m)]
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x]) #経路圧縮
return par[x]
def same(x,y):
return find(x) == find(y)
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return 0
par[x] = y
for i i... | Traceback (most recent call last):
File "/tmp/tmpd_2vbsdg/tmp_sarjwep.py", line 1, in <module>
m,n=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s733449187 | p02536 | u010379708 | 1601212387 | Python | Python (3.8.2) | py | Runtime Error | 200 | 12640 | 1345 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x) -> int:
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) -> Non... | Traceback (most recent call last):
File "/tmp/tmp7a27vc79/tmp05x5xlya.py", line 48, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s358789589 | p02536 | u869790980 | 1601205739 | Python | PyPy2 (7.3.0) | py | Runtime Error | 68 | 64300 | 383 |
n,m = map(int, raw_input())
def g(u,parent):
if parent[u]!= u:
parent[u] = g(parent[u], parent)
return parent[u]
parent = {u:u for u in range(1, n+1)}
for _ in range(m):
u,v = map(int, raw_input().split())
pu,pv = g(u,parent), g(v,parent)
if pu!= pv:
parent[pu] = pv
ans = 0
for u ... | File "/tmp/tmp5b262orj/tmppj1cqfd7.py", line 19
print ans -1
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s207716317 | p02536 | u500006160 | 1601204705 | Python | PyPy2 (7.3.0) | py | Runtime Error | 232 | 122916 | 526 | import sys
input = sys.stdin.readline
n,m = (int(x) for x in input().split())
visited = [False for _ in xrange(n)]
graph = dict(((i,[]) for i in xrange(n)))
def dfs(node):
if visited[node]:
return None
visited[node] = True
for next_node in graph[node]:
dfs(next_node)
return None
for... | Traceback (most recent call last):
File "/tmp/tmpdu2uhnv8/tmpxrutaejn.py", line 5, in <module>
n,m = (int(x) for x in input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s822957280 | p02536 | u500006160 | 1601203729 | Python | Python (3.8.2) | py | Runtime Error | 335 | 28028 | 405 | from collections import defaultdict
n,m=map(int,input().split())
visited=[0]*n
d=defaultdict(list)
def dfs(n):
visited[n]=1
#print(visited)
for i in d[n]:
if visited[i]==0:
dfs(i)
for i in range (m):
a,b=map(int,input().split())
a,b=a-1,b-1
d[a].append(b)
d[b].append(a)... | Traceback (most recent call last):
File "/tmp/tmpzuwpccas/tmpy3f9p77z.py", line 3, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s328840069 | p02536 | u500006160 | 1601203607 | Python | Python (3.8.2) | py | Runtime Error | 310 | 28020 | 468 | from collections import defaultdict
n, m=map(int,input().split())
visited=[False for _ in range(n)]
graph = defaultdict(list)
def dfs(node):
visited[node]=1
for next_node in graph[node]:
if visited[next_node]==0:
dfs(next_node)
for _ in range(m):
a,b=map(int,input().split())
a,b=... | Traceback (most recent call last):
File "/tmp/tmpk0xupxk0/tmpbz479afo.py", line 3, in <module>
n, m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s201035161 | p02536 | u500006160 | 1601203280 | Python | Python (3.8.2) | py | Runtime Error | 332 | 28008 | 483 | from collections import defaultdict
n,m = (int(x) for x in input().split())
visited = [False for _ in range(n)]
graph = defaultdict(list)
for _ in range(m):
u,v = (int(x)-1 for x in input().split())
graph[u].append(v)
graph[v].append(u)
def dfs(node):
if not visited[node]:
visited[node] = T... | Traceback (most recent call last):
File "/tmp/tmpduo4ud1d/tmpw3ir5isj.py", line 3, in <module>
n,m = (int(x) for x in input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s301410899 | p02536 | u500006160 | 1601202773 | Python | Python (3.8.2) | py | Runtime Error | 387 | 34492 | 480 | n,m = (int(x) for x in input().split())
visited = [False for _ in range(n)]
graph = dict(((i,[]) for i in range(n)))
def dfs(node):
if visited[node]:
return None
visited[node] = True
for next_node in graph[node]:
dfs(next_node)
return None
for _ in range(m):
u,v = (int(x) - 1 for x... | Traceback (most recent call last):
File "/tmp/tmpghmertmz/tmp3w1h_83s.py", line 1, in <module>
n,m = (int(x) for x in input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s545006600 | p02536 | u500006160 | 1601202517 | Python | PyPy2 (7.3.0) | py | Runtime Error | 417 | 124204 | 796 | import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')
n,m = (in... | Traceback (most recent call last):
File "/tmp/tmpnxh_f1av/tmp5ktsvkgc.py", line 12, in <module>
n,m = (int(x) for x in input().split())
^^^^^^^
File "/tmp/tmpnxh_f1av/tmp5ktsvkgc.py", line 8, in <lambda>
input = lambda: sys.stdin.readline().rstrip('\r\n')
^^^^^... | |
s211322098 | p02536 | u500006160 | 1601202225 | Python | PyPy2 (7.3.0) | py | Runtime Error | 501 | 127504 | 834 | import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')
n,m = (in... | Traceback (most recent call last):
File "/tmp/tmpjlssj3rf/tmpeqi4juev.py", line 12, in <module>
n,m = (int(x) for x in input().split())
^^^^^^^
File "/tmp/tmpjlssj3rf/tmpeqi4juev.py", line 8, in <lambda>
input = lambda: sys.stdin.readline().rstrip('\r\n')
^^^^^... | |
s139945847 | p02536 | u397080265 | 1601196434 | Python | PyPy3 (7.3.0) | py | Runtime Error | 233 | 115868 | 4942 | #Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threadi... | Traceback (most recent call last):
File "/tmp/tmpmrrk03ow/tmp8mzxme3d.py", line 137, in <module>
n,m=map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s478173963 | p02536 | u729133443 | 1601194487 | Python | Python (3.8.2) | py | Runtime Error | 350 | 53524 | 193 | (n,m),*a=[map(int,t.split())for t in open(0)]
p=[-1]*-~n
for a in a:
b,a=sorted(map(r:=lambda x:x*(p[x]<0)or r(p[x]),a),key=p.__getitem__)
if a-b:p[a]+=p[b];p[b]=a
print(sum(i<0for i in p)-2) | /tmp/tmp6joa_8hg/tmpay4kbw3h.py:6: SyntaxWarning: invalid decimal literal
print(sum(i<0for i in p)-2)
Traceback (most recent call last):
File "/tmp/tmp6joa_8hg/tmpay4kbw3h.py", line 1, in <module>
(n,m),*a=[map(int,t.split())for t in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at lea... | |
s274776308 | p02536 | u729133443 | 1601194374 | Python | Python (3.8.2) | py | Runtime Error | 365 | 53524 | 167 | (n,m),*a=[map(int,t.split())for t in open(0)]
p=[-1]*-~n
for a in a:
a,b=map(r:=lambda x:x*(p[x]<0)or r(p[x]),a)
if a-b:p[a]+=p[b];p[b]=a
print(sum(i<0for i in p)-2) | /tmp/tmp7910uw9p/tmpsr63pg_3.py:6: SyntaxWarning: invalid decimal literal
print(sum(i<0for i in p)-2)
Traceback (most recent call last):
File "/tmp/tmp7910uw9p/tmpsr63pg_3.py", line 1, in <module>
(n,m),*a=[map(int,t.split())for t in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at lea... | |
s954920185 | p02536 | u694665829 | 1601193235 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9020 | 559 | from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int,input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
checked = [False]*n
q = deque([])
cnt = 0
#連結成分のカウント
for i in range(n):
if checked[i]:
continue
checked[i] = Tru... | File "/tmp/tmpk0yxr3h4/tmptfhr44iy.py", line 30
print(cnt - 1
^
SyntaxError: '(' was never closed
| |
s566756348 | p02536 | u224993839 | 1601192524 | Python | PyPy3 (7.3.0) | py | Runtime Error | 363 | 152780 | 372 |
from collections import defaultdict
visited=set()
def dfs(visited,graph,node):
if node not in visited:
visited.add(node)
for neighbour in graph[node]:
dfs(visited,graph,neighbour)
n,m=map(int,input().split())
d=defaultdict(list)
for i in range(m):
a,b=map(int,input().split())
d[a].append(b)
d[b].append(... | Traceback (most recent call last):
File "/tmp/tmpuhk4emnq/tmp31l40z1y.py", line 11, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s221624836 | p02536 | u224993839 | 1601192404 | Python | PyPy3 (7.3.0) | py | Runtime Error | 392 | 161396 | 367 |
from collections import defaultdict
visited=set()
def dfs(visited,graph,node):
if node not in visited:
visited.add(node)
for neighbour in graph[node]:
dfs(visited,graph,neighbour)
n,m=map(int,input().split())
d=defaultdict(list)
for i in range(m):
a,b=map(int,input().split())
d[a].append(b)
d[b].append(... | Traceback (most recent call last):
File "/tmp/tmp772m9dct/tmpqekwcin7.py", line 11, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s621051951 | p02536 | u216928054 | 1601189829 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 68740 | 1322 | """
Union-Find Tree / Disjoint Set Union (DSU)
"""
def init_unionfind(N):
global parent, rank, NUM_VERTEX
NUM_VERTEX = N
parent = [-1] * N
rank = [0] * N
def find_root(x):
p = parent[x]
if p == -1:
return x
p2 = find_root(p)
parent[x] = p2
return p2
def unite(x, y):
... | File "/tmp/tmp90pejwaa/tmpza985cfk.py", line 61
a, b = map(int, input().split()))
^
SyntaxError: unmatched ')'
| |
s251312525 | p02536 | u332657092 | 1601189470 | Python | PyPy3 (7.3.0) | py | Runtime Error | 268 | 81600 | 1330 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmprhxsec6r/tmp_9vkm881.py", line 48, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s009550572 | p02536 | u332657092 | 1601189195 | Python | PyPy3 (7.3.0) | py | Runtime Error | 277 | 75276 | 1300 | 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):
x = ... | Traceback (most recent call last):
File "/tmp/tmpgvcq9cec/tmpkz81pnp6.py", line 48, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s139090892 | p02536 | u197922478 | 1601187849 | Python | PyPy3 (7.3.0) | py | Runtime Error | 113 | 71460 | 1923 | class UnionFind:
def __init__(self,n):
self.param = [-1]*N
self.tree = [0]*N
def clustering(self,x,y):
x ,y =min(x,y), max(x,y)
#小さいほうが未知
if self.param[x] == -1:
#どちらも未知
if self.param[y] == -1:
self.param[x] = y
... | Traceback (most recent call last):
File "/tmp/tmp1k9uyxfm/tmpdgog8iao.py", line 46, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s145505297 | p02536 | u197922478 | 1601187478 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 71536 | 1805 | class UnionFind:
def __init__(self,n):
self.param = [-1]*N
self.tree = [0]*N
def clustering(self,x,y):
x ,y =min(x,y), max(x,y)
#小さいほうが未知
if self.param[x] == -1:
#どちらも未知
if self.param[y] == -1:
self.param[x] = y
... | Traceback (most recent call last):
File "/tmp/tmprrivmmim/tmpi_m55iao.py", line 42, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s584677630 | p02536 | u404034840 | 1601187361 | Python | Python (3.8.2) | py | Runtime Error | 49 | 9256 | 635 | n,m = map(int,input().split())
a = []
cnt = 0
dl = []
for i in range(m):
x,y = map(int,input().split())
if i == 0:
a.append([])
a[0].append(x)
a[0].append(y)
else:
f = -1
for j in range(len(a)):
if f == -1 and (x in a[j] or y in a[j]):
a[j].append(x)
a[j].append(y)
... | Traceback (most recent call last):
File "/tmp/tmpk04z_o_9/tmp95nwjw9e.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s125065103 | p02536 | u197922478 | 1601186865 | Python | PyPy3 (7.3.0) | py | Runtime Error | 87 | 71688 | 1805 | class UnionFind:
def __init__(self,n):
self.param = [-1]*N
self.tree = [0]*N
def clustering(self,x,y):
x ,y =min(x,y), max(x,y)
#小さいほうが未知
if self.param[x] == -1:
#どちらも未知
if self.param[y] == -1:
self.param[x] = y
... | Traceback (most recent call last):
File "/tmp/tmpttvhd7sv/tmpxzeowf_v.py", line 42, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s382333859 | p02536 | u381585104 | 1601186480 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9008 | 3275 | #![allow(dead_code,unused_variables)]
use proconio::{fastout, input};
#[fastout]
fn main() {
input! {
n: usize,
m: usize,
}
let mut uf = Dsu::new(n);
for i in 0..m{
input!(a:usize,b:usize);
uf.merge(a-1,b-1);
}
println!("{}",uf.groups().len()-1);
}
//https://gith... | File "/tmp/tmpt9lk34us/tmpyi0x841b.py", line 2
use proconio::{fastout, input};
^^^^^^^^
SyntaxError: invalid syntax
| |
s212614510 | p02536 | u437351386 | 1601186096 | Python | PyPy3 (7.3.0) | py | Runtime Error | 313 | 82336 | 931 | n,m=map(int,input().split())
#Union-Find木
#par[i]:iの親 deep[i]:iの深さ size[i]:iの大きさ
par=[i for i in range(n)]
deep=[1]*n
size=[1]*n
#親を見つける
def find(x):
if par[x]==x:
return x
else:
return find(par[x])
#二つのグループを統合する
def unite(x,y):
x=find(x)
y=find(y)
if x==y:
return
if deep[x]<deep[y]:
par[x... | Traceback (most recent call last):
File "/tmp/tmp3el82l0a/tmpqxwmuk1m.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s701497403 | p02536 | u197922478 | 1601185758 | Python | PyPy3 (7.3.0) | py | Runtime Error | 122 | 74596 | 1752 | class UnionFind:
def __init__(self,n):
self.param = [-1]*N
self.tree = [0]*N
def clustering(self,x,y):
x ,y =min(x,y), max(x,y)
#小さいほうが未知
if self.param[x] == -1:
#どちらも未知
if self.param[y] == -1:
self.param[x] = y
... | Traceback (most recent call last):
File "/tmp/tmpresafpfb/tmprczy9vl1.py", line 42, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s627668593 | p02536 | u197922478 | 1601185569 | Python | PyPy3 (7.3.0) | py | Runtime Error | 3026 | 292172 | 1791 | class UnionFind:
def __init__(self,n):
self.param = [-1]*N
self.tree = [0]*N
def clustering(self,x,y):
x ,y =min(x,y), max(x,y)
#小さいほうが未知
if self.param[x] == -1:
#どちらも未知
if self.param[y] == -1:
self.param[x] = y
... | Traceback (most recent call last):
File "/tmp/tmpbvph9caz/tmpkronssez.py", line 42, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s704482481 | p02536 | u197922478 | 1601185075 | Python | PyPy3 (7.3.0) | py | Runtime Error | 116 | 74568 | 1940 | N, M = map(int, input().split())
class UnionFind:
def __init__(self,n):
self.param = [-1]*N
self.tree = [0]*N
def unite(self,x,y):
pass
#親を探す
def search(self,x,y):
pass
def clustering(self,x,y):
x ,y =min(x,y), max(x,y)
#小さいほうが未... | Traceback (most recent call last):
File "/tmp/tmpxzi5m1nx/tmpa1riax_j.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s366541719 | p02536 | u734876600 | 1601185068 | Python | Python (3.8.2) | py | Runtime Error | 322 | 30768 | 453 | n,m = map(int, input().split())
li = [[] for _ in range(n)]
for i in range(m):
a,b = map(int, input().split())
a -= 1
b -= 1
li[a].append(b)
li[b].append(a)
nodes = [_ for _ in range(n)]
group = [1]*n
def dfs(node, group):
s = li[node]
group[node]=0
for v in s:
if group[v]!=0:
... | Traceback (most recent call last):
File "/tmp/tmp7psvbb8f/tmpkvgmqy3a.py", line 1, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s150822983 | p02536 | u197922478 | 1601184975 | Python | PyPy3 (7.3.0) | py | Runtime Error | 119 | 74672 | 1921 | N, M = map(int, input().split())
class UnionFind:
def __init__(self,n):
self.param = [-1]*N
self.tree = [0]*N
def unite(self,x,y):
pass
#親を探す
def search(self,x,y):
pass
def clustering(self,x,y):
x ,y =min(x,y), max(x,y)
#小さいほうが未... | Traceback (most recent call last):
File "/tmp/tmphx_tio3g/tmpr3all554.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s478456634 | p02536 | u734876600 | 1601184720 | Python | Python (3.8.2) | py | Runtime Error | 327 | 30892 | 452 | n,m = map(int, input().split())
li = [[] for _ in range(n)]
for i in range(m):
a,b = map(int, input().split())
a -= 1
b -= 1
li[a].append(b)
li[b].append(a)
nodes = [i for i in range(n)]
group = [1]*n
def dfs(node, group):
s = li[node]
group[node]=0
for v in s:
if group[v]!=0:
... | Traceback (most recent call last):
File "/tmp/tmpfrrhil78/tmpb6qqdasi.py", line 1, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.