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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s086366622 | p02573 | u592944963 | 1598732887 | Python | Python (3.8.2) | py | Runtime Error | 825 | 71052 | 690 | N, M = map(int, input().split())
G = []
lookup_tab = {}
AB = [list(sorted((map(int, input().split())))) for _ in range(M)]
AB.sort()
for a, b in AB:
if a not in lookup_tab and b not in lookup_tab:
G.append({a, b})
lookup_tab[a] = len(G) - 1
lookup_tab[b] = len(G) - 1
elif a in lookup_t... | Traceback (most recent call last):
File "/tmp/tmp95cmrff5/tmp9j2o0g6k.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s327340344 | p02573 | u183509493 | 1598732885 | Python | Python (3.8.2) | py | Runtime Error | 752 | 18292 | 291 | n,m=map(int,input().split())
# Union-Find
a=list(range(n))
def find(x):
if a[x]==x:
return x
a[x] = find(a[x])
return a[x]
for _ in range(m):
x,y=map(lambda x:int(x)-1,input().split())
a[find(y)]=find(x)
count=[0]*n
for i in range(n):
count[find(i)] += 1
print(max(count))
| Traceback (most recent call last):
File "/tmp/tmp8ys5k6rf/tmpgqkn3afh.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s940701752 | p02573 | u670567845 | 1598732861 | Python | Python (3.8.2) | py | Runtime Error | 514 | 33568 | 425 | import collections
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())
ans = 0
f = [-1]*N
for i in range(M):
if f[A[i]-1] == -1 and f[B[i]-1] == -1:
f[A[i]-1] = i
f[B[i]-1] = i
elif f[A[i]-1] != -1 and f[B[i]-1] == -1:
f[B[i]-1] = f[A[i]-1]
el... | Traceback (most recent call last):
File "/tmp/tmpvbg268fh/tmpsj41nyu5.py", line 2, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s194931682 | p02573 | u074220993 | 1598732844 | Python | Python (3.8.2) | py | Runtime Error | 715 | 38012 | 489 | N, M = (int(x) for x in input().split())
import collections
Parent = [i for i in range(N)]
def fp(i):
global Parent
if Parent[i] == i:
return i
else:
Parent[i] == fp(Parent[i])
return Parent[i]
for _ in range(M):
a, b = (int(x) for x in input().split())
Parent[max(a,b)-1] = ... | Traceback (most recent call last):
File "/tmp/tmpmezg5s6o/tmpc9dscu5b.py", line 1, in <module>
N, M = (int(x) for x in input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s951173297 | p02573 | u521866787 | 1598732837 | Python | Python (3.8.2) | py | Runtime Error | 721 | 18312 | 1147 | class UnionFind:
def __init__(self, n):
self.par = list(range(n)) #親
self.rank = [0] * n #根の深さ
# xの属する根を求める
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
def un... | Traceback (most recent call last):
File "/tmp/tmp490bocbg/tmp1k362wck.py", line 33, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s572491013 | p02573 | u572026348 | 1598732836 | Python | Python (3.8.2) | py | Runtime Error | 794 | 335616 | 364 | import numpy as np
def main():
n, m = map(int, input().split())
friends_mat = np.zeros((n, n), dtype=int)
for i in range(m):
a, b = map(int, input().split())
friends_mat[a - 1][b - 1] = 1
friends_mat[b - 1][a - 1] = 1
# print(friends_mat)
print(max(friends_mat.sum(axis=0)+1... | Traceback (most recent call last):
File "/tmp/tmpc6lm252h/tmpwwv1z7e3.py", line 16, in <module>
main()
File "/tmp/tmpc6lm252h/tmpwwv1z7e3.py", line 5, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s573421532 | p02573 | u882950355 | 1598732831 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 166284 | 519 | a = list(map(int,input().split()))
n = a[0]
m = a[1]
ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]
set_list = [{a[0],b[0]}]
for i in range(1,m):
flag = 0
for j in range(len(set_list)):
if a[i] in set_list[j] or b[i] in set_list[j]:
set_list[j].add(a[i])
set_l... | Traceback (most recent call last):
File "/tmp/tmpu98kimba/tmphuy2uvi8.py", line 1, in <module>
a = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s612689604 | p02573 | u088553842 | 1598732820 | Python | Python (3.8.2) | py | Runtime Error | 2135 | 230496 | 233 | import networkx as nx
n, m = map(int, input().split())
tree1 = nx.Graph()
for _ in range(m):
a, b = map(int, input().split())
tree1.add_edge(a, b)
res = 0
for i in range(1, n + 1):
res = max(res, tree1.degree(i))
print(res + 1) | Traceback (most recent call last):
File "/tmp/tmpvjpm4wxg/tmp0pn3c5uj.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s814593181 | p02573 | u521866787 | 1598732810 | Python | PyPy3 (7.3.0) | py | Runtime Error | 469 | 83084 | 1147 | class UnionFind:
def __init__(self, n):
self.par = list(range(n)) #親
self.rank = [0] * n #根の深さ
# xの属する根を求める
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
def un... | Traceback (most recent call last):
File "/tmp/tmpdpzkhuzu/tmpry8hvrlh.py", line 33, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s674602409 | p02573 | u003926785 | 1598732799 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 171092 | 544 | N, M = map(int, input().split())
l = []
A, B = map(int, input().split())
l.append((A, B))
for i in range(M-1):
A, B = map(int, input().split())
hit = None
for tup in l:
if A in tup or B in tup:
if hit != None:
hit = tuple(set(hit+tup+(A, B)))
else:
... | Traceback (most recent call last):
File "/tmp/tmphj70icg0/tmplmps8d9x.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s356837780 | p02573 | u960611411 | 1598732796 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 45644 | 1085 | [n,m] = list(map(int, input().split()))
abList = []
for i in range(m):
abList.append(list(map(int, input().split())))
class QuickFind(object):
id = []
count = 0
def __init__(self, n):
self.count = n
i = 0
while i < n:
self.id.append(i)
i += 1
def co... | Traceback (most recent call last):
File "/tmp/tmpnvoscv5n/tmph233ea98.py", line 1, in <module>
[n,m] = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s125021346 | p02573 | u169165784 | 1598732792 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 62960 | 733 | import numpy
N, M = map(int, input().split())
R = numpy.array([[int(r) for r in input().split()] for _ in range(M)]) - 1
size = [1] * N
groups = numpy.array([-1] * N)
gnum = 1
sameinfo = []
for p1, p2 in R:
g1 = groups[p1]
g2 = groups[p2]
if g1 == -1 and g2 == -1:
groups[p1] = gnum
gro... | Traceback (most recent call last):
File "/tmp/tmpf89_2nwy/tmp8_blo1hw.py", line 3, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s054789370 | p02573 | u559250296 | 1598732783 | Python | Python (3.8.2) | py | Runtime Error | 2221 | 335896 | 451 | import numpy as np
n,m =map(int,input().split())
a = np.zeros((n,n))
for i in range(m):
x,y = map(int,input().split())
a[x-1][y-1] = 1
a[y-1][x-1] = 1
used_list =[]
count =0
for j in range(n):
if j in used_list:
continue
else:
used_list.append(j)
count +=1
for k in range(j,n):
if k in used_lis... | Traceback (most recent call last):
File "/tmp/tmpmejahmy5/tmp4w1cnj77.py", line 2, in <module>
n,m =map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s886488890 | p02573 | u134185377 | 1598732738 | Python | Python (3.8.2) | py | Runtime Error | 2212 | 152420 | 610 | from collections import defaultdict
import numpy as np
import copy
N,M=map(int,input().split())
friend=defaultdict(list)
for _ in range(M):
a,b=map(int,input().split())
friend[a].append(b)
friend[b].append(a)
friend2={i:list(set(j)) for i,j in friend.items()}
for i,j in friend.items():
j=list(set(j))
... | Traceback (most recent call last):
File "/tmp/tmp951u0cpq/tmpxlr0ddrf.py", line 4, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s826319311 | p02573 | u087414215 | 1598732723 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2327 | 3522816 | 626 | from collections import deque
n,m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]
edge = [[0]*n for i in range(n)]
for i in range(m):
edge[a[i]-1][b[i]-1] = 1
edge[b[i]-1][a[i]-1] = 1
maxcon = 0
con = 0
yet = [-1 for i in range(n)]
for i in r... | Traceback (most recent call last):
File "/tmp/tmpasw1ugfy/tmpz9_dn7d4.py", line 3, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s999416166 | p02573 | u018808362 | 1598732711 | Python | Python (3.8.2) | py | Runtime Error | 1052 | 644972 | 297 | import numpy as np
N, M = map(int,input().split())
Adj=np.identity(N)
for i in range(M):
A, B= map(int,input().split())
Adj[A-1,B-1]=1
Adj[B-1,A-1]=1
AD=Adj**2
count=0
for i in range(N):
if np.count_nonzero(AD[i, :])>count:
count=np.count_nonzero(AD[i, :])
print(count) | Traceback (most recent call last):
File "/tmp/tmpo73l7_de/tmpxgf9_rbc.py", line 4, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s354177104 | p02573 | u074220993 | 1598732711 | Python | Python (3.8.2) | py | Runtime Error | 723 | 37992 | 486 | N, M = (int(x) for x in input().split())
import collections
Parent = [i for i in range(N)]
for _ in range(M):
a, b = (int(x) for x in input().split())
Parent[max(a,b)-1] = min(a,b)-1
def fp(i):
global Parent
if Parent[i] == i:
return i
else:
Parent[i] == fp(Parent[i])
return... | Traceback (most recent call last):
File "/tmp/tmpp5y_d_j8/tmppqldn1vq.py", line 1, in <module>
N, M = (int(x) for x in input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s110504514 | p02573 | u252405453 | 1598732708 | Python | Python (3.8.2) | py | Runtime Error | 781 | 56936 | 856 | def abc177d():
n, m = map(int, input().split())
check = [-1] * n
group_no = 0
group = {}
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
if check[a] == check[b] != -1: continue
if check[a] == check[b] == -1:
group[group_no] = {a, ... | Traceback (most recent call last):
File "/tmp/tmprkvsuavm/tmp0ihe0x1n.py", line 30, in <module>
abc177d()
File "/tmp/tmprkvsuavm/tmp0ihe0x1n.py", line 2, in abc177d
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s486171928 | p02573 | u107798522 | 1598732707 | Python | PyPy3 (7.3.0) | py | Runtime Error | 91 | 68720 | 155 | group = [1]*N
ngroup = [[0 for i in range(N)] for i in range(N)]
for i in range(M):
group[AB[i][0]-1] += 1
group[AB[i][1]-1] += 1
print(max(group)) | Traceback (most recent call last):
File "/tmp/tmpoebues_s/tmp5_bttg0p.py", line 1, in <module>
group = [1]*N
^
NameError: name 'N' is not defined
| |
s966997349 | p02573 | u521866787 | 1598732699 | Python | PyPy3 (7.3.0) | py | Runtime Error | 496 | 82416 | 1064 | class UnionFind:
def __init__(self, n):
self.par = list(range(n)) #親
self.rank = [0] * n #根の深さ
# xの属する根を求める
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
def un... | Traceback (most recent call last):
File "/tmp/tmp1nqtp3qx/tmpbu69hk__.py", line 33, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s511796895 | p02573 | u367319568 | 1598732692 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 42304 | 590 | N, M = map(int, input().split())
A_set = set()
B_set = set()
A = []
B = []
for i in range(M):
a, b = map(int, input().split())
if (a < b):
A_set.add(a)
A.append(a)
B_set.add(b)
B.append(b)
else:
A_set.add(b)
A.append(b)
B_set.add(a)
B.append(a... | Traceback (most recent call last):
File "/tmp/tmp6s9vz4n5/tmp515olyvc.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s403637144 | p02573 | u412255932 | 1598732684 | Python | PyPy3 (7.3.0) | py | Runtime Error | 784 | 195716 | 552 | from collections import defaultdict
def dfs(target):
if target in visited:
return 0
visited.add(target)
node_count = 1
for neighbor in adj_list[target]:
#if neighbor != parent:
node_count += dfs(neighbor)
return node_count
N, M = map(int, input().split())
A, B = [], []
ad... | Traceback (most recent call last):
File "/tmp/tmpb0hs3pmh/tmpls952n0i.py", line 13, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s697787831 | p02573 | u825343780 | 1598732666 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8976 | 205 | n = int(input())
a = list(map(int,input().split()))
sums = 0
for i in range(n):
sums += a[i]
sums *= sums;
ans = sums;
for i in range(n):
ans -= a[i]*a[i]
ans /= 2
ans %= 1000000007
print(ans)
| Traceback (most recent call last):
File "/tmp/tmp2s_7fbq5/tmp0w00ohp3.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s178463925 | p02573 | u872538555 | 1598732660 | Python | Python (3.8.2) | py | Runtime Error | 826 | 33980 | 999 | from collections import Counter
class UnionFind():
def __init__(self, n):
self.par = [i for i in range(n)]
self.rank = [0] * n
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par... | Traceback (most recent call last):
File "/tmp/tmp6krupvci/tmp2zknz16z.py", line 28, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s975652835 | p02573 | u749491107 | 1598732660 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 10372 | 446 | n, m = map(int, input().split())
x = [list(map(int, input().split()))]
for i in range(1, m):
ab = list(map(int, input().split()))
cnt = 0
for j in range(len(x)):
if ab[0] in x[j] or ab[1] in x[j]:
x[j].extend(ab)
x[j] = list(set(x[j]))
else:
cnt += 1
... | Traceback (most recent call last):
File "/tmp/tmp0ys2wq2j/tmph571pltu.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s187618790 | p02573 | u649769812 | 1598732658 | Python | Python (3.8.2) | py | Runtime Error | 1019 | 63580 | 706 | n, m = map(int, input().split())
friend_list = [set()]
input_list = []
for i in range(m):
a, b = map(int, input().split())
input_list.append([sorted([a, b])])
sorted(input_list)
for inp in input_list:
found = False
for friend_set in friend_list:
if inp[0] in friend_set:
friend_se... | Traceback (most recent call last):
File "/tmp/tmpx7puad7z/tmpt5j8facj.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s329429680 | p02573 | u880850253 | 1598732658 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 49268 | 1004 |
def get_unique_list(seq):
seen = []
return [x for x in seq if x not in seen and not seen.append(x)]
n,m= map(int,input().split())
s = set()
J = {}
for i in range(m):
t1,t2 = map(int,input().split())
if t1 < t2:
if t1 in J:
if t2 not in J[t1]:
J[t1].append(t2)
... | Traceback (most recent call last):
File "/tmp/tmpd7itvjud/tmp7w86d93y.py", line 6, in <module>
n,m= map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s895313870 | p02573 | u259190728 | 1598732655 | Python | PyPy2 (7.3.0) | py | Runtime Error | 146 | 64828 | 1616 | from __future__ import print_function
range = xrange
input = raw_input
import sys,bisect
from sys import stdin,stdout
from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right
from math import gcd,ceil,floor,sqrt
from collections import Counter,defaultdict,deque,OrderedDict
dx=[-1,1,0,0]
... | Traceback (most recent call last):
File "/tmp/tmphc14jd5x/tmpradq1209.py", line 2, in <module>
range = xrange
^^^^^^
NameError: name 'xrange' is not defined. Did you mean: 'range'?
| |
s697874379 | p02573 | u260370057 | 1598732646 | Python | Python (3.8.2) | py | Runtime Error | 2353 | 3551900 | 676 | n,m = map(int,input().split())
frl = [] #friend list
number = [0]*n #personal number
lnum = 1
for i in range(m):
a,b = map(int,input().split())
if number[a-1] == 0 and number[b-1] == 0:
number[a-1] = lnum
number[b-1] = lnum
frl.append([a,b])
lnum += 1
elif number[a-1] != 0 and number[b-1] != 0:
if number[a... | Traceback (most recent call last):
File "/tmp/tmp4mcjb944/tmpe8xfen1u.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s877031621 | p02573 | u804800128 | 1598732646 | Python | Python (3.8.2) | py | Runtime Error | 231 | 37920 | 1277 | import sys
input = sys.stdin.readline
def main():
n , m = map( int, input().split() )
Sets = []
Dicto = [ -1 for i in range(n + 1)]
for i in range( m ):
a , b = map( int , input().split() )
if Dicto[a] == -1 and Dicto[b] == -1:
Sets.append( set( [a,b] ) )
x_i =... | Traceback (most recent call last):
File "/tmp/tmp8khgyig3/tmppo0ovif3.py", line 48, in <module>
main()
File "/tmp/tmp8khgyig3/tmppo0ovif3.py", line 5, in main
n , m = map( int, input().split() )
^^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s896973381 | p02573 | u087414215 | 1598732644 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2354 | 3527416 | 637 | from collections import deque
n,m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]
edge = [[0]*n for i in range(n)]
for i in range(m):
edge[a[i]-1][b[i]-1] = 1
edge[b[i]-1][a[i]-1] = 1
maxcon = 0
con = 0
yet = [-1 for i in range(n)]
for i in ... | Traceback (most recent call last):
File "/tmp/tmpyg1hvx0l/tmpu_rya33x.py", line 3, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s566336402 | p02573 | u297089927 | 1598732640 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9524 | 611 | n,m=map(int,input().split())
li=[]
for i in range(m):
a,b=map(int,input().split())
if len(li)==0:
li.append([a,b])
else:
flag=0
for j in range(len(li)):
if a in li[j] and b not in li[j]:
li[j].append(b)
flag=1
elif a not in li[j... | Traceback (most recent call last):
File "/tmp/tmpmyrnkxvt/tmptl_ohiah.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s730237974 | p02573 | u581022379 | 1598732638 | Python | Python (3.8.2) | py | Runtime Error | 43 | 10908 | 1079 | from collections import Counter
N, M = map(int, input().split())
groups = [0] * (N + 1)
group_num_list = [[0]]
group_num = 1
for _ in range(M):
A, B = map(int, input().split())
if groups[A] != 0 and groups[B] != 0:
if groups[A] != groups[B]:
lower = min(groups[A], groups[B])
high... | Traceback (most recent call last):
File "/tmp/tmpda_epzh5/tmpl1gm4hhw.py", line 2, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s815763163 | p02573 | u457460736 | 1598732618 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 23776 | 844 | import math
import collections
import itertools
def resolve():
#N=int(input())
N,M=map(int,input().split())
Gr = [[] for y in range(N)]
GrNum=1
A0,B0=map(int,input().split())
Gr[0].append(A0)
Gr[0].append(B0)
Max=2
for i in range(M-1):
A,B=map(int,input().split())
f... | Traceback (most recent call last):
File "/tmp/tmp0vuwb7hh/tmpqpc0nnyo.py", line 38, in <module>
resolve()
File "/tmp/tmp0vuwb7hh/tmpqpc0nnyo.py", line 7, in resolve
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s714873508 | p02573 | u260204064 | 1598732597 | Python | Python (3.8.2) | py | Runtime Error | 451 | 32532 | 587 | n, m = map(int, input().split())
li = [0]*(n+1)
flag = 1
for _ in range(m):
a, b = map(int, input().split())
if li[a] and li[b]:
if li[a]!=li[b]:
x = li[b]
for i in len(li):
if li[i]==x:
li[i] = li[a]
elif li[a] or li[b]:
s = max(li... | Traceback (most recent call last):
File "/tmp/tmpzilnkk5j/tmp885zgmf5.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s443923152 | p02573 | u412255932 | 1598732559 | Python | PyPy3 (7.3.0) | py | Runtime Error | 777 | 201260 | 544 | from collections import defaultdict
def dfs(node):
if node in visited:
return 0
visited.add(node)
node_count = 1
for neighbor in adj_list[node]:
#if neighbor != parent:
node_count += dfs(neighbor)
return node_count
N, M = map(int, input().split())
A, B = [], []
adj_list =... | Traceback (most recent call last):
File "/tmp/tmp3ictg69l/tmp_58_1ii0.py", line 13, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s889486605 | p02573 | u170839742 | 1598732522 | Python | Python (3.8.2) | py | Runtime Error | 647 | 101936 | 495 | from collections import Counter
import sys
sys.setrecursionlimit(10 ** 5)
N, M = map(int, input().split())
parent = [-1] * N
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
parent[x] = y
def find(x):
if parent[x] == -1:
return x
res = parent[x] = find(parent[x])... | Traceback (most recent call last):
File "/tmp/tmpnl04_gc3/tmp_658uzep.py", line 7, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s832177967 | p02573 | u581022379 | 1598732512 | Python | Python (3.8.2) | py | Runtime Error | 658 | 31524 | 1078 | from collections import Counter
N, M = map(int, input().split())
groups = [0] * (N + 1)
group_num_list = [[0]]
group_num = 1
for _ in range(M):
A, B = map(int, input().split())
if groups[A] != 0 and groups[B] != 0:
if groups[A] != groups[B]:
lower = min(groups[A], groups[B])
high... | Traceback (most recent call last):
File "/tmp/tmpuyvj77v3/tmpcqnk9nt9.py", line 2, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s216378792 | p02573 | u267549387 | 1598732512 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 14856 | 1091 | #!/usr/bin/env python3
# from typing import Optional
# from typing import List
# from typing import Dict
# from typing import Tuple
# from typing import Sequence
def main():
args = input().split()
N = int(args[0])
M = int(args[1])
groupList = set()
for i in range(M):
args = list(map(lamb... | Traceback (most recent call last):
File "/tmp/tmp5buxqayz/tmp6xpmh5b3.py", line 45, in <module>
main()
File "/tmp/tmp5buxqayz/tmp6xpmh5b3.py", line 11, in main
args = input().split()
^^^^^^^
EOFError: EOF when reading a line
| |
s370495431 | p02573 | u933341648 | 1598732491 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 36440 | 877 | # from collections import deque
n, m = map(int, input().split())
# # arr = [tuple(map(int, input().split())) for _ in range(m)]
# f = {a: set() for a in range(1, n+1)}
# for _ in range(m):
# x, y = map(int, input().split())
# f[x].add(y)
# f[y].add(x)
# res = 0
# visited = set()
# stack = deque()
# for i... | Traceback (most recent call last):
File "/tmp/tmp5zfy5zoz/tmpz_c40w68.py", line 3, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s669712655 | p02573 | u226849101 | 1598732477 | Python | Python (3.8.2) | py | Runtime Error | 751 | 44656 | 551 | N,M = map(int,input().split())
E_list = [[]for i in range(N)]
marks = [False for i in range(N)]
def dfs(n):
global E_list
global marks
global N,M
marks[n] = True
steps = 1
for nx in E_list[n]:
if not marks[nx]:
marks[nx] = True
steps += dfs(nx)
retu... | Traceback (most recent call last):
File "/tmp/tmpa7zx0l3n/tmp1fmzn_zh.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s785753984 | p02573 | u255943004 | 1598732468 | Python | PyPy3 (7.3.0) | py | Runtime Error | 100 | 74256 | 1104 | from math import gcd
from collections import defaultdict
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
... | Traceback (most recent call last):
File "/tmp/tmp1ozrzlkm/tmps3uh26xy.py", line 19, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s129721282 | p02573 | u534610124 | 1598732459 | Python | Python (3.8.2) | py | Runtime Error | 2209 | 132024 | 558 | N,M = map(int, input().split())
dic = dict((i, set()) for i in range(1,N+1))
#print(dic)
for _ in range(M):
a,b = map(int, input().split())
dic[a].add(b)
dic[b].add(a)
#print(dic)
def dfs(x:int, marked:set):
a = set()
a = a.union(dic[x])
marked.add(x)
for i in dic[x]:
if i not ... | Traceback (most recent call last):
File "/tmp/tmpo59wn1so/tmpb32y3x04.py", line 1, in <module>
N,M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s688254783 | p02573 | u347502437 | 1598732458 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 13268 | 511 | N, M = map(int, input().split())
count = 0
people = set()
friends = []
while count < M:
A, B = map(int,input().split())
if A in people and B not in people:
for f in friends:
if A in f:
f += [B]
elif B in people and A not in people:
for f in friends:
if... | Traceback (most recent call last):
File "/tmp/tmpczxsti5n/tmpg7mqyplh.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s106850728 | p02573 | u412255932 | 1598732446 | Python | PyPy3 (7.3.0) | py | Runtime Error | 841 | 195716 | 539 | from collections import defaultdict
def dfs(node):
if node in visited:
return 0
visited.add(node)
count = 1
for neighbor in adj_list[node]:
#if neighbor != parent:
count += dfs(neighbor)
return count
N, M = map(int, input().split())
A, B = [], []
adj_list = defaultdict(se... | Traceback (most recent call last):
File "/tmp/tmpjw7ikut9/tmpz7qhdk_2.py", line 13, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s379886349 | p02573 | u202641516 | 1598732444 | Python | PyPy3 (7.3.0) | py | Runtime Error | 613 | 153200 | 545 | from collections import defaultdict as dc
x, y = map(int, input().split())
graph = [[] for n in range(x+1)]
st = dc(lambda: 0)
for n in range(y):
a, b = map(int, input().split())
if a > b:
a, b = b, a
graph[a].append(b)
graph[b].append(a)
res = 0
vis = dc(lambda: 0)
def dfs(node):
glo... | Traceback (most recent call last):
File "/tmp/tmpth1rqjoq/tmp2zhkzctc.py", line 2, in <module>
x, y = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s638791579 | p02573 | u933929042 | 1598732428 | Python | PyPy3 (7.3.0) | py | Runtime Error | 802 | 139624 | 1613 | import random
import sys
sys.setrecursionlimit(100000)
n, m = map(int, input().split())
# n, m = 200000, 200000
group = {i: 0 for i in range(1, n+1)}
edge = {}
g_mem = {}
g_num = 0
g_con = set()
for i in range(m):
a, b = map(int, input().split())
# a, b = random.sample(range(1,n+1), 2)
if group[a]==0 and... | Traceback (most recent call last):
File "/tmp/tmp0g_nj783/tmpdglu7bqo.py", line 6, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s689402989 | p02573 | u868600519 | 1598732420 | Python | PyPy3 (7.3.0) | py | Runtime Error | 536 | 123144 | 669 | from collections import defaultdict, deque
N, M = map(int, input().split())
D = defaultdict(deque)
R = [0] * (N+1)
for _ in range(M):
a, b = map(int, input().split())
if R[a] != 0:
if R[b] != 0:
aa, bb = R[a], R[b]
if aa == bb:
pass
else:
if len(D[aa]) < len(D[bb]):
... | Traceback (most recent call last):
File "/tmp/tmp5bd17s48/tmpvlg5ue6e.py", line 3, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s441128579 | p02573 | u790812284 | 1598732410 | Python | Python (3.8.2) | py | Runtime Error | 2226 | 335504 | 363 | import sys
import numpy as np
N, M = map(int, input().split())
if M==0:
print(1)
sys.exit()
friends_map = np.zeros(shape=(N, N))
for _ in range(M):
A_i, B_i = map(int, input().split())
friends_map[A_i-1][B_i-1] = 1
friends_map[B_i-1][A_i-1] = 1
ans = 0
for row in friends_map:
ans ... | Traceback (most recent call last):
File "/tmp/tmpfat1fg8d/tmpk_mah8o4.py", line 4, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s613618929 | p02573 | u349724238 | 1598732409 | Python | PyPy3 (7.3.0) | py | Runtime Error | 592 | 120872 | 339 | N,M = map(int,input().split())
d = {}
for i in range(1,N+1):
d[i] = []
for i in range(M):
A,B = map(int,input().split())
d[A].append(B)
d[B].append(A)
ans = 0
m = 0
for a in range(1,N+1):
b = len(set(d[a]))
if b > ans:
ans = b
m = a
P = d[m]
H = P.copy()
for a in P:
H += d[a]... | Traceback (most recent call last):
File "/tmp/tmp6ghwtamo/tmpoy2vdmt1.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s055539444 | p02573 | u572026348 | 1598732407 | Python | Python (3.8.2) | py | Runtime Error | 759 | 335472 | 358 | import numpy as np
def main():
n, m = map(int, input().split())
friends_mat = np.zeros((n, n))
for i in range(m):
a, b = map(int, input().split())
friends_mat[a - 1][b - 1] = 1
friends_mat[b - 1][a - 1] = 1
print(int(max(friends_mat.sum(axis=1))+1))
# print(friends_mat)
... | Traceback (most recent call last):
File "/tmp/tmp3cdsxupu/tmpuo9vfwe6.py", line 17, in <module>
main()
File "/tmp/tmp3cdsxupu/tmpuo9vfwe6.py", line 4, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s943808383 | p02573 | u003926785 | 1598732406 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 171076 | 562 | N, M = map(int, input().split())
l = []
A, B = map(int, input().split())
l.append((A, B))
for i in range(M-1):
A, B = map(int, input().split())
hit = None
for tup in l:
if A in tup or B in tup:
if hit != None:
hit += tuple(set(tup+(A, B)))
hit
... | Traceback (most recent call last):
File "/tmp/tmpaczahroc/tmpl64swec2.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s562798187 | p02573 | u534610124 | 1598732402 | Python | Python (3.8.2) | py | Runtime Error | 2213 | 132036 | 556 | N,M = map(int, input().split())
dic = dict((i, set()) for i in range(1,N+1))
print(dic)
for _ in range(M):
a,b = map(int, input().split())
dic[a].add(b)
dic[b].add(a)
#print(dic)
def dfs(x:int, marked:set):
a = set()
a = a.union(dic[x])
marked.add(x)
for i in dic[x]:
if i not i... | Traceback (most recent call last):
File "/tmp/tmp4mbvz0ky/tmpxjqo21oj.py", line 1, in <module>
N,M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s388421109 | p02573 | u194585018 | 1598732395 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 43984 | 477 | def packrel(s: str):
x, y = map(int, s.split())
if (x < y):
return (x, y)
else:
return (y, x)
N, M = map(int, input().split())
rels = list({packrel(input()) for i in range(M)})
unions = []
for a, b in rels:
for u in unions:
if a in u:
u.add(b)
break
... | Traceback (most recent call last):
File "/tmp/tmplozlx141/tmpuyvf48dl.py", line 9, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s706773624 | p02573 | u880400515 | 1598732389 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2343 | 3529036 | 1073 | N, M = list(map(int, input().split()))
G = [[0]*N for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
G[a - 1][b - 1] = 1
G[b - 1][a - 1] = 1
friend_chain = []
checked = [False]*N
for i in range(N):
if (checked[i] == True):
for a, chain_i in enumerate(friend_chain)... | Traceback (most recent call last):
File "/tmp/tmpuv6kdjkm/tmp5idiupj2.py", line 1, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s498123019 | p02573 | u581022379 | 1598732386 | Python | Python (3.8.2) | py | Runtime Error | 444 | 18892 | 1076 | from collections import Counter
N, M = map(int, input().split())
groups = [0] * (N + 1)
group_num_list = [[0]]
group_num = 1
for _ in range(M):
A, B = map(int, input().split())
if groups[A] != 0 and groups[B] != 0:
if groups[A] != groups[B]:
lower = min(groups[A], groups[B])
high... | Traceback (most recent call last):
File "/tmp/tmpm4i149v7/tmpba6urtpt.py", line 2, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s211664851 | p02573 | u719840207 | 1598732360 | Python | Python (3.8.2) | py | Runtime Error | 2273 | 2696036 | 298 | n,m = map(int,input().split())
s= [[0] * n for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
s[a-1][b-1]=1
s[b-1][a-1]=1
ss = np.array(s)
group, labels = connected_components(ss)
import collections
retsu = collections.Counter(labels)
rkosuu=retsu.most_common()[0][1] | Traceback (most recent call last):
File "/tmp/tmpsa5x8qhd/tmpt9hkg3lu.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s850871250 | p02573 | u878389297 | 1598732359 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2212 | 196020 | 554 | import collections
a=input()
a=a.split()
n=int(a[0])
m=int(a[1])
l=[0]*(n)
k=1
for i in range(m):
x=input()
x=x.split()
xa=int(x[0])-1
xb=int(x[1])-1
if l[xa]==0 and l[xb]==0:
l[xa]=k
l[xb]=k
k+=1
if l[xa]==0 and l[xb]!=0:
l[xa]=l[xb]
if l[xa]!=0 and l[xb]==0:... | Traceback (most recent call last):
File "/tmp/tmpdkt2_rcd/tmpvtgslgqg.py", line 2, in <module>
a=input()
^^^^^^^
EOFError: EOF when reading a line
| |
s863428563 | p02573 | u166366686 | 1598732351 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 93196 | 800 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 一番多いグループが何人か調べる
from statistics import mode
import collections
N, M = map(int, input().split())
team = [0 for i in range(N+1)]
ans = 0
for i in range(1,M+1):
A, B = map(int, input().split())
if team[A] != 0 or team[B] != 0:
for j in range(1,N+1):
... | Traceback (most recent call last):
File "/tmp/tmph3kr8jic/tmpkelg_k2v.py", line 7, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s869940929 | p02573 | u134185377 | 1598732349 | Python | Python (3.8.2) | py | Runtime Error | 2237 | 143404 | 672 | from collections import defaultdict
import numpy as np
import copy
N,M=map(int,input().split())
friend=defaultdict(list)
for _ in range(M):
a,b=map(int,input().split())
friend[a].append(b)
friend[b].append(a)
friend2={i:list(set(j)) for i,j in friend.items()}
print(friend2)
for i,j in friend.items():
j=... | Traceback (most recent call last):
File "/tmp/tmpj1orbi3o/tmpjz20g7fx.py", line 4, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s289883902 | p02573 | u850087201 | 1598732347 | Python | Python (3.8.2) | py | Runtime Error | 724 | 47184 | 983 | import copy
(N,M) = map(int,input().split())
l = []
if M == 0:
print(1)
else:
for i in range(M):
l.append([int(x) for x in input().split()])
mn = 0
for i in range(M):
for j in range(2):
mn = max(mn,l[i][j])
s = [0 for i in range(mn+100)]
k = [0 for i in range(M)]
... | Traceback (most recent call last):
File "/tmp/tmpxiopvbcd/tmpm3gwrrq2.py", line 2, in <module>
(N,M) = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s242141842 | p02573 | u491296898 | 1598732345 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 69208 | 714 | from collections import defaultdict, deque
n,m = list(map(int, input().split()))
d = defaultdict(list)
for _ in range(m):
a,b = list(map(int, input().split()))
d[a].append(b)
d[b].append(a)
def dfs(node):
s = set()
stack = deque([node])
while stack:
n = stac... | Traceback (most recent call last):
File "/tmp/tmpi3g4bqbn/tmpznaj0d4m.py", line 2, in <module>
n,m = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s807149248 | p02573 | u882323840 | 1598732329 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2242 | 1046732 | 439 | 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())
C = [set()]
C[0].add(A[0])
C[0].add(B[0])
for i in range(1,M):
for j in range(len(C)):
if A[i] in C[j] or B[i] in C[j]:
C[j].add(A[i])
C[j].add(B[i])
else:
... | Traceback (most recent call last):
File "/tmp/tmp0fupwbpj/tmpj7ebpchl.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s013047979 | p02573 | u908763441 | 1598732328 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 73776 | 888 | from collections import Counter
n, m = map(int, input().split())
index = 1
group = [0] * (n + 1) # 何番目のグループにいるか
for i in range(m):
a, b = map(int, input().split())
_a = group[a]
_b = group[b]
if _a == 0 and _b == 0: # 新しいグループ
group[a] = index
group[b] = index
index += 1
elif _a == 0: # aが新人
gr... | Traceback (most recent call last):
File "/tmp/tmp9c8fb8gt/tmp_keorgmy.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s080551250 | p02573 | u427819770 | 1598732317 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 36340 | 561 | N, M = map(int, input().split())
if M == 0:
print(1)
else:
ans = {}
for i in range(M):
A, B = map(int, input().split())
if i == 0:
ans[i] = {A, B}
else:
flag = 1
for k, v in ans.items():
if A in v or B in v:
ans[... | Traceback (most recent call last):
File "/tmp/tmp6gt_na5i/tmpvf5ijnz_.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s604344579 | p02573 | u432621419 | 1598732312 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9052 | 893 | ##この問題はグループの最大人数を求めれば良い
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(m)]
#print(a[0][1])
l = [n+1]*n
# lで何のグループに属しているか判定する
p = [1]*n
# lでどのグループがどのくらいのpowerを持っているか判定する
##最終的にlがn+1でない中で,pが一番大きいのを解答に出す
##ただ,これでは更新頻度がえぐいため工夫がいる.
for j in range(m):
if(l[a[j][0]] == n+1 & l[a[j... | File "/tmp/tmpyqexq4kj/tmpp80okg5w.py", line 32
###give up
IndentationError: expected an indented block after 'if' statement on line 30
| |
s535015553 | p02573 | u412255932 | 1598732307 | Python | PyPy3 (7.3.0) | py | Runtime Error | 732 | 202876 | 562 | from collections import defaultdict
def dfs(node, parent):
if node in visited:
return 0
visited.add(node)
count = 1
for neighbor in adj_list[node]:
if neighbor != parent:
count += dfs(neighbor, node)
return count
N, M = map(int, input().split())
A, B = [], []
adj_list... | Traceback (most recent call last):
File "/tmp/tmpkx8r2475/tmpea42xkfc.py", line 13, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s276463535 | p02573 | u728200259 | 1598732292 | Python | Python (3.8.2) | py | Runtime Error | 2236 | 781976 | 348 | N, M = map(int, input().split())
import networkx as nx
g = nx.Graph()
g_list = []
for i in range(M):
b, c = map(int, input().split())
g_list.append(b)
g.add_edges_from([(b,c)])
result = 1
for n in g_list:
tmp = len(nx.single_source_shortest_path(g, n).keys())
if result < tmp:
... | Traceback (most recent call last):
File "/tmp/tmpgnvp0ifw/tmpok8zi_er.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s176298292 | p02573 | u933929042 | 1598732237 | Python | PyPy3 (7.3.0) | py | Runtime Error | 822 | 177888 | 1542 | import random
import sys
sys.setrecursionlimit(100000)
n, m = map(int, input().split())
# n, m = 200000, 200000
group = {i: 0 for i in range(1, n+1)}
edge = {}
g_mem = {}
g_num = 0
g_con = set()
for i in range(m):
a, b = map(int, input().split())
# a, b = random.sample(range(1,n+1), 2)
if group[a]==0 and... | Traceback (most recent call last):
File "/tmp/tmpyf3mae8r/tmphfdp1x6u.py", line 6, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s991714697 | p02573 | u000623733 | 1598732234 | Python | PyPy3 (7.3.0) | py | Runtime Error | 286 | 90808 | 1589 | N, M = map(int, input().split())
members = [-1] * N
group_count = 0
groups = [0] * N
group_dict = {}
for m in range(M):
A, B = map(int, input().split())
A = A - 1
B = B - 1
if members[A]==-1 and members[B]==-1:
members[A] = members[B] = group_count
groups[group_count] = 2
group... | Traceback (most recent call last):
File "/tmp/tmp6vxopbl2/tmpqd9k21sq.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s935496212 | p02573 | u458925609 | 1598732230 | Python | Python (3.8.2) | py | Runtime Error | 1010 | 59472 | 446 | N, M = list(map(int, input().split()))
d = {i: [] for i in range(1, N + 1)}
for _ in range(M):
a, b = list(map(int, input().split()))
d[a].append(b)
d[b].append(a)
visited = [False for _ in range(N + 1)]
def visit(x):
if visited[x]:
return 0
visited[x] = True
z = 1
for y in d[x]... | Traceback (most recent call last):
File "/tmp/tmpmb8ztfxk/tmpjb9ijtw5.py", line 1, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s050673111 | p02573 | u226849101 | 1598732227 | Python | Python (3.8.2) | py | Runtime Error | 1102 | 48480 | 606 | N,M = map(int,input().split())
E_list = [[]for i in range(N)]
marks = [False for i in range(N)]
def dfs(n):
global E_list
global marks
global N,M
marks[n] = True
steps = 1
for nx in E_list[n]:
if not marks[nx]:
marks[nx] = True
steps += dfs(nx)
retu... | Traceback (most recent call last):
File "/tmp/tmp8pkb49wo/tmp1kqiebwh.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s974375976 | p02573 | u869567753 | 1598732217 | Python | Python (3.8.2) | py | Runtime Error | 340 | 47156 | 557 | import sys
readline = sys.stdin.readline
N, M = map(int, readline().split())
G = {}
for i in range(M):
ai, bi = map(int, readline().split())
if ai in G:
if type(G[ai]) is int:
G[G[ai]].add(bi)
G[bi] = G[ai]
else:
G[ai].add(bi)
G[bi] = ai
elif bi in G:
if type(G[bi]) is int:
... | Traceback (most recent call last):
File "/tmp/tmp9o40ya9n/tmp2ytnt3t5.py", line 4, in <module>
N, M = map(int, readline().split())
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s445962668 | p02573 | u581022379 | 1598732199 | Python | Python (3.8.2) | py | Runtime Error | 449 | 19836 | 1104 | import collections
N, M = map(int, input().split())
groups = [0] * (N + 1)
group_num_list = [[0]]
group_num = 1
for _ in range(M):
A, B = map(int, input().split())
if groups[A] != 0 and groups[B] != 0:
if groups[A] != groups[B]:
group_num -= 1
lower = min(groups[A], groups[B])
... | Traceback (most recent call last):
File "/tmp/tmpa2ay1ub1/tmpjv90yhto.py", line 2, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s877853410 | p02573 | u743383679 | 1598732196 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 45716 | 827 | n, m = list(map(int, input().split()))
am = []
bm = []
for _ in range(m):
a, b = list(map(int, input().split()))
am.append(a)
bm.append(b)
groups = []
for ai, bi in zip(am, bm):
ag = None
bg = None
for g, group in enumerate(groups):
if ai in group:
ag = g
if bi in gr... | Traceback (most recent call last):
File "/tmp/tmp_6d1ojh4/tmpdejygbe7.py", line 1, in <module>
n, m = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s509849890 | p02573 | u137226361 | 1598732187 | Python | Python (3.8.2) | py | Runtime Error | 31 | 8864 | 815 | import sys
def main():
stdin = sys.stdin
n, m = map(int, stdin.readline().split())
par = [i for i in range(i)]
size = [1] * n
rank = [1] * n
def find(x, par):
if par[x] == x:
return x
else:
return find(par[x], par)
def unite(x, y):
x = find... | File "/tmp/tmp4i5x3pnv/tmplzh1caj6.py", line 39
if __name__ == '__main__':
IndentationError: expected an indented block after 'if' statement on line 39
| |
s277777346 | p02573 | u291028869 | 1598732168 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2339 | 3528388 | 227 | n,m = map(int,input().split())
A = [[0]*n for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
A[a-1][b-1] = 1
A[b-1][a-1] = 1
ans = [0]*n
for i in range(n):
ans[i] = sum(A[i])
print(max(ans)+1) | Traceback (most recent call last):
File "/tmp/tmp48jnnikt/tmptvwdnf9j.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s527012185 | p02573 | u002765126 | 1598732165 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2383 | 3522968 | 766 | import queue
n, m = map(int,input().split())
A=[]
B=[]
conne = [[0]*n for _ in range(n)]
visited = [0]*n
for i in range(m):
a,b=map(int,input().split())
A.append(a)
B.append(b)
conne[a-1][b-1]=1
conne[b-1][a-1]=1
ans=0
for i in range(n):
d=1
count=0
if visited[i]==0:
visit... | Traceback (most recent call last):
File "/tmp/tmpvttgt0n1/tmpwarc3nb7.py", line 2, in <module>
n, m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s816250590 | p02573 | u728200259 | 1598732160 | Python | Python (3.8.2) | py | Runtime Error | 2228 | 796492 | 422 | N, M = map(int, input().split())
import networkx as nx
g = nx.Graph()
g_list = []
for i in range(M):
b, c = map(int, input().split())
g_list.append(b)
g.add_edges_from([(b,c)])
result = 1
for n in g_list:
if n not in g_list:
continue
node_n = n+1
tmp = len(nx.single... | Traceback (most recent call last):
File "/tmp/tmp_a0o6cgt/tmp69a7845t.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s760636120 | p02573 | u170839742 | 1598732139 | Python | Python (3.8.2) | py | Runtime Error | 628 | 19024 | 402 | N, M = map(int, input().split())
parent = [-1] * N
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
parent[x] = y
def find(x):
if parent[x] == -1:
return x
res = parent[x] = find(parent[x])
return res
for _ in range(M):
a, b = map(int, input().split())
... | Traceback (most recent call last):
File "/tmp/tmp9lovz_a5/tmpvl4nvzcg.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s611279507 | p02573 | u408262366 | 1598732137 | Python | PyPy3 (7.3.0) | py | Runtime Error | 90 | 70244 | 701 | import collections
n,m = map(int, input().split())
friends = [0] * n
query = []
for i in range(m):
a,b = map(int, input().split())
if friends[a - 1] == 0 and friends[b - 1] == 0:
friends[a - 1] = tmp
friends[b - 1] = tmp
tmp += 1
elif friends[a - 1] == 0:
friends[a - 1] = friends[b - 1]
elif ... | Traceback (most recent call last):
File "/tmp/tmpiw7zt7es/tmpbu4wvvcx.py", line 2, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s968375264 | p02573 | u137226361 | 1598732116 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9192 | 837 | import sys
def main():
stdin = sys.stdin
n, m = map(int, stdin.readline().split())
par = [i for i in range(i)]
size = [1] * n
rank = [1] * n
def find(x, par):
if par[x] == x:
return x
else:
return find(par[x], par)
def unite(x, y):
x = find... | Traceback (most recent call last):
File "/tmp/tmpjxbmx5ri/tmpd628sdp_.py", line 40, in <module>
main()
File "/tmp/tmpjxbmx5ri/tmpd628sdp_.py", line 5, in main
n, m = map(int, stdin.readline().split())
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s387243590 | p02573 | u347502437 | 1598732086 | Python | Python (3.8.2) | py | Runtime Error | 665 | 56528 | 533 | N, M = map(int, input().split())
info = []
count = 0
people = set()
friends = []
while count < M:
A, B = map(int,input().split())
info += [[A,B]]
people.union({A,B})
if A in people and B not in people:
for f in friends:
if A in f:
f += [B]
elif B in people and A n... | Traceback (most recent call last):
File "/tmp/tmpyrsne9l_/tmpe113vw2a.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s873586854 | p02573 | u077296371 | 1598732084 | Python | Python (3.8.2) | py | Runtime Error | 1150 | 294728 | 15483 | # ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10**8)
mod... | Exception in thread Thread-1 (main):
Traceback (most recent call last):
File "/root/miniconda3/envs/sandbox-runtime/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
self.run()
File "/root/miniconda3/envs/sandbox-runtime/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **s... | |
s897227618 | p02573 | u226849101 | 1598732083 | Python | Python (3.8.2) | py | Runtime Error | 1239 | 84180 | 656 | N,M = map(int,input().split())
E = [[0,0]for i in range(M)]
E_list = [[]for i in range(N)]
marks = [False for i in range(N)]
def dfs(n):
global E_list
global marks
global N,M
marks[n] = True
steps = 1
for nx in E_list[n]:
if not marks[nx]:
marks[nx] = True
st... | Traceback (most recent call last):
File "/tmp/tmp4o9xdyhy/tmp675juduk.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s035522731 | p02573 | u539639881 | 1598732079 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 74768 | 645 | import numpy as np
import scipy.stats as stats
n, m = map(int, input().split())
table = [[False] * n for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
table[a-1][b-1] = True
table[b-1][a-1] = True
group = [i for i in range(n)]
update = [True] * n
needUpdate = True
while(needUpdate):
next... | Traceback (most recent call last):
File "/tmp/tmpihn63d1y/tmpfwqz3zxl.py", line 3, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s252254859 | p02573 | u295585689 | 1598732068 | Python | Python (3.8.2) | py | Runtime Error | 631 | 69792 | 733 | N,M = [int(i) for i in input().split()]
relations = []
for i in range(M):
relations.append({int(i) for i in input().split()})
def search(node,stock):
n_member = 0
while(len(node)>0):
n_member += len(node)
go_list = []
ng_list = []
for s in stock:
... | Traceback (most recent call last):
File "/tmp/tmpsc5g0k1w/tmpjkxsto4s.py", line 1, in <module>
N,M = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s184126483 | p02573 | u959682393 | 1598732066 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 24328 | 497 | N,M = map(int,input().split())
ans = [[] for i in range(N)]
a,b = map(int,input().split())
ans[0].append(a)
ans[0].append(b)
for i in range(M-1):
a,b = map(int,input().split())
for j in ans:
if len(j) == 0:
j.append(a)
j.append(b)
break
if a in ... | Traceback (most recent call last):
File "/tmp/tmpz8c9y5jt/tmp4hw0iwuk.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s719548817 | p02573 | u188305619 | 1598732063 | Python | Python (3.8.2) | py | Runtime Error | 2215 | 284412 | 601 | N, M = map(int,input().split())
friend_list = [list(map(int,input().split()))]
for i in [0] * (M - 1):
A,B = map(int,input().split())
for j in range(len(friend_list)):
if friend_list[j].count(A) == 1:
if friend_list[j].count(B) == 0:
friend_list[j].append(B)
elif fri... | Traceback (most recent call last):
File "/tmp/tmp4e89w0qj/tmpyclk7uat.py", line 1, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s653258592 | p02573 | u170839742 | 1598732061 | Python | Python (3.8.2) | py | Runtime Error | 675 | 18976 | 498 | N, M = map(int, input().split())
parent = [-1] * N
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
parent[x] = y
def find(x):
if parent[x] == -1:
return x
res = parent[x] = find(parent[x])
return res
for _ in range(M):
a, b = map(int, input().split())
... | Traceback (most recent call last):
File "/tmp/tmp6yji4a55/tmpfvylyw5g.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s027490119 | p02573 | u641851773 | 1598732051 | Python | Python (3.8.2) | py | Runtime Error | 1670 | 120900 | 1631 | #!/usr/bin/env python3
import sys
from collections import namedtuple
DEBUG = False
def read(t):
return t(sys.stdin.readline().rstrip())
def read_list(t, sep=" "):
return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]
def dprint(*args, **kwargs):
if DEBUG:
print(*args, **kwargs)
... | Traceback (most recent call last):
File "/tmp/tmp_nf4qzr4/tmp0z8jgzf4.py", line 80, in <module>
main()
File "/tmp/tmp_nf4qzr4/tmp0z8jgzf4.py", line 62, in main
_n, m = read_list(int)
^^^^^^^^^^^^^^
File "/tmp/tmp_nf4qzr4/tmp0z8jgzf4.py", line 14, in read_list
return [t(s) for s in sys.stdi... | |
s239359889 | p02573 | u710515311 | 1598732045 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 100884 | 463 | def solve():
N, M = [int(i) for i in input().split()]
R = []
for _ in range(M):
A, B = [int(i) for i in input().split()]
f = False
if (len(R) > 0):
for r in R:
if A in r or B in r:
f = True
r.add(A)
... | Traceback (most recent call last):
File "/tmp/tmpc4x6spmg/tmp63h9mpm2.py", line 19, in <module>
solve()
File "/tmp/tmpc4x6spmg/tmp63h9mpm2.py", line 2, in solve
N, M = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s032581958 | p02573 | u745685739 | 1598732031 | Python | Python (3.8.2) | py | Runtime Error | 736 | 25564 | 439 |
def solve():
n,m=map(int,input().split()[0:2])
fa=list(range(0,n+1))
sz=[1]*(n+1)
def gf(x) :
if x==fa[x] :
return x
fa[x]=gf(fa[x])
return fa[x]
for i in range(m) :
a,b=map(gf,map(int,input().split()[0:2]))
if a!=b :
fa[a]=b
... | Traceback (most recent call last):
File "/tmp/tmpls_ym747/tmpc6op3d6u.py", line 24, in <module>
print(solve())
^^^^^^^
File "/tmp/tmpls_ym747/tmpc6op3d6u.py", line 3, in solve
n,m=map(int,input().split()[0:2])
^^^^^^^
EOFError: EOF when reading a line
| |
s248211565 | p02573 | u246907970 | 1598732012 | Python | Python (3.8.2) | py | Runtime Error | 2209 | 87760 | 542 | ininfo = input().split(" ")
num = int(ininfo[0])
m = int(ininfo[1])
list=[]
for i in range(m):
list.append(input().split(" "))
list[i].sort()
list.sort()
anslist=[]
s={list[0][0],list[0][1]}
anslist.append(s)
for i in list:
match=0
for j in anslist:
if i[0] in j and i[1] in j:
match=1
break
... | Traceback (most recent call last):
File "/tmp/tmp6828ym67/tmpo12ezdk5.py", line 1, in <module>
ininfo = input().split(" ")
^^^^^^^
EOFError: EOF when reading a line
| |
s757035851 | p02573 | u170839742 | 1598731985 | Python | Python (3.8.2) | py | Runtime Error | 713 | 19000 | 488 | N, M = map(int, input().split())
parent = [-1] * N
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
parent[x] = y
def find(x):
if parent[x] == -1:
return x
res = parent[x] = find(parent[x])
return res
for _ in range(M):
a, b = map(int, input().split())
... | Traceback (most recent call last):
File "/tmp/tmppqlo8hin/tmpv7ist512.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s033007015 | p02573 | u310381103 | 1598731984 | Python | Python (3.8.2) | py | Runtime Error | 1498 | 261808 | 244 | n,m=map(int,input().split())
ab = [map(int, sorted(input().split())) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]
ans=[set(str(i)) for i in range(1,n+1)]
for i in range(m):
ans[a[i]-1].add(str(b[i]))
print(max([len(x) for x in ans])) | Traceback (most recent call last):
File "/tmp/tmpuoawvxph/tmp2x7r7xyz.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s162718856 | p02573 | u748311048 | 1598731982 | Python | Python (3.8.2) | py | Runtime Error | 552 | 14088 | 693 | from collections import Counter
import collections
n, m = map(int, input().split())
koseki = [-1 for _ in range(n)] # -1
group = []
mouyatta = Counter()
for i in range(m):
a, b = map(int, input().split())
# if mouyatta[tuple(sorted([a,b]))]==0:
# mouyatta[tuple(sorted([a,b]))]+=1
if koseki[a-1] == kose... | Traceback (most recent call last):
File "/tmp/tmpwwc15drg/tmpk3zfvwja.py", line 3, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s877899097 | p02573 | u000623733 | 1598731968 | Python | PyPy3 (7.3.0) | py | Runtime Error | 91 | 74780 | 1174 | import numpy as np
N, M = map(int, input().split())
members = np.array([-1] * N).astype(np.int)
group_count = 0
groups = [0] * N
group_dict = {}
for m in range(M):
A, B = map(int, input().split())
A = A - 1
B = B - 1
if members[A]==-1 and members[B]==-1:
members[A] = members[B] = group_count
... | Traceback (most recent call last):
File "/tmp/tmp4szqw5ky/tmp24995z2r.py", line 3, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s334849136 | p02573 | u623283955 | 1598731956 | Python | Python (3.8.2) | py | Runtime Error | 538 | 29628 | 452 | n,m=map(int,input().split())
p=[(i,1)for i in range(n)]
def find(i):
if p[i][0]==i:return i
else:
c=find(p[i])
p[i]=(c,0)
return c
def union(i,j):
pi=find(i)
pj=find(j)
if not pi==pj:
if p[pi][1]>p[pj][1]:
p[pj]=(pi,p[pi][1]+p[pj][1])
else:
p[pi]=(pj,p[pi][1]+p[pj][1])
for i i... | Traceback (most recent call last):
File "/tmp/tmp28m19vd9/tmpdu487hui.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s608893622 | p02573 | u678128840 | 1598731956 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9344 | 610 | baseData = [int(i) for i in input().split(" ")]
N = baseData[0]
M = baseData[1]
group = []
flg = False
for i in range(M):
temp = [int(j) for j in input().split(" ")]
temp.sort()
if i == 0:
group.append(temp)
else:
for j in range(len(group)):
if temp[0] in group[j]:
... | Traceback (most recent call last):
File "/tmp/tmpeojhmoxx/tmpwqp6xb2i.py", line 1, in <module>
baseData = [int(i) for i in 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.