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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s403668972 | p02536 | u352198227 | 1601172600 | Python | Python (3.8.2) | py | Runtime Error | 232 | 24824 | 725 | a = list(map(int,input().split()))
N = a[0]
M = a[1]
cities = [0] * N
roads = []
lands = {}
for i in range(M):
a = list(map(int,input().split()))
roads.append([a[0], a[1]])
for r in roads:
if cities[r[0]-1] == 0:
cities[r[0]-1] = r[0]
lands[r[0]-1] = [r[0]]
if cities[r[1]-1] == ... | Traceback (most recent call last):
File "/tmp/tmpl7_3ibah/tmpqholhyb_.py", line 1, in <module>
a = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s993956050 | p02536 | u865383026 | 1601172560 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 48660 | 569 | def Search(n):
L[n-1] = 1
for i in R[n]:
if L[i-1] == 0:
Search(i)
N, M = map(int, input().split())
L = [1] * N
R = {}
ans = -1
for i in range(M):
A, B = map(int, input().split())
if A not in R:
R[A] = set()
if B not in R:
R[B] = set()
R[A].add(B)
R[B].add(A)
L[A-1] = 0
L[B-1] = 0
f... | Traceback (most recent call last):
File "/tmp/tmprd4pqo3x/tmp7qsv4ok1.py", line 7, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s747766121 | p02536 | u480139706 | 1601172540 | Python | Python (3.8.2) | py | Runtime Error | 2216 | 189468 | 825 | import numpy as np
def main():
n_num, m_num = map(int, input().split())
road = np.zeros((n_num, n_num), dtype='int32')
for _ in range(m_num):
a, b = map(int, input().split())
if a > b:
a, b = b, a
road[a-1][b-1] = 1
city_info = np.zeros(n_num, dtype='int32')
la... | Traceback (most recent call last):
File "/tmp/tmpsdpp59p2/tmpcagqzwep.py", line 40, in <module>
main()
File "/tmp/tmpsdpp59p2/tmpcagqzwep.py", line 4, in main
n_num, m_num = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s406240188 | p02536 | u252828980 | 1601172534 | Python | Python (3.8.2) | py | Runtime Error | 260 | 17244 | 1902 | n,m = map(int,input().split())
#L = [list(map(int,input().split())) for i in range(m)]
class UnionFind:
def __init__(self, n):
self.n = n
self.parent = [i for i in range(n)] # 親
self.rank = [1] * n # 木の高さ
self.size = [1] * n # size[i] は i を根とするグループのサイズ
def find(self, x): #... | Traceback (most recent call last):
File "/tmp/tmpze0eoqo4/tmprii_zf9c.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s460845019 | p02536 | u653026173 | 1601172509 | Python | Python (3.8.2) | py | Runtime Error | 136 | 9660 | 144 | n,m = map(int, input().split())
cnt = [1]*n
for i in range(m):
a,b = map(int, input().split())
cnt[a] = 0
cnt[b] = 0
print(sum(cnt)) | Traceback (most recent call last):
File "/tmp/tmpyiw8q7hs/tmpql0mnr22.py", line 1, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s185640489 | p02536 | u844872527 | 1601172477 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 13484 | 994 |
def MII(): return map(int, input().split())
def MSI(): return map(str, input().split())
n,m=MII()
groups=[["1"]]
group_set=set(["1"])
for i in range(m):
a,b=MSI()
a_place=0
b_place=0
tmp=[]
if a in group_set:
if b in group_set:
for j in range(len(groups)):
if a... | Traceback (most recent call last):
File "/tmp/tmpj37egr5b/tmp47_tj6t4.py", line 5, in <module>
n,m=MII()
^^^^^
File "/tmp/tmpj37egr5b/tmp47_tj6t4.py", line 2, in MII
def MII(): return map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s848296488 | p02536 | u177370876 | 1601172381 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9136 | 1312 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | File "/tmp/tmppb_bomis/tmpcgs3k7td.py", line 52
uf.union(a−1, b−1)
^
SyntaxError: invalid character '−' (U+2212)
| |
s240370526 | p02536 | u483721532 | 1601172379 | Python | Python (3.8.2) | py | Runtime Error | 153 | 18352 | 173 | N, M = map(int, input().split())
n = list(i+1 for i in range(N))
for _ in range(M):
A, B = map(int, input().split())
n[A] = 0
n[B] = 0
n = set(n)
print(len(n)-1) | Traceback (most recent call last):
File "/tmp/tmp849enb77/tmpnjgs1_5c.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s426671370 | p02536 | u903082918 | 1601172351 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 15624 | 1892 | """ C
"""
import sys
import math
from functools import reduce
from bisect import bisect_left
def readString():
return sys.stdin.readline()
def readInteger():
return int(readString())
def readStringSet(n):
return sys.stdin.readline().split(" ")[:n]
def readIntegerSet(n):
return list(map(int, readStri... | Traceback (most recent call last):
File "/tmp/tmp3x7yjskk/tmpl_60n__j.py", line 70, in <module>
_N, _M = readIntegerSet(2)
^^^^^^^^^^^^^^^^^
File "/tmp/tmp3x7yjskk/tmpl_60n__j.py", line 18, in readIntegerSet
return list(map(int, readStringSet(n)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Val... | |
s037178848 | p02536 | u553605501 | 1601172336 | Python | PyPy3 (7.3.0) | py | Runtime Error | 315 | 85492 | 1381 | n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
a_,b_=map(int,input().split())
a.append(a_)
b.append(b_)
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/tmpi89p0q46/tmpih3poxd0.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s552291307 | p02536 | u177370876 | 1601172314 | Python | Python (3.8.2) | py | Runtime Error | 205 | 12768 | 1304 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | Traceback (most recent call last):
File "/tmp/tmp3576hgsb/tmpw_s3kv_s.py", line 48, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s934110333 | p02536 | u881675205 | 1601172310 | Python | PyPy3 (7.3.0) | py | Runtime Error | 340 | 89156 | 562 | def s(way):
global w
w2 =[]
for i in way:
for j in w[i]:
if c[j] == 0:
w2.append(i)
if not w2 ==[]:
s(w2)
c[i] = 1
n,m = map(int,input().split())
a = [0 for i in range(m)]
b = [0 for i in range(m)]
w = [[] for i in range(n)]
c = [0 f... | Traceback (most recent call last):
File "/tmp/tmpml2di2pg/tmp_meawdov.py", line 14, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s183341046 | p02536 | u517682687 | 1601172309 | Python | Python (3.8.2) | py | Runtime Error | 268 | 24928 | 1439 | class DSU:
def __init__(self, n):
self._n = n
self.parent_or_size = [-1] * n
def merge(self, a, b):
assert 0 <= a < self._n
assert 0 <= b < self._n
x, y = self.leader(a), self.leader(b)
if x == y: return x
if -self.parent_or_size[x] < -self.parent_or_size... | Traceback (most recent call last):
File "/tmp/tmp3vfdsjgj/tmpa5cam6ib.py", line 37, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s481104373 | p02536 | u881675205 | 1601172281 | Python | PyPy3 (7.3.0) | py | Runtime Error | 352 | 88912 | 562 | def s(way):
global w
w2 =[]
for i in way:
for j in w[i]:
if c[j] == 0:
w2.append(i)
if not w2 ==[]:
s(w2)
c[i] = 1
n,m = map(int,input().split())
a = [0 for i in range(m)]
b = [0 for i in range(m)]
w = [[] for i in range(n)]
c = [0 f... | Traceback (most recent call last):
File "/tmp/tmpih_5ghdm/tmpq97ukf0v.py", line 14, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s160770228 | p02536 | u016843859 | 1601172231 | Python | PyPy3 (7.3.0) | py | Runtime Error | 356 | 116132 | 425 | from collections import defaultdict
N,M=map(int,input().split())
AB=list()
memo=[False]*N
G=defaultdict(list)
def dfs(G,i):
memo[i]=True
for j in G[i]:
if memo[j]==False:
dfs(G,j)
count=0
for i in range(M):
AB=list(map(int,input().split()))
G[AB[1]-1].append(AB[0]-1)
G[AB[0]-1].a... | Traceback (most recent call last):
File "/tmp/tmp_4ypzcj3/tmpujbck4px.py", line 2, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s641643847 | p02536 | u878473776 | 1601172216 | Python | PyPy3 (7.3.0) | py | Runtime Error | 201 | 70952 | 106 | n, m = map(int, input().split())
for i in range(n):
a, b = map(int, input().split())
print(n - m - 1) | Traceback (most recent call last):
File "/tmp/tmpr02bd79c/tmpygc15csf.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s557187769 | p02536 | u473172054 | 1601172204 | Python | Python (3.8.2) | py | Runtime Error | 152 | 18320 | 532 | n, m = map(int, input().split())
par = [i for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
par[b] = par[a]
for i in range(n-1,-1,-1):
flg = True
change_list = []
idx = i
while(flg):
if par[idx] == idx:
flg = False
cur_p = idx
else:... | Traceback (most recent call last):
File "/tmp/tmp44kxyaa4/tmplbl9h4yv.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s678992358 | p02536 | u016843859 | 1601172197 | Python | Python (3.8.2) | py | Runtime Error | 381 | 30904 | 425 | from collections import defaultdict
N,M=map(int,input().split())
AB=list()
memo=[False]*N
G=defaultdict(list)
def dfs(G,i):
memo[i]=True
for j in G[i]:
if memo[j]==False:
dfs(G,j)
count=0
for i in range(M):
AB=list(map(int,input().split()))
G[AB[1]-1].append(AB[0]-1)
G[AB[0]-1].a... | Traceback (most recent call last):
File "/tmp/tmp809eltya/tmpeoh2jpo7.py", line 2, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s901634240 | p02536 | u791728900 | 1601172153 | Python | PyPy2 (7.3.0) | py | Runtime Error | 67 | 64544 | 811 | n, m = map(int, input().split())
towns = [0] * n
cnt = 1
def rewr(x, y, z):
if x == y:
return z
else:
return x
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
if towns[a] == 0 and towns[b] == 0:
towns[a] = cnt
towns[b] = cnt
cnt += 1
... | Traceback (most recent call last):
File "/tmp/tmph2p7r1qn/tmpr0mfa22z.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s626977093 | p02536 | u504256702 | 1601172152 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2340 | 3536464 | 451 | N, M = list(map(int, input().split()))
c = [[0]*N for i in range(N)]
tree = {}
for i in range(M):
a, b = list(map(int, input().split()))
if a not in tree:
for t in tree:
if a in tree[t]:
tree[t].append(b)
else:
tree[a] = [a,b]
break
if len(tree) == 0:
tree[a] = [a... | Traceback (most recent call last):
File "/tmp/tmptbpjdqil/tmp2i5fig7z.py", line 1, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s843067393 | p02536 | u553605501 | 1601172148 | Python | PyPy3 (7.3.0) | py | Runtime Error | 260 | 75312 | 1312 | n,m=map(int,input().split())
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def u... | Traceback (most recent call last):
File "/tmp/tmpaurm02c8/tmpbagaas8b.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s679524304 | p02536 | u883983516 | 1601172112 | Python | Python (3.8.2) | py | Runtime Error | 38 | 17652 | 608 | N, M = [int(x) for x in input().split(' ')]
city_s=set(range(1,N+1))
for j in range(0, M):
A, B = [int(x) for x in input().split(' ')]
if j == 0:
dic={}
dic[0]=[A,B]
if j != 0:
for i in range(len(dic)):
print(i)
if x in dic[i]:
dic[i].append(y... | Traceback (most recent call last):
File "/tmp/tmp18es6jvu/tmpty_y9ma6.py", line 1, in <module>
N, M = [int(x) for x in input().split(' ')]
^^^^^^^
EOFError: EOF when reading a line
| |
s620959184 | p02536 | u881675205 | 1601172102 | Python | PyPy3 (7.3.0) | py | Runtime Error | 90 | 74604 | 7 | 3 1
1 2 | File "/tmp/tmpoq_eal2f/tmpztnbv0v0.py", line 1
3 1
^
SyntaxError: invalid syntax
| |
s306481549 | p02536 | u232202715 | 1601172072 | Python | Python (3.8.2) | py | Runtime Error | 786 | 45364 | 241 | N, M = (int(i) for i in input().split())
AB = [input().split() for i in range(M)]
city = list(str(n) for n in range(1, N+1))
for ab in AB:
city.remove(ab[0])
city.remove(ab[1])
if(len(city) == 0):
break;
print(len(city)) | Traceback (most recent call last):
File "/tmp/tmp34id3luf/tmpo0_vqe9c.py", line 1, in <module>
N, M = (int(i) for i in input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s985655080 | p02536 | u177370876 | 1601172017 | Python | PyPy3 (7.3.0) | py | Runtime Error | 282 | 75204 | 1304 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | Traceback (most recent call last):
File "/tmp/tmpwb6tu_wa/tmpyrcdevm9.py", line 48, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s935662158 | p02536 | u441246928 | 1601171947 | Python | Python (3.8.2) | py | Runtime Error | 462 | 12816 | 164 | N,M = map(int,input().split())
a = list(range(N))
for i in range(M) :
A,B = map(int,input().split())
a.remove(A)
a.remove(B)
print(int(len(a)+M/2))
| Traceback (most recent call last):
File "/tmp/tmpcx8qxnh4/tmph5j36sga.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s484357617 | p02536 | u455809703 | 1601171930 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 16232 | 354 | def inclusive_index(lst, purpose):
for i, e in enumerate(lst):
if purpose in e: return i
raise IndexError
N, M = map(int,input().split())
lst = [str(i+1) for i in range(N)]
for _ in range(M):
A, B = input().split()
a = inclusive_index(lst, A)
b = inclusive_index(lst, B)
lst[a] = lst[... | Traceback (most recent call last):
File "/tmp/tmp6gldikv9/tmpzlcert4g.py", line 7, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s718364554 | p02536 | u077816564 | 1601171923 | Python | Python (3.8.2) | py | Runtime Error | 332 | 26916 | 734 | def dfs(now, prev):
global flag
# 今いる頂点から行ける頂点を順に next に入れてループ
for next in g[now]:
if next != prev:
if memo[next]:
# 過去に訪れていれば閉路
flag = False
else:
memo[next] = True
dfs(next, now)
n, m = map(int, input().split... | Traceback (most recent call last):
File "/tmp/tmpf8jf7rxw/tmper_g6gmr.py", line 14, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s858084969 | p02536 | u172569352 | 1601171892 | Python | Python (3.8.2) | py | Runtime Error | 205 | 42380 | 231 | from scipy.special import comb
N, M = [int(i) for i in input().split()]
AB = []
for i in range(M):
AB[''.join(input().split())] = True
c = 0
for i in range(1, N):
d = False
if str(i)+str(i+1) not in AB:
c += 1
print(c) | Traceback (most recent call last):
File "/tmp/tmpovydyocd/tmpdfssxwmv.py", line 3, in <module>
N, M = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s955515656 | p02536 | u504256702 | 1601171877 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2334 | 3537672 | 421 | N, M = list(map(int, input().split()))
c = [[0]*N for i in range(N)]
tree = {}
for i in range(M):
a, b = list(map(int, input().split()))
if a not in tree:
for t in tree:
if a in tree[t]:
tree[t].append(b)
else:
tree[a] = [a,b]
if len(tree) == 0:
tree[a] = [a,b]
else:
... | Traceback (most recent call last):
File "/tmp/tmpltfnjk9f/tmppljdaajj.py", line 1, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s225920801 | p02536 | u133370097 | 1601171872 | Python | Python (3.8.2) | py | Runtime Error | 1991 | 2161732 | 304 | import numpy as np
number=input().rstrip().split(' ')
N=int(number[0])
M=int(number[1])
judge=np.zeros([N-1,N],dtype=np.int16)
for i in range(M):
cities=input().rstrip().split(' ')
A=int(cities[0])
B=int(cities[1])
judge[A-1][B-1]=1
print(np.count_nonzero(np.all(judge==0,axis=1))) | Traceback (most recent call last):
File "/tmp/tmpc5hrf1vn/tmpit47mcur.py", line 2, in <module>
number=input().rstrip().split(' ')
^^^^^^^
EOFError: EOF when reading a line
| |
s409864517 | p02536 | u441246928 | 1601171872 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9168 | 168 | N,M = map(int,input().split())
a = list(range())
for i in range(N) :
A,B = map(int,input().split())
a.remove(A)
a.remove(B)
print(int(len(a)+M/2))
| Traceback (most recent call last):
File "/tmp/tmpwcde6bzl/tmpu4zvtsin.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s243508969 | p02536 | u532549251 | 1601171867 | Python | Python (3.8.2) | py | Runtime Error | 306 | 28096 | 1598 | #n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
n, m = map(int, input().split())
req = [list(map(int, input().split())) for _ ... | Traceback (most recent call last):
File "/tmp/tmp_72t0rkb/tmphfpkzfns.py", line 9, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s490952981 | p02536 | u077816564 | 1601171823 | Python | Python (3.8.2) | py | Runtime Error | 386 | 28268 | 743 | def dfs(now, prev):
global flag
# 今いる頂点から行ける頂点を順に next に入れてループ
for next in g[now]:
if next != prev:
if memo[next]:
# 過去に訪れていれば閉路
flag = False
else:
memo[next] = True
dfs(next, now)
n, m = map(int, input().split... | Traceback (most recent call last):
File "/tmp/tmpqjq2mqlt/tmps1iae_qn.py", line 14, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s060744745 | p02536 | u327498205 | 1601171805 | Python | Python (3.8.2) | py | Runtime Error | 297 | 28080 | 2213 | class AlgUnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n #各要素の親要素の番号を格納するリスト 要素が根(ルート)の場合は-(そのグループの要素数)を格納する
def find(self, x): #要素xが属するグループの根を返す
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
... | Traceback (most recent call last):
File "/tmp/tmpfb83v1x6/tmpz_u4ytt_.py", line 49, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s445231624 | p02536 | u609561564 | 1601171791 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9920 | 696 | from collections import deque
N, M = map(int, input().split())
pair={}
for _ in range(M):
a, b = map(int, input().split())
if a not in pair:
pair[a-1]=[b-1]
else:
pair[a-1].append(b-1)
if b not in pair:
pair[b-1]=[a-1]
else:
pair[b-1].append(a-1)
# print(pair)
did=[... | Traceback (most recent call last):
File "/tmp/tmporf6kkhd/tmppk4l2tz0.py", line 2, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s805052780 | p02536 | u218757284 | 1601171786 | Python | Python (3.8.2) | py | Runtime Error | 203 | 12752 | 1179 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x ... | Traceback (most recent call last):
File "/tmp/tmpjo8rqjg6/tmprekw2gm2.py", line 48, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s664179312 | p02536 | u790905630 | 1601171759 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9820 | 957 | def main():
N, M = map(int, input().split())
connect_list = [0] * N
for i in range(M):
A, B = map(int, input().split())
A_road_num = connect_list[A]
B_road_num = connect_list[B]
if A_road_num == 0 and B_road_num == 0:
max_road_num = max(connect_list)
... | Traceback (most recent call last):
File "/tmp/tmpmt1wuoyd/tmp99ia884v.py", line 30, in <module>
main()
File "/tmp/tmpmt1wuoyd/tmp99ia884v.py", line 2, in main
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s859420511 | p02536 | u714887242 | 1601171689 | Python | PyPy3 (7.3.0) | py | Runtime Error | 3679 | 306604 | 324 | N,M= [int(x) for x in input().split()]
root = list(range(N))
for i in range(M):
print(root)
A,B = [int(x)-1 for x in input().split()]
a = root[A]
b = root[B]
if a<b:
root = [a if i == b else i for i in root]
if b<a:
root = [b if i == a else i for i in root]
print(len(set(root)... | Traceback (most recent call last):
File "/tmp/tmp2gbe_7o8/tmpp5h387_y.py", line 1, in <module>
N,M= [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s585779352 | p02536 | u171654347 | 1601171622 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 12108 | 1254 | import copy
import math
import time
import statistics
import math
import itertools
import bisect
import sys
from decimal import *
from collections import deque
def get_int():
return int(input())
def get_string():
return input()
def get_int_list():
return [int(x) for x in input().split()]
def get_string... | Traceback (most recent call last):
File "/tmp/tmpuiald_j_/tmp9iff9yzr.py", line 66, in <module>
main()
File "/tmp/tmpuiald_j_/tmp9iff9yzr.py", line 38, in main
n, m = get_int_multi()
^^^^^^^^^^^^^^^
File "/tmp/tmpuiald_j_/tmp9iff9yzr.py", line 26, in get_int_multi
return map(int, input().sp... | |
s393756162 | p02536 | u216015528 | 1601171594 | Python | Python (3.8.2) | py | Runtime Error | 33 | 9784 | 2385 | #!/usr/bin/env python3
class UnionFind:
"""Union-Find(素集合データ構造)"""
def __init__(self, n: int):
"""
Constructer(Initialize parameter in this class)
Parameters
----------
n : int
Number of node
Yields
-----
root : list
... | Traceback (most recent call last):
File "/tmp/tmp98f_biu5/tmpif3evb_9.py", line 119, in <module>
main()
File "/tmp/tmp98f_biu5/tmpif3evb_9.py", line 103, in main
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s241974906 | p02536 | u171654347 | 1601171585 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 75148 | 1254 | import copy
import math
import time
import statistics
import math
import itertools
import bisect
import sys
from decimal import *
from collections import deque
def get_int():
return int(input())
def get_string():
return input()
def get_int_list():
return [int(x) for x in input().split()]
def get_string... | Traceback (most recent call last):
File "/tmp/tmpm8an30jx/tmpg_q61lpa.py", line 66, in <module>
main()
File "/tmp/tmpm8an30jx/tmpg_q61lpa.py", line 38, in main
n, m = get_int_multi()
^^^^^^^^^^^^^^^
File "/tmp/tmpm8an30jx/tmpg_q61lpa.py", line 26, in get_int_multi
return map(int, input().sp... | |
s511846188 | p02536 | u035885928 | 1601171557 | Python | Python (3.8.2) | py | Runtime Error | 332 | 26936 | 388 | n,m = map(int,input().split())
adj=[[] for k in range(n)]
for i in range(m):
x,y=map(int,input().split())
x-=1;y-=1
adj[x].append(y)
adj[y].append(x)
numCon=0
visited=[False]*n
def dfs(x):
visited[x]=True
for a in adj[x]:
if visited[a]: continue
dfs(a)
for i in range(n):
if n... | Traceback (most recent call last):
File "/tmp/tmpegcydz78/tmpqu1q5gjk.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s690330804 | p02536 | u554850896 | 1601171533 | Python | Python (3.8.2) | py | Runtime Error | 224 | 27256 | 1496 | class Graph:
# init function to declare class variables
def __init__(self,V):
self.V = V
self.adj = [[] for i in range(V)]
def DFSUtil(self, temp, v, visited):
# Mark the current vertex as visited
visited[v] = True
# Store the vertex to list
... | Traceback (most recent call last):
File "/tmp/tmpyc47k8v0/tmpgml0uv9n.py", line 48, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s334607636 | p02536 | u473172054 | 1601171516 | Python | Python (3.8.2) | py | Runtime Error | 160 | 18344 | 281 | n, m = map(int, input().split())
par = [i for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
cur = par[b]
par[b] = par[a]
for i in range(n):
if par[i] < i:
cur_p = par[i]
par[i] = par[cur_p]
ans = len(set(par)) - 1
print(ans) | Traceback (most recent call last):
File "/tmp/tmpcpj45z08/tmp79l1_w3q.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s168047650 | p02536 | u319818856 | 1601171492 | Python | Python (3.8.2) | py | Runtime Error | 327 | 29912 | 892 | from typing import List, Dict
MAX_N = 10 ** 5
visited = [False] * MAX_N
cluster = [0] * MAX_N
edges: Dict[int, List[int]] = {}
def dfs(node: int, cluster_num: int) -> None:
cluster[node] = cluster_num
visited[node] = True
if node not in edges:
return
for v in edges[node]:
if visite... | Traceback (most recent call last):
File "/tmp/tmp9e1tzluv/tmp4v_phl8k.py", line 34, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s497109460 | p02536 | u363391958 | 1601171462 | Python | Python (3.8.2) | py | Runtime Error | 330 | 31680 | 547 | def main(dic, lst):
seen = set()
res = 0
def bfs(i):
if i in seen:
return
seen.add(i)
for j in dic[i]:
bfs(j)
for i in lst:
if i in seen:
continue
bfs(i)
res += 1
return res - 1
n, m = tuple(map(int, input().split... | Traceback (most recent call last):
File "/tmp/tmpvc66wfn4/tmpz6wwklsb.py", line 19, in <module>
n, m = tuple(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s500636670 | p02536 | u778614444 | 1601171457 | Python | PyPy3 (7.3.0) | py | Runtime Error | 122 | 102412 | 513 | import collections
n, m = map(int, input().split())
linked = collections.defaultdict(set)
for i in range(1, n + 1):
linked[i].add(i)
for i in range(m):
a, b = map(int, input().split())
if len(linked[a]) > len(linked[b]):
tmp = a
a = b
b = tmp
linked[a].add(linked[b])
tmp =linked[a]
for t in... | Traceback (most recent call last):
File "/tmp/tmpfr9hlfr8/tmpobbtlugi.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s379455228 | p02536 | u275666666 | 1601171423 | Python | Python (3.8.2) | py | Runtime Error | 326 | 53472 | 599 | import networkx as nx
import matplotlib.pyplot as plt
N,M = list(map(int,input().split()))
AB=[list(map(int, input().split())) for i in range(M)]
G=nx.Graph()
for i in range(1,N+1):
G.add_node(i)
for ab in AB:
G.add_edge(ab[0],ab[1])
count=0
nodes=list(range(1,N+1))
p_ori=nodes[0]
reachable=nx.shortest_path(... | Traceback (most recent call last):
File "/tmp/tmpro5_1_h4/tmp4c0cyhrj.py", line 3, in <module>
N,M = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s515150889 | p02536 | u383025592 | 1601171418 | Python | PyPy3 (7.3.0) | py | Runtime Error | 5027 | 294104 | 673 | class UnionFind:
par = None
def __init__(self, n):
self.par = [0] * n
def root(self, x):
if(self.par[x] == 0):
return x
else:
self.par[x] = self.root(self.par[x])
return self.root(self.par[x])
def unite(self, x, y):
if(self.root(x) != self.root(y)):
self.par[se... | Traceback (most recent call last):
File "/tmp/tmp1xwc7hrm/tmp3hr71nr9.py", line 21, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s207106438 | p02536 | u767797498 | 1601171409 | Python | Python (3.8.2) | py | Runtime Error | 372 | 38920 | 392 | def dfs(f):
if vis[f] == 1: return
vis[f] = 1
for t in V[f]:
dfs(t)
n, m = map(int, input().split())
E = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]
V = [[] for _ in range(n)]
for a, b in E: V[a].append(b); V[b].append(a)
ans = 0
vis = [0]*n
for a in range(... | Traceback (most recent call last):
File "/tmp/tmpao6j0nzg/tmpb1juxlxu.py", line 8, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s321997814 | p02536 | u265118937 | 1601171403 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8940 | 450 | #include <bits/stdc++.h>
#include <atcoder/all>
#include <cstdio>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n, m;
cin >> n >> m;
int cnt = 0;
dsu d(n);
rep(i, m){
int a, b;
cin >> a >> b;
d.merge(a, b);
}
for (int i=... | File "/tmp/tmpu9c85gue/tmp9aeatbze.py", line 5
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
s995966878 | p02536 | u559367141 | 1601171400 | Python | Python (3.8.2) | py | Runtime Error | 230 | 27260 | 130 | N,M = map(int, input().split())
a_list = []
for i in range(N):
a_list.append(list(map(int, input().split())))
print(N-(M+1))
| Traceback (most recent call last):
File "/tmp/tmpy_47c73l/tmp_xfe1592.py", line 1, in <module>
N,M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s430710592 | p02536 | u319818856 | 1601171383 | Python | Python (3.8.2) | py | Runtime Error | 308 | 29888 | 871 | from typing import List, Dict
MAX_N = 10 ** 5
visited = [False] * MAX_N
cluster = [0] * MAX_N
edges: Dict[int, List[int]] = {}
def dfs(node: int, cluster_num: int) -> None:
cluster[node] = cluster_num
visited[node] = True
if node not in edges:
return
for v in edges[node]:
if visite... | Traceback (most recent call last):
File "/tmp/tmp73j8i58y/tmp9bamcmpb.py", line 34, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s441385701 | p02536 | u216015528 | 1601171366 | Python | Python (3.8.2) | py | Runtime Error | 64 | 17964 | 2435 | #!/usr/bin/env python3
class UnionFind:
"""Union-Find(素集合データ構造)"""
def __init__(self, n: int):
"""
Constructer(Initialize parameter in this class)
Parameters
----------
n : int
Number of node
Yields
-----
root : list
... | Traceback (most recent call last):
File "/tmp/tmpfb_a_wsx/tmpx82nyl9d.py", line 121, in <module>
main()
File "/tmp/tmpfb_a_wsx/tmpx82nyl9d.py", line 103, in main
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s633100318 | p02536 | u688839540 | 1601171338 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 10196 | 676 | n,m = list(map(int,input().split()))
c = []
cn = []
for _ in range(m):
i,j = list(map(int,input().split()))
if (not i in c) and (not j in c):
c+=[i,j]
cn.append([i,j])
elif (not i in c):
c.append(i)
for a,x in enumerate(cn):
if j in x:
cn[a].append(i)
elif (not j in c):
c.appen... | Traceback (most recent call last):
File "/tmp/tmpyquxwnqp/tmpluygnr5e.py", line 1, in <module>
n,m = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s170755287 | p02536 | u216728327 | 1601171304 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9192 | 189 | d = input().split()
N = int(d[0])
M = int(d[1])
c = []
for i in range(M):
l = input.split()
if l[0] not in c:
c.append(l[0])
if l[1] not in c:
c.append(l[1])
print(N - len(c)) | Traceback (most recent call last):
File "/tmp/tmplifnwgpw/tmp9kkvkrw6.py", line 1, in <module>
d = input().split()
^^^^^^^
EOFError: EOF when reading a line
| |
s222910732 | p02536 | u554850896 | 1601171268 | Python | Python (3.8.2) | py | Runtime Error | 27 | 8876 | 1802 | #include <bits/stdc++.h>
using namespace std;
// Graph class represents a undirected graph
// using adjacency list representation
class Graph {
// No. of vertices
int V;
// Pointer to an array containing adjacency lists
list<int>* adj;
// A function used by DFS
void DFSUtil(in... | File "/tmp/tmp1yvcyh93/tmpvxbopw80.py", line 2
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
s295496151 | p02536 | u016843859 | 1601171259 | Python | Python (3.8.2) | py | Runtime Error | 340 | 30828 | 425 | from collections import defaultdict
N,M=map(int,input().split())
AB=list()
memo=[False]*N
G=defaultdict(list)
def dfs(G,i):
memo[i]=True
for j in G[i]:
if memo[j]==False:
dfs(G,j)
count=0
for i in range(M):
AB=list(map(int,input().split()))
G[AB[1]-1].append(AB[0]-1)
G[AB[0]-1].a... | Traceback (most recent call last):
File "/tmp/tmp1w8on8zi/tmpi4byy0y3.py", line 2, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s346559900 | p02536 | u935241425 | 1601171224 | Python | Python (3.8.2) | py | Runtime Error | 2227 | 419868 | 655 | import numpy as np
n, m = map( int, input().split() )
#print( n, m )
a = [ 0 ] * m
b = [ 0 ] * m
for i in range( m ):
a[ i ], b[ i ] = map( int, input().split() )
#print( a, b )
xmat = np.zeros( ( n, n ), dtype=int)
#print( xmat )
for i in range( m ):
xmat[ a[ i ]-1 ][ b[ i ]-1 ] = 1
xmat[ b[ i ]-... | Traceback (most recent call last):
File "/tmp/tmp4ajuuxqo/tmpae5erkpm.py", line 3, in <module>
n, m = map( int, input().split() )
^^^^^^^
EOFError: EOF when reading a line
| |
s915777593 | p02536 | u483721532 | 1601171183 | Python | Python (3.8.2) | py | Runtime Error | 615 | 12956 | 211 | N, M = map(int, input().split())
n = list(i+1 for i in range(N))
count = 0
for _ in range(M):
A, B = map(int, input().split())
if A in n or B in n:
n.remove(A)
n.remove(B)
print(len(n)) | Traceback (most recent call last):
File "/tmp/tmp60tv82m7/tmpfebq0jat.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s964110389 | p02536 | u361716628 | 1601171178 | Python | Python (3.8.2) | py | Runtime Error | 148 | 9664 | 227 | N, M = map(int, input().split())
# 都市分のリストを作成
res = [0] * N
# 道路の数だけ入力する
for i in range(M):
x, y = map(int, input().split())
res[x] += 1
res[y] += 1
print(N - sum(res)) | Traceback (most recent call last):
File "/tmp/tmpekdn_fot/tmp4w66sdem.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s946120306 | p02536 | u688839540 | 1601171176 | Python | Python (3.8.2) | py | Runtime Error | 348 | 9332 | 662 | n,m = list(map(int,input().split()))
c = []
cn = []
for _ in range(m):
i,j = list(map(int,input().split()))
if (not i in c) and (not j in c):
c+=[i,j]
cn.append([i,j])
elif (not i in c):
c.append(i)
for a,x in enumerate(cn):
if j in x:
cn[a].append(i)
elif (not j in c):
c.appen... | Traceback (most recent call last):
File "/tmp/tmpls_a10c8/tmpm30gp96e.py", line 1, in <module>
n,m = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s684483140 | p02536 | u844872527 | 1601171160 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9192 | 798 | def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))
n,m=MII()
#connect_city=[LII() for _ in range(m)]
groups=[[1]]
group_set=set([1])
#city_count=1
for i in range(m):
a,b=MII()
flag=0
if a in group_set:
for group in groups:
if a in group:
... | Traceback (most recent call last):
File "/tmp/tmpn1sx705l/tmpowgcutex.py", line 4, in <module>
n,m=MII()
^^^^^
File "/tmp/tmpn1sx705l/tmpowgcutex.py", line 1, in MII
def MII(): return map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s607055853 | p02536 | u798136015 | 1601171116 | Python | PyPy3 (7.3.0) | py | Runtime Error | 385 | 94280 | 428 | N, M = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(M)]
par = [i for i in range(N)]
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
return par[x]
def same(x, y):
return find(x) == find(y)
def unite(x, y):
x = find(x)
y... | Traceback (most recent call last):
File "/tmp/tmp6inxw6gc/tmpqtdcn5b9.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s771734834 | p02536 | u383025592 | 1601171074 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1736 | 294440 | 577 | class UnionFind:
par = None
def __init__(self, N):
self.par = list(range(N))
def root(self, x):
if(self.par[x] == x):
return x
else:
self.par[x] = self.root(self.par[x])
return self.par[x]
def unite(self, x, y):
if(self.root(x) != self.root(y)):
self.par[x] = s... | Traceback (most recent call last):
File "/tmp/tmp6v275enu/tmppgii03uz.py", line 18, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s851313897 | p02536 | u261374036 | 1601171048 | Python | PyPy3 (7.3.0) | py | Runtime Error | 460 | 135072 | 2694 | class Vertex(object):
def __init__(self, id):
self.id = id
self.adjacent = {}
# DFS
self.visited = False
def add_neighbor(self, neighbor, weight=0):
self.adjacent[neighbor] = weight
def get_neighbors(self):
return self.adjacent
def get_connections(sel... | Traceback (most recent call last):
File "/tmp/tmpnfnr9sua/tmpoxow9rhd.py", line 77, in <module>
N, M = (int(i) for i in input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s277798183 | p02536 | u016843859 | 1601171024 | Python | Python (3.8.2) | py | Runtime Error | 405 | 30600 | 502 | N,M=map(int,input().split())
AB=list()
memo=[False]*N
G=dict()
def dfs(G,i):
memo[i]=True
for j in G[i]:
if memo[j]==False:
G.setdefault(j,[])
dfs(G,j)
count=0
for i in range(M):
AB=list(map(int,input().split()))
G.setdefault(AB[0]-1,list())
G.setdefault(AB[1]-1,list(... | Traceback (most recent call last):
File "/tmp/tmphsvbrcg5/tmpxrznluak.py", line 1, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s721736794 | p02536 | u363391958 | 1601170976 | Python | Python (3.8.2) | py | Runtime Error | 357 | 31776 | 486 | def main(dic,lst):
seen =set()
res = 0
def bfs(i):
if i in seen:
return
seen.add(i)
for j in dic[i]:
bfs(j)
for i in lst:
if i in seen:
continue
bfs(i)
res+=1
return res-1
n, m = tuple(map(int, input().split()))
lst = [i for i in range(1,n+1)]
from collections impo... | Traceback (most recent call last):
File "/tmp/tmpfn92_cdr/tmp72cmqpei.py", line 17, in <module>
n, m = tuple(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s398263949 | p02536 | u077816564 | 1601170894 | Python | Python (3.8.2) | py | Runtime Error | 313 | 26820 | 738 | def dfs(now, prev):
global flag
# 今いる頂点から行ける頂点を順に next に入れてループ
for next in g[now]:
if next != prev:
if memo[next]:
# 過去に訪れていれば閉路
flag = False
else:
memo[next] = True
dfs(next, now)
n, m = map(int, input().split... | Traceback (most recent call last):
File "/tmp/tmpag92ywr9/tmpsz_7dlr5.py", line 14, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s764200553 | p02536 | u600195339 | 1601170881 | Python | Python (3.8.2) | py | Runtime Error | 263 | 31876 | 568 | from collections import deque
from collections import defaultdict
n, m = map(int, input().split())
g = defaultdict(list)
s = set(list(range(1, n+1)))
ans = 0
for i in range(m):
a, b = map(int, input().split())
g[a].append(b)
while s:
root = s.pop()
q = deque()
q.append(root)
done = set()
... | Traceback (most recent call last):
File "/tmp/tmpepj4trgy/tmp_dsuowpe.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s645859372 | p02536 | u483721532 | 1601170878 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 13124 | 225 | N, M = map(int, input().split())
n = list(i+1 for i in range(N))
count = 0
for _ in range(M):
A, B = map(int, input().split())
if A in n or B in n:
count+=1
n[A] = 0
n[B] = 0
print(N-1-count) | Traceback (most recent call last):
File "/tmp/tmpgpm9la3t/tmpwptyzojn.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s218536617 | p02536 | u953655640 | 1601170846 | Python | Python (3.8.2) | py | Runtime Error | 204 | 12880 | 1328 | N, M = map(int, input().split())
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
d... | Traceback (most recent call last):
File "/tmp/tmpajvunsq7/tmpxix0weez.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s227336208 | p02536 | u600195339 | 1601170829 | Python | Python (3.8.2) | py | Runtime Error | 21 | 9036 | 549 | from collections import deque
from collections import defaultdict
n, m = map(int, input().split())
g = defaultdict(list)
s = set(list(range(1, n+1)))
ans = 0
for i in range(m):
a, b = map(int, input().split())
g[a].append(b)
while s:
ans += 1
root = s.pop()
q = deque()
q.append(root)
done = s... | File "/tmp/tmpnlq5kz17/tmpu9owg63t.py", line 12
root = s.pop()
^
IndentationError: unindent does not match any outer indentation level
| |
s194538872 | p02536 | u388164885 | 1601170826 | Python | Python (3.8.2) | py | Runtime Error | 504 | 21024 | 444 | n, m = map(int, input().split())
fathers = {t:t for t in range(n)}
cnt = 0
def get_father(n) :
while not fathers[n] == fathers[fathers[n]] :
fathers[n] = fathers[fathers[n]]
return fathers[n]
for i in range(m):
ai, bi = map(int, input().split())
if get_father(ai) == get_father(bi):
conti... | Traceback (most recent call last):
File "/tmp/tmp522g8ugr/tmpbrb22ucm.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s638264461 | p02536 | u688839540 | 1601170823 | Python | Python (3.8.2) | py | Runtime Error | 136 | 9444 | 622 | n,m = list(map(int,input().split()))
c = []
cn = []
for _ in range(m):
i,j = list(map(int,input().split()))
if (not i in c) and (not j in c):
c+=[i,j]
cn.append([i,j])
elif (not i in c):
c.append(i)
for a,x in enumerate(cn):
if j in x:
cn[a].append(i)
elif (not j in c):
c.appen... | Traceback (most recent call last):
File "/tmp/tmppx2wghhm/tmpug9m0tar.py", line 1, in <module>
n,m = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s814720305 | p02536 | u994544088 | 1601170813 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9100 | 98 | n,m=int(input()),int(input())
a,b=input(input()),input(input())
if a: print(n-m-1)
else:print(n-m) | Traceback (most recent call last):
File "/tmp/tmp405ezcsc/tmpahzd2_zn.py", line 1, in <module>
n,m=int(input()),int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s245385224 | p02536 | u252828980 | 1601170802 | Python | Python (3.8.2) | py | Runtime Error | 330 | 32772 | 1878 | n,m = map(int,input().split())
L = [list(map(int,input().split())) for i in range(m)]
class UnionFind:
def __init__(self, n):
self.n = n
self.parent = [i for i in range(n)] # 親
self.rank = [1] * n # 木の高さ
self.size = [1] * n # size[i] は i を根とするグループのサイズ
def find(self, x): # ... | Traceback (most recent call last):
File "/tmp/tmpd6yh_ivv/tmpp7o4p_w6.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s424282082 | p02536 | u994544088 | 1601170763 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9164 | 92 | n,m=int(input()),int(input())
a,b=int(input()),int(input())
if a: print(n-2)
else:print(n-1) | Traceback (most recent call last):
File "/tmp/tmpz0a5p4hp/tmpv4o28_mg.py", line 1, in <module>
n,m=int(input()),int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s853034854 | p02536 | u077816564 | 1601170754 | Python | Python (3.8.2) | py | Runtime Error | 341 | 26920 | 736 | def dfs(now, prev):
global flag
# 今いる頂点から行ける頂点を順に next に入れてループ
for next in g[now]:
if next != prev:
if memo[next]:
# 過去に訪れていれば閉路
flag = False
else:
memo[next] = True
dfs(next, now)
N, M = map(int, input().split(... | Traceback (most recent call last):
File "/tmp/tmpf4rgm6br/tmpyfzgnblq.py", line 13, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s937466553 | p02536 | u865383026 | 1601170712 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 41504 | 431 | def Search(pos):
L[pos-1] = 1
if pos not in R:
R[pos] = set()
R[pos].add(1)
return
for i in R[pos]:
if L[i-1] == 0:
Search(i)
N, M = map(int, input().split())
R = {}
for i in range(M):
A, B = map(int, input().split())
if A not in R:
R[A] = set()
if B not in R:
R[B] = set()
R... | Traceback (most recent call last):
File "/tmp/tmph4mekxfj/tmp3grzk5mk.py", line 11, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s614019585 | p02536 | u759200007 | 1601170695 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 31868 | 1062 | import sys
sys.setrecursionlimit(10**6)
N = 10**5+1
g = [[] for i in range(N)]
vis = [False for i in range(N)]
good = [False for i in range(N)]
def ADD_EDGE(u, v):
g[u].append(v)
def dfs1(v):
good[v] = True
for to in g[v]:
if not good[to]:
dfs1(to)
def dfs2(v... | Traceback (most recent call last):
File "/tmp/tmp376_uzm9/tmpm5tl5_yn.py", line 54, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s381339456 | p02536 | u441246928 | 1601170653 | Python | Python (3.8.2) | py | Runtime Error | 181 | 9168 | 103 | N,M = map(int,input().split())
for i in range(N) :
A,B = map(int,input().split())
print(N-1-M) | Traceback (most recent call last):
File "/tmp/tmpz1j16r95/tmp8n_ad0ky.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s368309781 | p02536 | u405276711 | 1601170649 | Python | PyPy3 (7.3.0) | py | Runtime Error | 334 | 90080 | 518 | n,m = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(m)]
*p, = range(n)
rank = [1]*n
def root(x):
if x == p[x]:
return x
p[x] = y = root(p[x])
return y
def unite(x, y):
px = root(x); py = root(y)
if px == py:
return 0
rx = rank[px]; ry = rank[... | Traceback (most recent call last):
File "/tmp/tmp6zxbaey_/tmpadu9fq0q.py", line 1, in <module>
n,m = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s675350223 | p02536 | u514441044 | 1601170649 | Python | Python (3.8.2) | py | Runtime Error | 1051 | 649504 | 1277 | from collections import Counter
import string
import math
import sys
sys.setrecursionlimit(10**6)
def array_int():
return [int(i) for i in sys.stdin.readline().split()]
def vary(number_of_variables):
if number_of_variables==1:
return int(sys.stdin.readline())
if number_of_variables>=2:
retu... | Traceback (most recent call last):
File "/tmp/tmpfgi3mnev/tmptn3c2kq9.py", line 27, in <module>
n,m=vary(2)
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s994453225 | p02536 | u844872527 | 1601170589 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9224 | 563 | def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))
n,m=MII()
#connect_city=[LII() for _ in range(m)]
groups=[[1]]
city_count=1
for i in range(m):
a,b=MII()
flag=0
for group in groups:
if a in group:
group+=[b]
city_count+=1
... | Traceback (most recent call last):
File "/tmp/tmp4ubz680t/tmpsv9unjjk.py", line 4, in <module>
n,m=MII()
^^^^^
File "/tmp/tmp4ubz680t/tmpsv9unjjk.py", line 1, in MII
def MII(): return map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s288936342 | p02536 | u759200007 | 1601170569 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 26908 | 1021 | N = 10**5+1
g = [[] for i in range(N)]
vis = [False for i in range(N)]
good = [False for i in range(N)]
def ADD_EDGE(u, v):
g[u].append(v)
def dfs1(v):
good[v] = True
for to in g[v]:
if not good[to]:
dfs1(to)
def dfs2(v):
global cnt
vis[v] = True
... | Traceback (most recent call last):
File "/tmp/tmpop6vj1at/tmpsngksdog.py", line 51, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s811773122 | p02536 | u472005704 | 1601170569 | Python | PyPy3 (7.3.0) | py | Runtime Error | 217 | 123548 | 522 | import sys
def dfs(idx):
for x in arr[idx]:
if not vis[x]:
vis[x] = True
dfs(x)
n, m = map(int, input().split())
arr = [[] * (n + 1) for _ in range(n + 1)]
vis = [False] * (n + 1)
for _ in range(m):
a, b = map(int, sys.stdin.readline().split())
arr[a].append(b)
arr[... | Traceback (most recent call last):
File "/tmp/tmpoq16cvcs/tmpumsts_ua.py", line 11, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s222831626 | p02536 | u618696829 | 1601170558 | Python | Python (3.8.2) | py | Runtime Error | 74 | 31316 | 433 | N,M = map(int,input().split( ))
loads = []
teams = [[i] for i in range(N)]
syozoku = {i:i for i in range(N)}
for _ in range(M):
A,B = map(int,input().split( ))
if syozoku[A-1] != syozoku[B-1]:
hairu,nukeru = min(syozoku[A-1],syozoku[B-1]),max(syozoku[A-1],syozoku[B-1])
team = teams.pop(nukeru)
... | Traceback (most recent call last):
File "/tmp/tmpx5q_u_h8/tmp4c_iro3o.py", line 1, in <module>
N,M = map(int,input().split( ))
^^^^^^^
EOFError: EOF when reading a line
| |
s538017020 | p02536 | u519339498 | 1601170552 | Python | Python (3.8.2) | py | Runtime Error | 157 | 12952 | 1919 | '''
Created on 2020/09/26
@author: harurun
'''
#UnionFind(要素数)で初期化
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
#parents 各要素の親番号を格納するリストを返す
#要素xが属するグループを返す
def find(self, x):
if self.parents[x] < 0:
return x
else:
... | Traceback (most recent call last):
File "/tmp/tmpenqd6p8w/tmp7tdid7wm.py", line 77, in <module>
main()
File "/tmp/tmpenqd6p8w/tmp7tdid7wm.py", line 67, in main
N,M=map(int,pin().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s172410285 | p02536 | u954153335 | 1601170538 | Python | Python (3.8.2) | py | Runtime Error | 303 | 13864 | 285 | n,m=map(int,input().split())
data=list(range(n))
cnt=n-1
def find(x):
if data[x]==x:
return x
else:
return find(data[x])
for i in range(m):
a,b=map(int,input().split())
a=find(a-1)
b=find(b-1)
if a!=b:
data[a]=b
cnt-=1
print(cnt) | Traceback (most recent call last):
File "/tmp/tmp23my63gn/tmp5cpfv50e.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s466554731 | p02536 | u650939551 | 1601170510 | Python | Python (3.8.2) | py | Runtime Error | 381 | 28948 | 1660 | # Python3 program to print DFS traversal
# from a given given graph
from collections import defaultdict
viz = [0]*100005
# This class represents a directed graph using
# adjacency list representation
class Graph:
# Constructor
def __init__(self):
# default dictionary to store graph
self.gra... | Traceback (most recent call last):
File "/tmp/tmpebx8aigm/tmpjkzvgnj_.py", line 58, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s097850745 | p02536 | u514441044 | 1601170504 | Python | Python (3.8.2) | py | Runtime Error | 220 | 27852 | 1247 | from collections import Counter
import string
import math
import sys
def array_int():
return [int(i) for i in sys.stdin.readline().split()]
def vary(number_of_variables):
if number_of_variables==1:
return int(sys.stdin.readline())
if number_of_variables>=2:
return map(int,sys.stdin.readline(... | Traceback (most recent call last):
File "/tmp/tmpjd0ogj5s/tmpzn8krz0z.py", line 26, in <module>
n,m=vary(2)
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s532224312 | p02536 | u759200007 | 1601170456 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 26964 | 1010 | N = 10**5
g = [[] for i in range(N)]
vis = [False for i in range(N)]
good = [False for i in range(N)]
def ADD_EDGE(u, v):
g[u].append(v)
def dfs1(v):
good[v] = True
for to in g[v]:
if not good[to]:
dfs1(to)
def dfs2(v):
global cnt
vis[v] = True
cn... | Traceback (most recent call last):
File "/tmp/tmp68nujngr/tmpl723etyh.py", line 51, in <module>
n, x = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s351017391 | p02536 | u252828980 | 1601170434 | Python | Python (3.8.2) | py | Runtime Error | 357 | 32772 | 1932 | n,m = map(int,input().split())
L = [list(map(int,input().split())) for i in range(m)]
class UnionFind:
def __init__(self, n):
self.n = n
self.parent = [i for i in range(n)] # 親
self.rank = [1] * n # 木の高さ
self.size = [1] * n # size[i] は i を根とするグループのサイズ
def find(self, x): # ... | Traceback (most recent call last):
File "/tmp/tmp99_j2cdo/tmpms2qdd7q.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s743630473 | p02536 | u129019798 | 1601170404 | Python | PyPy3 (7.3.0) | py | Runtime Error | 498 | 123960 | 576 | def main():
import sys
N,M=list(map(int,sys.stdin.readline().split()))
dic=[[] for _ in range(100001)]
mark=[0]*N
for i in range(M):
A,B=list(map(int,sys.stdin.readline().split()))
dic[A-1].append(B-1)
dic[B-1].append(A-1)
def dfs(idx):
if mark[idx]:
... | Traceback (most recent call last):
File "/tmp/tmpz51h55a5/tmpl36tzjta.py", line 29, in <module>
main()
File "/tmp/tmpz51h55a5/tmpl36tzjta.py", line 3, in main
N,M=list(map(int,sys.stdin.readline().split()))
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s291958619 | p02536 | u766486294 | 1601170393 | Python | Python (3.8.2) | py | Runtime Error | 225 | 26080 | 2061 | import types
_atcoder_code = """
# Python port of AtCoder Library.
__version__ = '0.0.1'
"""
atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)
_atcoder_dsu_code = """
import typing
class DSU:
'''
Implement (union by size) + (path compression)
Reference:
Zvi Galil and Gius... | Traceback (most recent call last):
File "/tmp/tmpr6_acdw0/tmprqmqja4j.py", line 85, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s116361991 | p02536 | u507456172 | 1601170385 | Python | Python (3.8.2) | py | Runtime Error | 199 | 12960 | 832 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | Traceback (most recent call last):
File "/tmp/tmpki2x600i/tmp4ra51uoe.py", line 32, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s376327849 | p02536 | u650939551 | 1601170375 | Python | Python (3.8.2) | py | Runtime Error | 334 | 28924 | 1658 | # Python3 program to print DFS traversal
# from a given given graph
from collections import defaultdict
viz = [0]*100005
# This class represents a directed graph using
# adjacency list representation
class Graph:
# Constructor
def __init__(self):
# default dictionary to store graph
self.gra... | Traceback (most recent call last):
File "/tmp/tmptq68r062/tmp3mh3mt2i.py", line 58, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s213820902 | p02536 | u600195339 | 1601170369 | Python | Python (3.8.2) | py | Runtime Error | 246 | 31848 | 555 | from collections import deque
from collections import defaultdict
n, m = map(int, input().split())
g = defaultdict(list)
s = set(list(range(1, n+1)))
ans = 0
for i in range(m):
a, b = map(int, input().split())
g[a].append(b)
while s:
root = s.pop()
q = deque()
q.append(root)
done = set()
... | Traceback (most recent call last):
File "/tmp/tmpwa912k5v/tmpyur2fzyb.py", line 4, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.