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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s741736133 | p02573 | u570155187 | 1598984052 | Python | Python (3.8.2) | py | Runtime Error | 574 | 63100 | 749 | from collections import Counter
n,m = map(int,input().split())
ab = list(list(map(int,input().split())) for _ in range(m))
a,b = [list(i) for i in zip(*ab)]
group = [-1]*(n+1)
group_name = 0
for i in range(m):
if group[a[i]] == -1 and group[b[i]] == -1:
group[a[i]] = group_name
group[b[i]] = group_name
... | Traceback (most recent call last):
File "/tmp/tmpdvy12h73/tmpewkqqrxz.py", line 3, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s277352767 | p02573 | u124864167 | 1598981415 | Python | Python (3.8.2) | py | Runtime Error | 1726 | 309708 | 108 | from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))]),1,1)) | Traceback (most recent call last):
File "/tmp/tmpkju4npvw/tmp__6p9bru.py", line 1, in <module>
from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))]),1,1))
^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s227432252 | p02573 | u124864167 | 1598981272 | Python | Python (3.8.2) | py | Runtime Error | 1675 | 309632 | 108 | from networkx import*
_,*n=map(str.split,open(0))
print(len(max([*connected_components(Graph(n))],key=len))) | Traceback (most recent call last):
File "/tmp/tmpl6j6ut8e/tmpu0bg9f5x.py", line 2, in <module>
_,*n=map(str.split,open(0))
^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s891155073 | p02573 | u124864167 | 1598980697 | Python | Python (3.8.2) | py | Runtime Error | 1651 | 309768 | 104 | from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))]))) | Traceback (most recent call last):
File "/tmp/tmpo91_5vgz/tmps07s9j1b.py", line 1, in <module>
from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))])))
^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s335783804 | p02573 | u200887663 | 1598978180 | Python | Python (3.8.2) | py | Runtime Error | 537 | 31840 | 599 | #n = int(input())
n, m = map(int, input().split())
#al = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
fgroup = {i: 0 for i in range(1, n+1)}
g_id = 0
for i in range(m):
a, b = map(int, input().split())
if fgroup[a] != 0:
fgroup[b] = fgroup[a]
elif fgroup[b... | Traceback (most recent call last):
File "/tmp/tmp1sm1012f/tmp93jh56pr.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s062993370 | p02573 | u803865203 | 1598970599 | Python | Python (3.8.2) | py | Runtime Error | 665 | 17884 | 800 | from collections import Counter
class UnionFind:
def __init__(self,num:int):
self.r = [-1 for i in range(num)]
def root(self,x:int):
if(self.r[x] < 0):
return x
self.r[x] = self.root(self.r[x])
return self.r[x]
def unite(self,x:int,y:int):
rx = self.root(... | Traceback (most recent call last):
File "/tmp/tmplf8z0mq0/tmpe32jfypj.py", line 24, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s640747227 | p02573 | u818213347 | 1598966282 | Python | Python (3.8.2) | py | Runtime Error | 989 | 94036 | 871 | import sys
sys.setrecursionlimit(10000)
class Graph:
def __init__(self,n,side):
self.side = side
self.neighbor = [set() for i in range(n+1)]
self.visited = [False]*(n+1)
self.group =[0]*n
self.product()
def product(self):
for a,b in self.side:
self.ne... | Traceback (most recent call last):
File "/tmp/tmp0acfvk5x/tmptk6_4umo.py", line 28, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s767443318 | p02573 | u818213347 | 1598966227 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9092 | 856 | sys.setrecursionlimit(10000)
class Graph:
def __init__(self,n,side):
self.side = side
self.neighbor = [set() for i in range(n+1)]
self.visited = [False]*(n+1)
self.group =[0]*n
self.product()
def product(self):
for a,b in self.side:
self.neighbor[a].a... | Traceback (most recent call last):
File "/tmp/tmpku3h4_e2/tmp48w8xz2m.py", line 1, in <module>
sys.setrecursionlimit(10000)
^^^
NameError: name 'sys' is not defined
| |
s953123381 | p02573 | u113255362 | 1598964916 | Python | Python (3.8.2) | py | Runtime Error | 628 | 46968 | 1267 | N,M=map(int,input().split())
List = []
for i in range (M):
List.append(list(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[... | Traceback (most recent call last):
File "/tmp/tmpw4vp3jn5/tmpaqgi7ezw.py", line 1, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s005369858 | p02573 | u818213347 | 1598964699 | Python | Python (3.8.2) | py | Runtime Error | 986 | 87512 | 830 | class Graph:
def __init__(self,n,side):
self.side = side
self.neighbor = [set() for i in range(n+1)]
self.visited = [False]*(n+1)
self.product()
self.group =[0]*n
def product(self):
for a,b in self.side:
self.neighbor[a].add(b)
self.neighbo... | Traceback (most recent call last):
File "/tmp/tmph6d1hkwx/tmpoec5io7n.py", line 25, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s208999102 | p02573 | u818213347 | 1598964001 | Python | Python (3.8.2) | py | Runtime Error | 986 | 87724 | 838 | class Graph:
def __init__(self,n,m,side):
self.side = side
self.neighbor = [set() for i in range(n+1)]
self.visited = [False]*(n+1)
self.product()
self.group =[0]*(n+1)
def product(self):
for a,b in self.side:
self.neighbor[a].add(b)
self.n... | Traceback (most recent call last):
File "/tmp/tmpehzuai8f/tmphxizlt6e.py", line 25, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s938141707 | p02573 | u909224749 | 1598953721 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 17068 | 872 | class UnionFindTree():
def __init__(self, num_leaves):
#self.num_leaves = num_leaves
self.root = [i for i in range(num_leaves+1)]
def find(self, leaf):
if self.root[leaf] == leaf:
return self.root[leaf]
else:
self.root[leaf] = self.find(self.root[... | Traceback (most recent call last):
File "/tmp/tmp1vp2u49g/tmpn6ql4_c7.py", line 22, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s875277316 | p02573 | u803865203 | 1598953063 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 230892 | 732 | from collections import Counter
class UnionFind:
def __init__(self,num:int):
self.parents = [i for i in range(num)]
def root(self,x:int):
if(self.parents[x] == x):
return x
return self.root(self.parents[x])
def unite(self,x:int,y:int):
rx = self.root(x)
r... | Traceback (most recent call last):
File "/tmp/tmpdtgn3a_2/tmpog1ytsex.py", line 21, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s770799801 | p02573 | u282813849 | 1598911216 | Python | Python (3.8.2) | py | Runtime Error | 1038 | 88040 | 465 | N, M = [int(k) for k in input().split()]
nodes = {k:set() for k in range(1,N+1)}
visited = [False for i in range(N+2)]
for i in range(M):
a, b = [int(k) for k in input().split()]
nodes[a].add(b)
nodes[b].add(a)
def dfs(i):
visited[i] = True
cnt = 1
for j in nodes[i]:
if not visited[j]:
cnt += ... | Traceback (most recent call last):
File "/tmp/tmphcu1wxbl/tmpzm62klal.py", line 1, in <module>
N, M = [int(k) for k in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s025978158 | p02573 | u923172145 | 1598910723 | Python | PyPy3 (7.3.0) | py | Runtime Error | 87 | 74788 | 2086 | # データ構造: Union Find (素集合データ構造)
# 前提
# グラフ(頂点と辺からなる集合)上の各頂点が、どの連結成分に属しているかを管理するときに使う
# 具体的には、各連結成分ごとに適当な1点を親として、同じ連結成分に属する他の点が子になるように配置する
# できること
# 1, ある頂点の親を返す (つまり、どの連結成分に属するかがわかる)
# 2, 新たな辺が与えられた時、必要なら連結成分の統合を行う
# 以下、事前準備。(本処理は42行目から)
# 上記1,2を実現する関数を作成する。
# 0, 前提
par = [-1]*n
# 配列parの要素par[i]には、
# ... | Traceback (most recent call last):
File "/tmp/tmpgznnamrt/tmpjmjn26_p.py", line 13, in <module>
par = [-1]*n
^
NameError: name 'n' is not defined
| |
s678843955 | p02573 | u282813849 | 1598910717 | Python | Python (3.8.2) | py | Runtime Error | 1017 | 88168 | 453 | N, M = [int(k) for k in input().split()]
nodes = {k:set() for k in range(1,N+1)}
visited = [False for i in range(N+1)]
for i in range(M):
a, b = [int(k) for k in input().split()]
nodes[a].add(b)
nodes[b].add(a)
def dfs(i):
visited[i] = True
cnt = 1
for j in nodes[i]:
if not visited[j]:
cnt += ... | Traceback (most recent call last):
File "/tmp/tmpgb74pehw/tmpkjff63bp.py", line 1, in <module>
N, M = [int(k) for k in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s273461688 | p02573 | u543016260 | 1598910591 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9092 | 1250 | import sys
import math
N=int(input())
A=list(map(int,input().split()))
def sieve_of_eratosthenes(n): #エラトステネスのふるい
candidate = list(range(2, n+1)) #候補
prime = []
limit = n**0.5 + 1 #+1がないと平方数を素数にしてしまう
while True:
p = candidate[0]
if limit <= p:
prime.extend(candidate) #この時... | Traceback (most recent call last):
File "/tmp/tmpmpxr192m/tmpydce93j0.py", line 3, in <module>
N=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s200706133 | p02573 | u282813849 | 1598910349 | Python | Python (3.8.2) | py | Runtime Error | 812 | 59480 | 436 | N, M = [int(k) for k in input().split()]
nodes = {k:[] for k in range(1,N+1)}
visited = [False for i in range(N+1)]
for i in range(M):
a, b = [int(k) for k in input().split()]
nodes[a].append(b)
nodes[b].append(a)
def dfs(i):
visited[i] = True
cnt = 1
for j in nodes[i]:
if not visited[j]:
cnt ... | Traceback (most recent call last):
File "/tmp/tmpcsymdu4_/tmpxb45cxi_.py", line 1, in <module>
N, M = [int(k) for k in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s983717299 | p02573 | u282813849 | 1598910057 | Python | Python (3.8.2) | py | Runtime Error | 1036 | 88156 | 433 | N, M = [int(k) for k in input().split()]
nodes = {k:set() for k in range(1,N+1)}
visited = [False for i in range(N+1)]
for i in range(M):
a, b = [int(k) for k in input().split()]
nodes[a].add(b)
nodes[b].add(a)
def dfs(i):
visited[i] = True
cnt = 1
for j in nodes[i]:
if not visited[j]:
cnt += ... | Traceback (most recent call last):
File "/tmp/tmpldmk97tv/tmpguwdftt5.py", line 1, in <module>
N, M = [int(k) for k in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s739640943 | p02573 | u282813849 | 1598909766 | Python | Python (3.8.2) | py | Runtime Error | 1028 | 87976 | 471 | N, M = [int(k) for k in input().split()]
nodes = {k:set() for k in range(1,N+1)}
visited = [False for i in range(N+1)]
for i in range(M):
a, b = [int(k) for k in input().split()]
nodes[a].add(b)
nodes[b].add(a)
def dfs(i):
visited[i] = True
cnt = 1
for j in nodes[i]:
if not visited[j]:
cnt += ... | Traceback (most recent call last):
File "/tmp/tmpw5g3ndrq/tmpsq3ohis9.py", line 1, in <module>
N, M = [int(k) for k in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s982372460 | p02573 | u282813849 | 1598904687 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 36432 | 673 | N, M = [int(a) for a in input().split()]
lol = []
for i in range(M):
a, b = [int(a) for a in input().split()]
found_a = -10
found_b = -10
for j in range(len(lol)):
if a in lol[j]:
found_a = j
if b in lol[j]:
found_b = j
if found_a >= 0 and found_b >= 0:
break
if found_a < 0 an... | Traceback (most recent call last):
File "/tmp/tmp1az2x3yr/tmp8_9qk6d5.py", line 1, in <module>
N, M = [int(a) for a in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s379328503 | p02573 | u837507786 | 1598903322 | Python | Python (3.8.2) | py | Runtime Error | 1994 | 254788 | 193 | from networkx import *
n,m = map(int, input().split())
G = Graph()
for i in range(m):
a,b = map(int, input().split())
G.add_edges_from([(a,b)])
print(len(max(connected_components(G)))) | Traceback (most recent call last):
File "/tmp/tmpj62gxrt7/tmpckgozr6z.py", line 2, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s262685602 | p02573 | u306033313 | 1598903309 | Python | Python (3.8.2) | py | Runtime Error | 978 | 17356 | 795 | class UnionFind:
def __init__(self, n):
self.r = [-1 for i in range(n)]
def root(self, x):
if self.r[x] < 0:
return x
self.r[x] = self.root(self.r[x])
return self.r[x]
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x ... | Traceback (most recent call last):
File "/tmp/tmpa93hbehz/tmp585gd19l.py", line 27, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s749483799 | p02573 | u306033313 | 1598903284 | Python | Python (3.8.2) | py | Runtime Error | 946 | 19684 | 807 | class UnionFind:
def __init__(self, n):
self.r = [-1 for i in range(n)]
def root(self, x):
if self.r[x] < 0:
return x
self.r[x] = self.root(self.r[x])
return self.r[x]
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x ... | Traceback (most recent call last):
File "/tmp/tmp5ernsbbp/tmp_wmxod09.py", line 27, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s226579580 | p02573 | u284854859 | 1598900722 | Python | Python (3.8.2) | py | Runtime Error | 532 | 45088 | 566 | import sys,heapq
input = sys.stdin.buffer.readline
n,m = map(int,input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
a,b = map(int,input().split())
edge[a-1].append(b-1)
edge[b-1].append(a-1)
#True:訪問済み False:未訪問
flag = [False]*n
def dfs(now):
if flag[now]:
return 0
f... | Traceback (most recent call last):
File "/tmp/tmp82z7qxim/tmp45ywf261.py", line 5, in <module>
n,m = map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s020132165 | p02573 | u284854859 | 1598900682 | Python | PyPy3 (7.3.0) | py | Runtime Error | 405 | 170556 | 566 | import sys,heapq
input = sys.stdin.buffer.readline
n,m = map(int,input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
a,b = map(int,input().split())
edge[a-1].append(b-1)
edge[b-1].append(a-1)
#True:訪問済み False:未訪問
flag = [False]*n
def dfs(now):
if flag[now]:
return 0
f... | Traceback (most recent call last):
File "/tmp/tmpjclxzvi6/tmps43p_z_i.py", line 5, in <module>
n,m = map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s556025095 | p02573 | u684814987 | 1598896661 | Python | Python (3.8.2) | py | Runtime Error | 792 | 46564 | 431 | n, m = map(int, input().split())
friends = [[] for i in range(n)]
def dfs(i):
ans[-1] += 1
flg[i] = 1
for j in friends[i]:
if not flg[j]:
dfs(j)
return
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
friends[a].append(b)
friends[b].append(a)
... | Traceback (most recent call last):
File "/tmp/tmpy6wo_wt9/tmpjbiq7fx9.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s753255198 | p02573 | u684814987 | 1598896601 | Python | Python (3.8.2) | py | Runtime Error | 912 | 73920 | 428 | n, m = map(int, input().split())
friends = [set() for i in range(n)]
def dfs(i):
ans[-1] += 1
flg[i] = 1
for j in friends[i]:
if not flg[j]:
dfs(j)
return
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
friends[a].add(b)
friends[b].add(a)
fl... | Traceback (most recent call last):
File "/tmp/tmpkncdxn21/tmpl3m8hti_.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s625463351 | p02573 | u684814987 | 1598896536 | Python | Python (3.8.2) | py | Runtime Error | 891 | 73808 | 416 | n, m = map(int, input().split())
friends = [set() for i in range(n)]
def dfs(i):
ans[-1] += 1
flg[i] = 1
for j in friends[i]:
if not flg[j]:
dfs(j)
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
friends[a].add(b)
friends[b].add(a)
flg = [0]*n
a... | Traceback (most recent call last):
File "/tmp/tmpok3vr0hi/tmpx0rs74ls.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s506010851 | p02573 | u753386263 | 1598890552 | Python | PyPy3 (7.3.0) | py | Runtime Error | 94 | 74752 | 1 | a | Traceback (most recent call last):
File "/tmp/tmpx3cxrk20/tmpahib5kqy.py", line 1, in <module>
a
NameError: name 'a' is not defined
| |
s850262727 | p02573 | u868055170 | 1598889029 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8944 | 619 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.pa... | File "/tmp/tmp_6p6z5ol/tmpn46ycgov.py", line 34
^
SyntaxError: invalid non-printable character U+00A0
| |
s007482431 | p02573 | u868055170 | 1598889001 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9048 | 615 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.pa... | File "/tmp/tmpwc8z2_3y/tmpgsf5tpx0.py", line 34
^
SyntaxError: invalid non-printable character U+00A0
| |
s488278900 | p02573 | u868055170 | 1598888769 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9064 | 624 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.pa... | File "/tmp/tmps0n5gdye/tmphfck96ap.py", line 34
^
SyntaxError: invalid non-printable character U+00A0
| |
s528146112 | p02573 | u868055170 | 1598888730 | Python | Python (3.8.2) | py | Runtime Error | 27 | 8928 | 610 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.pa... | File "/tmp/tmp3np8zd5b/tmpiy8jff62.py", line 34
^
SyntaxError: invalid non-printable character U+00A0
| |
s629366733 | p02573 | u589969467 | 1598887459 | Python | Python (3.8.2) | py | Runtime Error | 837 | 36820 | 540 | def f(n):
global myFriend
if len(myFriend[n])==0:
return []
else:
ans = []
for i in list(set(myFriend[n])):
ans += [i]
ans += f(i)
myFriend[n] = []
return ans
n,m = map(int,input().split())
myFriend = [[] for i in range(n+1)]
for i in range(m)... | Traceback (most recent call last):
File "/tmp/tmpfcjgscoe/tmpj78bms14.py", line 13, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s597026682 | p02573 | u926266624 | 1598885273 | Python | Python (3.8.2) | py | Runtime Error | 810 | 80460 | 646 | N,M= map(int,input().split())
ListM = [[0 for i in range(2)] for j in range(M)]
for m in range(M):
a, b = map(int,input().split())
if a < b:
ListM[m][0] = a
ListM[m][1] = b
else:
ListM[m][0] = b
ListM[m][1] = a
ListM = list(map(list, set(map(tuple, ListM))))
ListT = {{ListM[0][0]},{ListM[0][1... | Traceback (most recent call last):
File "/tmp/tmpq0uvl73l/tmpn6r64lxy.py", line 1, in <module>
N,M= map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s035566843 | p02573 | u250734103 | 1598882857 | Python | Python (3.8.2) | py | Runtime Error | 738 | 26328 | 947 | N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
A[i], B[i] = 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:
... | Traceback (most recent call last):
File "/tmp/tmp2cmz74_2/tmpb7zv3yjp.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s684416662 | p02573 | u250734103 | 1598881185 | Python | Python (3.8.2) | py | Runtime Error | 924 | 26824 | 1261 | N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
A[i], B[i] = map(int, input().split())
class UnionFind:
def __init__(self, n):
# 親要素のノード番号を格納。par[x] == xの時そのノードは根
self.par = [-1 for i in range(n + 1)]
# 検索
# 根ならその番号を返す
def find(self, x):
... | Traceback (most recent call last):
File "/tmp/tmpudoeo7ih/tmplekephhz.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s646367003 | p02573 | u806976856 | 1598879704 | Python | PyPy3 (7.3.0) | py | Runtime Error | 577 | 82036 | 441 |
n,m=map(int,input().split())
root=[-1]*n
def r(x):
if root[x]<0:
return x
else:
root[x]=r(root[x])
return root[x]
def unite(x,y):
x=r(x)
y=r(y)
if x==y:
return
root[x]+=root[y]
root[y]=x
def size(x):
x=r(x)
return -root[x]
for i in range(m):
x,y=m... | Traceback (most recent call last):
File "/tmp/tmpl9470plt/tmp4vv567je.py", line 2, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s460853859 | p02573 | u157232135 | 1598879452 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9020 | 255 | def main():
n,m=map(int,input().split())
uf=UnionFind(n)
for a,b in (map(lambda x: int(x)-1, input().split()) for _ in range(m)):
uf.union(a,b)
print(max((uf.size(x) for x in uf.roots())))
if __name__ == "__main__":
main() | Traceback (most recent call last):
File "/tmp/tmpvvfa2ql3/tmpawse8fgc.py", line 9, in <module>
main()
File "/tmp/tmpvvfa2ql3/tmpawse8fgc.py", line 2, in main
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s512683367 | p02573 | u607563136 | 1598872545 | Python | Python (3.8.2) | py | Runtime Error | 521 | 19768 | 845 | class UnionFind():
def __init__(self,n):
self.parents = [-1]*(n+1)
def find(self, x):
if self.parents[x] < x:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.... | Traceback (most recent call last):
File "/tmp/tmpln4kkpk4/tmprm4o0zoa.py", line 29, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s281690243 | p02573 | u537976628 | 1598871903 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 26668 | 694 | n, m = map(int,input().split())
grp = []
grp1 = set()
if m == 0:
print(1)
else:
a, b = map(int, input().split())
grp.append({a,b})
grp1.add(a)
grp1.add(b)
for _ in range(m - 1):
a, b = map(int, input().split())
if a not in grp1 and b not in grp1:
grp.append({a,b})... | Traceback (most recent call last):
File "/tmp/tmpjnnyozir/tmpk_1028s8.py", line 1, in <module>
n, m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s832105843 | p02573 | u607563136 | 1598870943 | Python | Python (3.8.2) | py | Runtime Error | 513 | 16604 | 715 | class UnionFind():
def __init__(self,n):
self.parents = [-1]*(n+1)
def find(self, x):
if self.parents[x] < x:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.... | Traceback (most recent call last):
File "/tmp/tmpxkjpfcx9/tmp9bg9kbcp.py", line 26, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s667862272 | p02573 | u617384447 | 1598869961 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 84104 | 927 | N, M = map(int, input().split())
encountered = []
friends = []
for _ in range(M):
a, b = map(int, input().split())
a_enc = a in encountered
b_enc = b in encountered
if [a_enc, b_enc] == [False, False]:
friends += [[a, b]]
encountered += [a, b]
elif [a_enc, b_enc] == [False, True]:
for i i... | Traceback (most recent call last):
File "/tmp/tmpebblhnoy/tmpd933x73l.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s943974326 | p02573 | u688587139 | 1598869744 | Python | Python (3.8.2) | py | Runtime Error | 498 | 36400 | 651 | N, M = map(int, input().split())
dic = {} # 各人が何番グループに属しているか
num = {} # 各グループに何人属しているか
count = 0 # グループの番号
for _ in range(M):
a, b = map(int, input().split())
if a in dic and b not in dic:
dic[b] = dic[a]
num[dic[a]] += 1
elif a not in dic and b in dic:
dic[a] = dic[b]
nu... | Traceback (most recent call last):
File "/tmp/tmph215le5k/tmptdh9ur03.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s235585235 | p02573 | u132620066 | 1598866771 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 137660 | 280 | n, m = map(int, input().split())
d = [list(map(int, input().split())) for i in range(m)]
f = []
for i in d:
for j in f:
if i[0] in j or i[1] in j:
j.add(i[0])
j.add(i[1])
break
else:
f.append(set(i))
a = []
for i in f:a.append(len(i))
print(max(a)) | Traceback (most recent call last):
File "/tmp/tmp4fvys6pm/tmpsoqiaimf.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s794827170 | p02573 | u588592871 | 1598866008 | Python | Python (3.8.2) | py | Runtime Error | 647 | 71380 | 571 | N,M=input().split(' ')
n,m=int(N),int(M)
flist=[input().split(' ')for i in range(m)]
Alist=[int(0)for i in range(n)]
num=0
for i in range(m):
a_i,b_i=int(flist[i][0]),int(flist[i][1])
if Alist[a_i-1]==0 and Alist[b_i-1]==0:
num+=1
Alist[a_i-1]=num
Alist[b_i-1]=num
elif Alist[b_i-1]=... | Traceback (most recent call last):
File "/tmp/tmp2glbbyq0/tmp5sh_siaq.py", line 1, in <module>
N,M=input().split(' ')
^^^^^^^
EOFError: EOF when reading a line
| |
s755442200 | p02573 | u588592871 | 1598865882 | Python | Python (3.8.2) | py | Runtime Error | 587 | 71304 | 524 | N,M=input().split(' ')
n,m=int(N),int(M)
flist=[input().split(' ')for i in range(m)]
Alist=[int(0)for i in range(n)]
num=0
for i in range(m):
a_i,b_i=int(flist[i][0]),int(flist[i][1])
if Alist[a_i-1]==0 and Alist[b_i-1]==0:
num+=1
Alist[a_i-1]=num
Alist[b_i-1]=num
elif Alist[a_i-1]!... | Traceback (most recent call last):
File "/tmp/tmpmrvx16ua/tmptcwt_ago.py", line 1, in <module>
N,M=input().split(' ')
^^^^^^^
EOFError: EOF when reading a line
| |
s807180853 | p02573 | u588592871 | 1598865859 | Python | Python (3.8.2) | py | Runtime Error | 645 | 73756 | 566 | N,M=input().split(' ')
n,m=int(N),int(M)
flist=[input().split(' ')for i in range(m)]
Alist=[int(0)for i in range(n)]
num=0
for i in range(m):
a_i,b_i=int(flist[i][0]),int(flist[i][1])
if Alist[a_i-1]==0 and Alist[b_i-1]==0:
num+=1
Alist[a_i-1]=num
Alist[b_i-1]=num
elif Alist[a_i-1]!... | Traceback (most recent call last):
File "/tmp/tmpng66gerq/tmpj4ahb9hq.py", line 1, in <module>
N,M=input().split(' ')
^^^^^^^
EOFError: EOF when reading a line
| |
s465650484 | p02573 | u650932312 | 1598860618 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 39836 | 839 | N, M = map(int, input().split())
list = []
A_prev = 0
B_prev = 0
for i in range(M):
A, B = map(int, input().split())
[A, B] = [min(A,B), max(A,B)]
if [A, B] == [A_prev, B_prev]:
continue
else:
list.append([A, B])
A_prev = A
B_prev = B
list.sort()
group = [list[0]]
for i ... | Traceback (most recent call last):
File "/tmp/tmpfiw3er38/tmpgum9q94y.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s115042610 | p02573 | u243312682 | 1598857721 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9364 | 2445 |
def main():
from itertools import chain
import sys
input = sys.stdin.readline
def gcd(x, y):
if y == 0:
return x
return gcd(y, x % y)
# 6n+1, 6n-1でも求めて、素数**2+素数*kはふるいおとす
def prime_set(N):
"""
Nまでの素数のsetを返す
"""
if N < 4:
re... | Traceback (most recent call last):
File "/tmp/tmpjoa4yuf_/tmp_9t6bv05.py", line 91, in <module>
main()
File "/tmp/tmpjoa4yuf_/tmp_9t6bv05.py", line 42, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s376677121 | p02573 | u879309973 | 1598854002 | Python | Python (3.8.2) | py | Runtime Error | 979 | 113828 | 524 | from collections import Counter
def solve(n, m, a, b):
parents = list(range(n+1))
def root(x):
return root(parents[x]) if parents[x] != x else x
for u, v in zip(a, b):
u = root(u)
v = root(v)
if u > v:
u, v = v, u
if u != v:
parents[v] = u
... | Traceback (most recent call last):
File "/tmp/tmpsiks83o1/tmp6e3vxo_4.py", line 15, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s375255195 | p02573 | u879309973 | 1598853496 | Python | Python (3.8.2) | py | Runtime Error | 951 | 113812 | 477 | from collections import Counter
def solve(n, m, a, b):
parents = list(range(n+1))
def root(x):
return root(parents[x]) if parents[x] != x else x
for i in range(m):
u = root(a[i])
v = root(b[i])
if u > v:
u, v = v, u
if u != v:
parents[v] = u
... | Traceback (most recent call last):
File "/tmp/tmp02a0ob12/tmpw5hkln1w.py", line 15, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s617908250 | p02573 | u064505481 | 1598839745 | Python | PyPy3 (7.3.0) | py | Runtime Error | 705 | 218060 | 1058 | from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math
#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().spl... | Traceback (most recent call last):
File "/tmp/tmpctqzu4e9/tmpsc6fehlc.py", line 49, in <module>
main()
File "/tmp/tmpctqzu4e9/tmpsc6fehlc.py", line 17, in main
n, m = rli()
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s679522538 | p02573 | u064505481 | 1598839638 | Python | PyPy3 (7.3.0) | py | Runtime Error | 715 | 217984 | 1054 | from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math
#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().spl... | Traceback (most recent call last):
File "/tmp/tmpkjx92yj5/tmptlb76soo.py", line 49, in <module>
main()
File "/tmp/tmpkjx92yj5/tmptlb76soo.py", line 17, in main
n, m = rli()
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s431065787 | p02573 | u887959172 | 1598836988 | Python | PyPy3 (7.3.0) | py | Runtime Error | 820 | 141472 | 972 | class UnionFind:
def __init__(self):
self.parents = {}
self.sz = {}
self.size = 0
def add(self, a):
if a in self.parents:
return
self.size += 1
self.sz[a] = 1
self.parents[a] = a
def find(self, a):
if self.parents[a] != a:
... | Traceback (most recent call last):
File "/tmp/tmpsim9a83e/tmp1e53guuo.py", line 36, in <module>
n,m = list(map(int,input().split(" ")))
^^^^^^^
EOFError: EOF when reading a line
| |
s160643778 | p02573 | u688219499 | 1598832618 | Python | Python (3.8.2) | py | Runtime Error | 2271 | 2685108 | 499 | n, m = map(int, input().split())
d = dict()
flag = [[True] * n for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
if flag[a - 1][b - 1] == True:
if flag[b - 1][a - 1] == True:
if a not in d:
d[a] = 1
else:
d[a] += 1
... | Traceback (most recent call last):
File "/tmp/tmps2rxi6g_/tmpb6trqvoi.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s172087206 | p02573 | u218216885 | 1598832086 | Python | Python (3.8.2) | py | Runtime Error | 2205 | 9816 | 764 | N, M = [int(i) for i in input().split()]
L = []
for i in range(M):
a, b = [int(j) for j in input().split()]
for j in range(len(L)):
ifa = a in L[j]
ifb = b in L[j]
if (not ifb) and ifa:
L[j].append(b)
break
elif (not ifa) and ifb:
L[j].append(a)
break
elif ifa and ifb:
... | Traceback (most recent call last):
File "/tmp/tmpgq0k4xch/tmpuk9mh_np.py", line 1, in <module>
N, M = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s235291980 | p02573 | u218216885 | 1598831939 | Python | Python (3.8.2) | py | Runtime Error | 2205 | 9808 | 689 | N, M = [int(i) for i in input().split()]
L = []
for i in range(M):
a, b = [int(j) for j in input().split()]
for j in range(len(L)):
ifa = a in L[j]
ifb = b in L[j]
if (not ifb) and ifa:
L[j].append(b)
break
elif (not ifa) and ifb:
L[j].append(a)
break
elif ifa and ifb:
... | Traceback (most recent call last):
File "/tmp/tmp7r7cd0s_/tmpweroevqd.py", line 1, in <module>
N, M = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s792633241 | p02573 | u218834617 | 1598830266 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 222408 | 332 | import sys
ans=0
g=[]
n=0
input()
for s in sys.stdin:
x=set()
d=[]
for a in s.split():
x.add(a)
for i in range(len(g)):
if a in g[i]:
d+=[i]
x|=g[i]
for i in d:
del g[i]
g.append(x)
if g:
print(max(len(t) for t in g))
else:
... | Traceback (most recent call last):
File "/tmp/tmputsc_ovb/tmpyr7llgrc.py", line 6, in <module>
input()
EOFError: EOF when reading a line
| |
s629529607 | p02573 | u218834617 | 1598829471 | Python | Python (3.8.2) | py | Runtime Error | 2205 | 10088 | 232 | import sys
ans=0
g=set()
input()
for s in sys.stdin:
for a in s.split():
for u in [*g]:
if a in u:
g.discard(u)
s+=u
g.add(s)
print(max(len(set(t.split())) for t in g))
| Traceback (most recent call last):
File "/tmp/tmpqomqw8ir/tmppx6vj0ij.py", line 5, in <module>
input()
EOFError: EOF when reading a line
| |
s462029730 | p02573 | u218834617 | 1598829300 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 219820 | 232 | import sys
ans=0
g=set()
input()
for s in sys.stdin:
for a in s.split():
for u in [*g]:
if a in u:
g.discard(u)
s+=u
g.add(s)
print(max(len(set(t.split())) for t in g))
| Traceback (most recent call last):
File "/tmp/tmpsn7hl8tk/tmp3q9hr320.py", line 5, in <module>
input()
EOFError: EOF when reading a line
| |
s389476655 | p02573 | u218834617 | 1598828821 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2240 | 1492900 | 196 | import sys
ans=0
g=[]
input()
for s in sys.stdin:
for a in s.split():
for u in g:
if a in u:
s+=u
g+=[s]
print(max(len(set(t.split())) for t in g))
| Traceback (most recent call last):
File "/tmp/tmpcfqzj0qp/tmpzn8fto5m.py", line 5, in <module>
input()
EOFError: EOF when reading a line
| |
s374056643 | p02573 | u970267139 | 1598826515 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 66472 | 717 | from collections import deque
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
t = []
s = set()
q = deque()
a, b = ab[0]
q.append(a)
lt = set
while len(q) != 0:
x = q.popleft()
s.add(x)
tt = {x}
tmp = []
#print(x)
#print(ab)
for a, b in ab:
... | Traceback (most recent call last):
File "/tmp/tmpva1cik1_/tmp71x3pw3l.py", line 3, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s258494723 | p02573 | u938005055 | 1598825534 | Python | Python (3.8.2) | py | Runtime Error | 650 | 14356 | 748 | class UnionFind:
def __init__(self, length):
self.r = [-1] * length
def root(self, x):
if (self.r[x]) < 0:
return x
return self.r[x] - self.root(self.r[x])
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return F... | Traceback (most recent call last):
File "/tmp/tmp4uai9aa5/tmp7rw1jf2k.py", line 31, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s322977872 | p02573 | u938005055 | 1598825448 | Python | Python (3.8.2) | py | Runtime Error | 500 | 14516 | 744 | class UnionFind:
def __init__(self, length):
self.r = [-1] * length
def root(self, x):
if (self.r[x]) < 0:
return x
return self.r[x] - self.root(self.r[x])
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return F... | Traceback (most recent call last):
File "/tmp/tmpar1lvak7/tmpe3tb_2os.py", line 31, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s868145180 | p02573 | u970267139 | 1598825299 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 52316 | 583 | from collections import deque
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
t = []
s = set()
q = deque()
a, b = ab[0]
q.append(a)
lt = set
while len(q) != 0:
x = q.popleft()
s.add(x)
tt = [x]
for a, b in ab:
if a in tt and b not in s:
tt... | Traceback (most recent call last):
File "/tmp/tmpdp9lf1qa/tmp9xuzqfr_.py", line 3, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s614961772 | p02573 | u649840780 | 1598825131 | Python | Python (3.8.2) | py | Runtime Error | 1158 | 51228 | 1192 | class Node():
def __init__(self,index):
self.index = index
self.parent = self
self.size = 1
@staticmethod
def find_set(node):
if node.parent == node:
return node
root = Node.find_set(node.parent)
node.parent = root
root.size += 1
... | Traceback (most recent call last):
File "/tmp/tmpnair36eq/tmpj6w3q32r.py", line 29, in <module>
n,m = [int(val) for val in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s880082899 | p02573 | u169165784 | 1598824949 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 63528 | 913 | import numpy
class UnionFind:
def __init__(self, N):
self.N = N
# the parent of all node is itself
self.parent = list(range(N))
def root(self, i):
if self.parent[i] == i:
return i
else:
return self.root(self.parent[i])
def unite(self, i, j)... | Traceback (most recent call last):
File "/tmp/tmps7bpxin2/tmpymrn6jj8.py", line 28, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s628310774 | p02573 | u972991614 | 1598824924 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 24616 | 499 | n,m = map(int,input().split())
x = []
for i in range(m):
t = list(map(int,input().split()))
if len(x)>0:
for j in range(len(x)):
r = 0
while r <len(x[j]):
if x[j][r] == t[0] or x[j][r] == t[1]:
x[j].extend(t)
break
... | Traceback (most recent call last):
File "/tmp/tmpfg2ircr0/tmppfthgb_p.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s650488326 | p02573 | u124864167 | 1598824228 | Python | PyPy3 (7.3.0) | py | Runtime Error | 336 | 167188 | 316 | l=lambda:map(int, input().split())
n,m=l()
p=[-1]*n
def r(x):
if p[x]<0:return x
p[x]=r(p[x]);return r(p[x])
def u(x,y):
x,y=r(x),(y)
if x==y: return
if x>y: x,y=y,x
p[x]+=p[y]
p[y]=x
def e(x,y):
return r(x)==r(y)
def s(x):
return -p[r(x)]
for _ in range(m):
a,b=l()
u(a-1,b-1)
print(-min(p)) | Traceback (most recent call last):
File "/tmp/tmpdcq5rtbs/tmpkh6v367z.py", line 2, in <module>
n,m=l()
^^^
File "/tmp/tmpdcq5rtbs/tmpkh6v367z.py", line 1, in <lambda>
l=lambda:map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s094996875 | p02573 | u649840780 | 1598824131 | Python | Python (3.8.2) | py | Runtime Error | 1148 | 51188 | 1192 | class Node():
def __init__(self,index):
self.index = index
self.parent = self
self.size = 1
@staticmethod
def find_set(node):
if node.parent == node:
return node
root = Node.find_set(node.parent)
node.parent = root
root.size += 1
... | Traceback (most recent call last):
File "/tmp/tmp2aacd1j7/tmpcgh3ovnp.py", line 29, in <module>
n,m = [int(val) for val in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s648388748 | p02573 | u543000780 | 1598823583 | Python | Python (3.8.2) | py | Runtime Error | 815 | 19336 | 871 | class UnionTree:
def __init__(self,n):
self.parent = [i for i in range(n)]
def get_root(self,m):
if self.parent[m] == m:
return m
else:
self.parent[m] = self.get_root(self.parent[m])
return self.parent[m]
def have_same_root(self,n,m):
if se... | Traceback (most recent call last):
File "/tmp/tmpivxfp9b1/tmp0kmhfvjv.py", line 20, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s318398922 | p02573 | u649840780 | 1598823528 | Python | Python (3.8.2) | py | Runtime Error | 1162 | 50432 | 1044 | class Node():
def __init__(self,index):
self.index = index
self.parent = self
@staticmethod
def find_set(node):
if node.parent == node:
return node
root = Node.find_set(node.parent)
node.parent = root
return root
@staticmethod
def union... | Traceback (most recent call last):
File "/tmp/tmpi_0ymles/tmp35tbelot.py", line 24, in <module>
n,m = [int(val) for val in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s329244265 | p02573 | u543000780 | 1598823407 | Python | Python (3.8.2) | py | Runtime Error | 836 | 19176 | 855 | class UnionTree:
def __init__(self,n):
self.parent = [i for i in range(n)]
def get_root(self,m):
if self.parent[m] == m:
return m
else:
self.parent[m] = self.get_root(self.parent[m])
return self.parent[m]
def have_same_root(self,n,m):
if se... | Traceback (most recent call last):
File "/tmp/tmpwtad4l_u/tmpyg06fkwx.py", line 20, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s566509592 | p02573 | u543000780 | 1598823245 | Python | Python (3.8.2) | py | Runtime Error | 842 | 19104 | 825 | class UnionTree:
def __init__(self,n):
self.parent = [i for i in range(n)]
def get_root(self,m):
if self.parent[m] == m:
return m
else:
self.parent[m] = self.get_root(self.parent[m])
return self.parent[m]
def have_same_root(self,n,m):
if se... | Traceback (most recent call last):
File "/tmp/tmppjf9e44y/tmpghalxx11.py", line 20, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s636001513 | p02573 | u335599768 | 1598823076 | Python | Python (3.8.2) | py | Runtime Error | 2335 | 149336 | 584 | import sys
sys.setrecursionlimit(10 ** 9)
N, M = map(int, input().split())
root = [-1] * N
def parent(x):
if root[x] < 0:
return x
return parent(root[x])
def union(x, y):
x_parent = parent(x)
y_parent = parent(y)
if x_parent == y_parent:
return
root[x_parent] += root[y_parent... | Traceback (most recent call last):
File "/tmp/tmpuymo8pc6/tmpdm9zseyt.py", line 4, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s808581554 | p02573 | u820087133 | 1598822949 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 15368 | 452 | N, M = map(int, input().split())
par = [-1 for n in range(N)]
def root(a):
if par[a - 1] < 0:
return a
return root(par[a - 1])
def same(a, b):
if root(a) == root(b):
return True
else:
return False
def unite(a, b):
if not same(a, b):
a = root(a)
b = root(b)
par[a - 1] += par[b - 1... | Traceback (most recent call last):
File "/tmp/tmpnw40se72/tmps_4yi2c6.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s901411364 | p02573 | u916338311 | 1598822933 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 16968 | 343 | N, M = map(int, input().split())
l = [set(map(int, input().split()))]
max_cnt = 0
for _ in range(M-1):
flg = False
t = set(map(int, input().split()))
for i in range(len(l)):
s = l[i]
if t & s:
l[i] = t | s
flg = True
max_cnt = max(max_cnt, len(l[i]))
break
if not flg:
l.ap... | Traceback (most recent call last):
File "/tmp/tmp8apo5avl/tmpmg5u0nva.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s824625660 | p02573 | u820087133 | 1598822918 | Python | Python (3.8.2) | py | Runtime Error | 2341 | 149168 | 451 | N, M = map(int, input().split())
par = [-1 for n in range(N)]
def root(a):
if par[a - 1] < 0:
return a
return root(par[a - 1])
def same(a, b):
if root(a) == root(b):
return True
else:
return False
def unite(a, b):
if not same(a, b):
a = root(a)
b = root(b)
par[a - 1] += par[b - 1... | Traceback (most recent call last):
File "/tmp/tmp5upqr6ku/tmpplo917nm.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s208652288 | p02573 | u335599768 | 1598822828 | Python | Python (3.8.2) | py | Runtime Error | 2313 | 149328 | 584 | import sys
sys.setrecursionlimit(10 ** 9)
N, M = map(int, input().split())
root = [-1] * N
def parent(x):
if root[x] < 0:
return x
return parent(root[x])
def union(x, y):
x_parent = parent(x)
y_parent = parent(y)
if x_parent == y_parent:
return
root[x_parent] += root[y_parent... | Traceback (most recent call last):
File "/tmp/tmp3trjpi53/tmp1izrrv_5.py", line 4, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s208252492 | p02573 | u649840780 | 1598822683 | Python | Python (3.8.2) | py | Runtime Error | 1057 | 50812 | 997 | class Node():
def __init__(self,index):
self.index = index
self.parent = self
@staticmethod
def find_set(node):
if node.parent == node:
return node
return Node.find_set(node.parent)
@staticmethod
def union(node_a,node_b):
root_a = Node.find_set... | Traceback (most recent call last):
File "/tmp/tmpdjapg1lf/tmpy0d80lmj.py", line 22, in <module>
n,m = [int(val) for val in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s312890342 | p02573 | u543016260 | 1598822339 | Python | Python (3.8.2) | py | Runtime Error | 900 | 124336 | 389 | N, M=map(int, input().split())
AB= [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]
G=[0]*(N+1)
sw=1
for i in range(M):
if G[A[i]]+G[B[i]]==0:
G[A[i]]=sw
G[B[i]]=sw
sw+=1
if G[A[i]]!=0:
G[B[i]]=G[A[i]]
else:
G[A[i]]=G[B[i]]
G=G[1:]
imp... | Traceback (most recent call last):
File "/tmp/tmp8ohmxidz/tmpmmhswem0.py", line 1, in <module>
N, M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s020783093 | p02573 | u820087133 | 1598822201 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 14952 | 424 | N, M = map(int, input().split())
par = [-1 for n in range(N)]
def root(a):
if par[a - 1] < 0:
return a
return root(par[a - 1])
def same(a, b):
if root(a) == root(b):
return True
else:
return False
def unite(a, b):
if not same(a, b):
par[root(a) - 1] += par[root(b) - 1]
par[root(b) - ... | Traceback (most recent call last):
File "/tmp/tmpqlozgnhx/tmp2jc1ytu1.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s592296658 | p02573 | u543016260 | 1598821357 | Python | Python (3.8.2) | py | Runtime Error | 2208 | 116732 | 507 |
N, M=map(int, input().split())
AB= [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]
G=[[A[0],B[0]]]
for i in range(1,M):
count=0
for j in range(len(G)):
if A[i] in G[j]:
if B[i] not in G[j]:
G[j].append(B[i])
count=1
e... | Traceback (most recent call last):
File "/tmp/tmpti4s3g3d/tmpcmvv0zur.py", line 2, in <module>
N, M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s056739956 | p02573 | u894521144 | 1598819777 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 47240 | 498 | def main(N, M, C):
lst = []
for c in C:
for l in lst:
if c[0] in l:
l.add(c[1])
break
elif c[1] in l:
l.add(c[0])
break
else:
lst.append(set(c))
# print(lst)
print(max({len(l) for l in lst... | Traceback (most recent call last):
File "/tmp/tmpl6zw8q3n/tmpk_1v20qy.py", line 18, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s884987492 | p02573 | u968404618 | 1598819593 | Python | Python (3.8.2) | py | Runtime Error | 2385 | 184292 | 864 | # Union find
# かっつぱさんの解説と公式のスライドみた
# https://www.youtube.com/watch?time_continue=916&v=zxor0DdwoXA&feature=emb_logo
# https://www.slideshare.net/chokudai/union-find-49066733
import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
root = [-1]... | Traceback (most recent call last):
File "/tmp/tmpyh6sfju8/tmpn_l6_7uu.py", line 9, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s171732134 | p02573 | u740284863 | 1598819071 | Python | Python (3.8.2) | py | Runtime Error | 715 | 21896 | 764 | from collections import *
n,m = map(int,input().split())
par = [-1 for _ in range(n)]#par<0なら自身が親で要素の個数、>0なら子で親の位置示す
def root(i):
if par[i] < 0:
return i
else:
return root(par[i])
def size(a):
return -par[root(a)]
def union(a,b):
a = root(a)
b = root(b)
if a == b:#親が等しい
... | Traceback (most recent call last):
File "/tmp/tmpadehpazb/tmp0mevy3yw.py", line 2, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s019320180 | p02573 | u164471280 | 1598819041 | Python | Python (3.8.2) | py | Runtime Error | 861 | 17384 | 1156 | # union-find
# https://note.nkmk.me/python-union-find/
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[... | Traceback (most recent call last):
File "/tmp/tmpi4w26mtu/tmp8tuhi1v_.py", line 49, in <module>
main()
File "/tmp/tmpi4w26mtu/tmp8tuhi1v_.py", line 36, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s114842605 | p02573 | u740284863 | 1598818996 | Python | Python (3.8.2) | py | Runtime Error | 749 | 22000 | 763 | from collections import *
n,m = map(int,input().split())
par = [-1 for _ in range(n)]#par<0なら自身が親で要素の個数、>0なら子で親の位置示す
def root(i):
if par[i] < 0:
return i
else:
return root(par[i])
def size(a):
return -par[root(a)]
def union(a,b):
a = root(a)
b = root(b)
if a == b:#親が等しい
... | Traceback (most recent call last):
File "/tmp/tmp2sbpms4v/tmp51qxylsd.py", line 2, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s409168068 | p02573 | u164471280 | 1598817099 | Python | Python (3.8.2) | py | Runtime Error | 696 | 17568 | 1108 | # union-find
# https://note.nkmk.me/python-union-find/
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[... | Traceback (most recent call last):
File "/tmp/tmp3yrc9wql/tmp9qfxc0td.py", line 48, in <module>
main()
File "/tmp/tmp3yrc9wql/tmp9qfxc0td.py", line 35, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s681052253 | p02573 | u698901270 | 1598816974 | Python | Python (3.8.2) | py | Runtime Error | 1065 | 87264 | 889 | ans = 1
n, m = map(int, input().split())
d = dict()
vis = set()
def dfs(key, size):
global ans
for friend in d[key]:
if friend not in vis:
size+=1
vis.add(friend)
ans = max(ans, size)
# print("key", friend,"ans", ans,"s", size)
dfs(friend, siz... | Traceback (most recent call last):
File "/tmp/tmpkpby3ysh/tmpp9ahzygp.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s360452703 | p02573 | u335599768 | 1598816955 | Python | Python (3.8.2) | py | Runtime Error | 683 | 14212 | 555 | n, m = map(int, input().split())
root = [-1] * n
def r(x):
if root[x] < 0:
return x
else:
root[x] = r(root[x])
return root[x]
def unite(x, y):
x = r(x)
y = r(y)
if x == y:
return
root[x] += root[y]
root[y] = x
def size(x):
x = r(x)
return ... | Traceback (most recent call last):
File "/tmp/tmptki_utji/tmpuaidcj9y.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s291121363 | p02573 | u247529573 | 1598816900 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 48356 | 685 | ################ D
n, m = map(int, input().split())
info = []
for _ in range(m):
a, b = map(int, input().split())
info.append((a,b))
info = tuple(set(info))
comp = [[info[0][0],info[0][1]]]
for i in range(len(info)):
for k,group in enumerate(comp):
if info[i][0] in group and info [i][1] in group:... | Traceback (most recent call last):
File "/tmp/tmplnqy9hkh/tmpj6fl5_bf.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s909047287 | p02573 | u698901270 | 1598816817 | Python | Python (3.8.2) | py | Runtime Error | 1042 | 87356 | 889 | ans = 0
n, m = map(int, input().split())
d = dict()
vis = set()
def dfs(key, size):
global ans
for friend in d[key]:
if friend not in vis:
size+=1
vis.add(friend)
ans = max(ans, size)
# print("key", friend,"ans", ans,"s", size)
dfs(friend, siz... | Traceback (most recent call last):
File "/tmp/tmpt8lzgjd4/tmprgh_ejlq.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s569219577 | p02573 | u335599768 | 1598816715 | Python | Python (3.8.2) | py | Runtime Error | 710 | 14052 | 512 | n, m = map(int, input().split())
root = [-1] * n
def r(x):
if root[x] < 0:
return x
else:
root[x] = r(root[x])
return root[x]
def unite(x, y):
x = r(x)
y = r(y)
if x == y:
return
root[x] += root[y]
root[y] = x
def size(x):
x = r(x)
return ... | Traceback (most recent call last):
File "/tmp/tmp9maygjf6/tmphcbbr262.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s441468012 | p02573 | u698901270 | 1598816704 | Python | Python (3.8.2) | py | Runtime Error | 1110 | 87336 | 878 | ans = 0
n, m = map(int, input().split())
d = dict()
vis = set()
def dfs(key, size):
global ans
for friend in d[key]:
if friend not in vis:
size+=1
vis.add(friend)
ans = max(ans, size)
# print("key", friend,"ans", ans,"s", size)
dfs(friend, siz... | Traceback (most recent call last):
File "/tmp/tmpbkti6k7u/tmpg40lexic.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s736087415 | p02573 | u698901270 | 1598816618 | Python | Python (3.8.2) | py | Runtime Error | 1238 | 90000 | 887 | ans = 0
n, m = map(int, input().split())
d = dict()
vis = set()
def dfs(key, size):
global ans
for friend in d[key]:
if friend not in vis:
size+=1
vis.add(friend)
ans = max(ans, size)
# print("key", friend,"ans", ans,"s", size)
dfs(friend, siz... | Traceback (most recent call last):
File "/tmp/tmpddezvym5/tmpaaateudr.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s625367704 | p02573 | u476674874 | 1598816377 | Python | Python (3.8.2) | py | Runtime Error | 444 | 47056 | 714 | def main():
N, M = map(int, input().split())
groups = dict()
for _ in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
if a in groups and b in groups:
group[a] = groups[a] | groups[b]
groups[b] = groups[a]
elif a in groups:
... | Traceback (most recent call last):
File "/tmp/tmpcqkeaql1/tmpxaul9o4y.py", line 33, in <module>
main()
File "/tmp/tmpcqkeaql1/tmpxaul9o4y.py", line 2, in main
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s076734230 | p02573 | u476674874 | 1598816336 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8928 | 714 | def main():
N, M = map(int, input().split())
groups = dict()
for _ in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
if a in groups and b in groups:
group[a] = groups[a] | groups[b]
groups[b] = groups[a]
elif a in groups:
... | File "/tmp/tmph6qcbl8y/tmpoi4gcm09.py", line 23
print(01
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.