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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s465152672 | p02536 | u722868069 | 1601184461 | Python | Python (3.8.2) | py | Runtime Error | 422 | 36564 | 775 | def root(x):
if r[x] < 0:
return x
else:
r[x] = root(r[x])
return r[x]
from operator import itemgetter
n, m = map(int, input().split())
road = [list(map(int,input().split())) for i in range(m)]
r = [-1]*(n+1)
#print(g)
road = sorted(road, key=lambda x:(x[0], x[1]))
#print(r)
group_num = 1;
for i, ... | Traceback (most recent call last):
File "/tmp/tmp04vluyol/tmpawfjdxhi.py", line 10, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s163617802 | p02536 | u979823197 | 1601182745 | Python | PyPy3 (7.3.0) | py | Runtime Error | 280 | 78776 | 1311 | 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/tmpxeb_4g0o/tmpkcsn0s2i.py", line 48, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s501610021 | p02536 | u234454594 | 1601181817 | Python | PyPy3 (7.3.0) | py | Runtime Error | 84 | 68768 | 417 | from collections import deque
n,m=map(int,input().split())
road=[[] for i i range(n)]
flag=[0]*n
for i in range(m):
a,b=map(int,input().split())
road[a-1].append(b-1)
road[b-1].append(a-1)
count=0
for i in range(n):
if flag[i]!=0:
continue
count+=1
q=[k]
while q:
p=q.popleft(... | File "/tmp/tmpby63we9a/tmpuuuq69g0.py", line 3
road=[[] for i i range(n)]
^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
| |
s178609934 | p02536 | u910358825 | 1601179151 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9892 | 543 | n,m=map(int, input().split())
lst=[list(map(int, input().split()))]
town=[1]*n
for j in range(2):
town[lst[0][j]-1]=0
l=1
for i in range(m-1):
a=list(map(int, input().split()))
for j in range(2):
town[a[j]-1]=0
cnt=0
for k in range(l):
if (a[0] or a[1]) in lst[k]:
lst... | Traceback (most recent call last):
File "/tmp/tmpsez5q8bq/tmpr64fbbtf.py", line 1, in <module>
n,m=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s900089433 | p02536 | u865383026 | 1601179043 | Python | Python (3.8.2) | py | Runtime Error | 55 | 11968 | 559 | N, M = map(int, input().split())
L = [0] * N
D = {}
c = 1
for i in range(M):
A, B = map(int, input().split())
if L[A - 1] == L[B - 1] == 0:
D[c] = set()
D[c].add(A)
D[c].add(B)
L[A - 1] = c
L[B - 1] = c
c += 1
elif L[A - 1] == 0:
D[L[B - 1]].add(A)
L[A - 1] = L[B - 1]
elif L[B - ... | Traceback (most recent call last):
File "/tmp/tmpmhllfbdd/tmp6te2hh3b.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s595475583 | p02536 | u363391958 | 1601178739 | Python | Python (3.8.2) | py | Runtime Error | 311 | 31752 | 551 | 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().sp... | Traceback (most recent call last):
File "/tmp/tmp7gsdfh2e/tmpg593tehx.py", line 19, in <module>
n, m = tuple(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s021823789 | p02536 | u865383026 | 1601178709 | Python | Python (3.8.2) | py | Runtime Error | 49 | 12000 | 533 | N, M = map(int, input().split())
L = [0] * N
D = {}
c = 1
for i in range(M):
A, B = map(int, input().split())
if L[A - 1] == 0 and L[B - 1] == 0:
D[c] = set()
D[c].add(A)
D[c].add(B)
L[A - 1] = c
L[B - 1] = c
c += 1
elif L[A - 1] == 0:
D[L[B - 1]].add(A)
L[A - 1] = L[B - 1]
elif ... | Traceback (most recent call last):
File "/tmp/tmpssod1g7k/tmpg7brvqgo.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s016695518 | p02536 | u478417863 | 1601177092 | Python | Python (3.8.2) | py | Runtime Error | 202 | 12876 | 1300 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | Traceback (most recent call last):
File "/tmp/tmp7glnfmq3/tmpadaczf5o.py", line 47, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s259943230 | p02536 | u456225659 | 1601177079 | Python | Python (3.8.2) | py | Runtime Error | 364 | 29412 | 861 | from collections import defaultdict
class graph:
def __init__(self,V):
self.V=V
self.graph=defaultdict(list)
def dfs(self,temp,v,visited):
visited[v]=True
temp.append(v)
for i in self.graph[v]:
if visited[i]==False:
temp=self.dfs(temp,i,visite... | Traceback (most recent call last):
File "/tmp/tmpvet1l5ww/tmp2a04um1e.py", line 26, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s811943715 | p02536 | u456225659 | 1601176900 | Python | Python (3.8.2) | py | Runtime Error | 358 | 29228 | 859 | from collections import defaultdict
class graph:
def __init__(self,V):
self.V=V
self.graph=defaultdict(list)
def dfs(self,temp,v,visited):
visited[v]=True
temp.append(v)
for i in self.graph[v]:
if visited[i]==False:
temp=self.dfs(temp,i,visite... | Traceback (most recent call last):
File "/tmp/tmpefjcejwt/tmpnlj93qr0.py", line 26, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s759314978 | p02536 | u881675205 | 1601176767 | Python | PyPy3 (7.3.0) | py | Runtime Error | 313 | 105652 | 453 | def s(way):
global w
global c
for i in way:
if c[i] == 0:
c[i] = 1
s(w[i])
from collections import deque
d = deque()
n,m = map(int,input().split())
w = [[] for i in range(n)]
c = [0 for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
w[a-1].append(... | Traceback (most recent call last):
File "/tmp/tmp0qt1fhvj/tmpv9aulxij.py", line 12, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s986519326 | p02536 | u881675205 | 1601176679 | Python | PyPy3 (7.3.0) | py | Runtime Error | 313 | 105804 | 441 | def s(way):
global w
for i in way:
if c[i] == 0:
c[i] = 1
s(w[i])
from collections import deque
d = deque()
n,m = map(int,input().split())
w = [[] for i in range(n)]
c = [0 for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
w[a-1].append(b-1)
w[b... | Traceback (most recent call last):
File "/tmp/tmp9l3e7303/tmpgaz9uzf3.py", line 11, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s543135893 | p02536 | u881675205 | 1601176536 | Python | PyPy3 (7.3.0) | py | Runtime Error | 361 | 110212 | 537 | def s(way):
global w
for i in way:
if c[i] == 0:
c[i] = 1
s(w[i])
from collections import deque
d = deque()
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)]
wc = [0 for i in range(n)]
c = [0 for i in range(n)]
for i ... | Traceback (most recent call last):
File "/tmp/tmpjocn68d3/tmpa36hqayi.py", line 11, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s292941519 | p02536 | u602773379 | 1601176532 | Python | Python (3.8.2) | py | Runtime Error | 216 | 27288 | 354 | #入力:N,M(int:整数)
def input2():
return map(int,input().split())
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
return list(map(int,input().split()))
n,m=input2()
AB=[input_array() for _ in range(m)]
uf = UnionFind(n)
for ab in AB:
a=ab[0]
b=ab[1]
uf.union(a-1,b-1)
ans=0
for i in uf.parents:
if i < 0:
ans+=... | Traceback (most recent call last):
File "/tmp/tmp_tyqv8um/tmp0nv1x1ab.py", line 9, in <module>
n,m=input2()
^^^^^^^^
File "/tmp/tmp_tyqv8um/tmp0nv1x1ab.py", line 3, in input2
return map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s557407441 | p02536 | u456225659 | 1601176429 | Python | Python (3.8.2) | py | Runtime Error | 364 | 29228 | 857 | from collections import defaultdict
class graph:
def __init__(self,V):
self.V=V
self.graph=defaultdict(list)
def dfs(self,temp,v,visited):
visited[v]=True
temp.append(v)
for i in self.graph[v]:
if visited[i]==False:
temp=self.dfs(temp,i,visite... | Traceback (most recent call last):
File "/tmp/tmppifogq94/tmpzb4xero0.py", line 26, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s208469706 | p02536 | u845573105 | 1601176391 | Python | PyPy3 (7.3.0) | py | Runtime Error | 153 | 68196 | 730 | class UnionFind:
def __init__(self, n):
self.class = [i for i in range(n)]
self.n = n
def whichclass(self, x):
if self.class[x]==x:
return x
else:
self.class[x] = self.whichclass(self.class[x])
return self.class[x]
def union(self, x, y):
cx = self.whichclass(x)
cy = self.... | File "/tmp/tmpl_vpacoh/tmpfrony56d.py", line 3
self.class = [i for i in range(n)]
^^^^^
SyntaxError: invalid syntax
| |
s969203150 | p02536 | u479638406 | 1601174872 | Python | Python (3.8.2) | py | Runtime Error | 289 | 22764 | 436 | n, m = map(int, input().split())
l = []
for _ in range(m):
a, b = map(int, input().split())
l.append((a, b))
l.sort()
a =[[l[0][0],l[0][1]]]
cnt = 0
num = 1
for i in range(1, m):
if l[i][0] in a[cnt] and l[i][1] not in a[cnt]:
a[cnt].append(l[i][1])
num += 1
elif l[i][1] in a[cnt] and l... | Traceback (most recent call last):
File "/tmp/tmpipri7ch7/tmpvrj2q58d.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s533934356 | p02536 | u243714267 | 1601174678 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9072 | 1594 | class UnionFind():
# 作りたい要素数nで初期化
# 使用するインスタンス変数の初期化
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
# ノードxのrootノードを見つける
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
... | Traceback (most recent call last):
File "/tmp/tmpslwc3dgx/tmprozelnt1.py", line 48, in <module>
uni = UnionFind(n)
^
NameError: name 'n' is not defined
| |
s228063895 | p02536 | u813993459 | 1601174623 | Python | Python (3.8.2) | py | Runtime Error | 352 | 46752 | 331 | import numpy as np
n, m =list(map(int,input().split()))
x=np.array([list(map(int,input().split())) for i in range(m)])
data=x
ans=0
add_times = len(np.arange(1,n+1))-len(np.unique(np.array(x)))
while(1):
if len(data)==0:
break
num=[data[0][0]]
data =check_cl(data,num)
ans+=1
print(int(ans-1+... | Traceback (most recent call last):
File "/tmp/tmpsddd0e0w/tmpl69ef4uw.py", line 2, in <module>
n, m =list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s854802261 | p02536 | u615285493 | 1601174613 | Python | PyPy3 (7.3.0) | py | Runtime Error | 202 | 74708 | 2441 | import os
import sys
from io import BytesIO, IOBase
def main():
# sys.setrecursionlimit(10**6)
n, m = getints()
g = [-1] * n
def find(u):
if g[u] < 0:
return u
else:
g[u] = find(u)
return g[u]
def merge(u, v):
u = find(u)
v = fin... | Traceback (most recent call last):
File "/tmp/tmplih97a5r/tmpazn_ynug.py", line 96, in <module>
main()
File "/tmp/tmplih97a5r/tmpazn_ynug.py", line 9, in main
n, m = getints()
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s698272468 | p02536 | u318427318 | 1601174407 | Python | Python (3.8.2) | py | Runtime Error | 129 | 27272 | 350 | #-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
def main():
roads=[]
n,m = map(int,input().split())
roads=[list(map(int,input().split())) for _ in range(m)]
count=0
for i in range(1,n+1):
if roads in i:
continue
else:
count+=1
print(count)
if __... | Traceback (most recent call last):
File "/tmp/tmpnx65x39c/tmpsiak_69u.py", line 19, in <module>
main()
File "/tmp/tmpnx65x39c/tmpsiak_69u.py", line 7, in main
n,m = map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s896371061 | p02536 | u463945054 | 1601174394 | Python | Python (3.8.2) | py | Runtime Error | 199 | 9028 | 223 | N,M = map(int,input().split())
count = 0
t = 1
for t in range(N):
A,B = map(int,input().split())
if t == A or t == B:
count += 0
else:
count += 1
print(count) | Traceback (most recent call last):
File "/tmp/tmptqo937vm/tmpez1exv8r.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s333336421 | p02536 | u750058957 | 1601174377 | Python | Python (3.8.2) | py | Runtime Error | 306 | 23064 | 1538 | 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/tmpk1vg02kb/tmpqglnzlig.py", line 47, in <module>
V, E = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s566868458 | p02536 | u320681122 | 1601174349 | Python | Python (3.8.2) | py | Runtime Error | 145 | 15308 | 482 | from math import factorial
def main():
n, m = map(int, input().split())
a = [0] * m
b = [0] * m
c = [0] * n
for i in range(m):
a[i], b[i] = map(int, input().split())
c[a[i]] = 1
c[b[i]] = 1
sum = factorial(n) / 2 * factorial(n - 2)
if sum <= m:
print... | Traceback (most recent call last):
File "/tmp/tmpdq4csd_q/tmp9aijzswp.py", line 34, in <module>
main()
File "/tmp/tmpdq4csd_q/tmp9aijzswp.py", line 5, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s058082114 | p02536 | u352198227 | 1601174336 | Python | Python (3.8.2) | py | Runtime Error | 240 | 25252 | 1117 | 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:
#print(cities)
#print(lands)
if cities[r[0]-1] == 0:
cities[r[0]-1] = r[0]
lands[cities[r[0... | Traceback (most recent call last):
File "/tmp/tmpc24zfvms/tmp16hyccty.py", line 1, in <module>
a = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s414383781 | p02536 | u950754160 | 1601174335 | Python | PyPy3 (7.3.0) | py | Runtime Error | 259 | 86684 | 633 | x,y=map(int,input().split())
a=[list(map(int,input().split())) for l in range(y)]
M=0
c=0
t=[]
g=[]
g.append(a[0][0])
g.append(a[1][0])
while M<y-1:
if not a[0][M] in t:
t.append(a[0][M])
if not a[1][M] in t:
t.append(a[1][M])
c=c+3
if a[0][M] in t:
i... | Traceback (most recent call last):
File "/tmp/tmpu9_n3c6d/tmpepxyzkk8.py", line 1, in <module>
x,y=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s445064529 | p02536 | u648868410 | 1601174324 | Python | Python (3.8.2) | py | Runtime Error | 230 | 11024 | 1465 |
import sys
sys.setrecursionlimit(10000)
class UnionFindTree:
def __init__(self,size):
"""
size個の集合を作成
負の値は、ルートで集合の個数
正の値は、次の要素
"""
self.table=[-1 for _ in range(size)]
def find(self,x):
"""
グループ番号を取得
"""
# 本質的には、木を上に辿るだけ
# ただし、通常、UnionFindでは経路圧縮を行うのが普通らしい
if self.table[x] < 0:
# 一個上がルートな... | Traceback (most recent call last):
File "/tmp/tmpw13frs3t/tmpdfrr25lg.py", line 56, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s507052760 | p02536 | u266675845 | 1601174314 | Python | Python (3.8.2) | py | Runtime Error | 270 | 17652 | 1384 | 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/tmpz8cnpizh/tmpk0p8s5dx.py", line 48, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s921000930 | p02536 | u306241759 | 1601174282 | Python | PyPy3 (7.3.0) | py | Runtime Error | 324 | 127020 | 814 | def dfs(now_node):
seen[now_node] = True
connect_nodes = graph[now_node]
for node in connect_nodes:
if seen[node] == True:#探索済みだったらスルー
continue
dfs(node)
N, M = map(int, input().split())
#edges = [list(map(int, input().split())) for i in range(M)]
edges = []
for i in range(M):
... | Traceback (most recent call last):
File "/tmp/tmpiediz2kc/tmpmbuehckg.py", line 9, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s715647099 | p02536 | u210545407 | 1601174277 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 30804 | 695 | N, M=map(int, input().split(" "))
graph=[[] for i in range(N)]
for i in range(M):
temp=list(map(lambda x: x-1, map(int, input().split(" "))))
graph[temp[0]].append(temp[1])
graph[temp[1]].append(temp[0])
# print(graph)
seen=[False for i in range(N)]
todo=[]
def seek(graph, current):
seen[current]=True
for ... | Traceback (most recent call last):
File "/tmp/tmpdstr6b8a/tmpkfo_0_t4.py", line 1, in <module>
N, M=map(int, input().split(" "))
^^^^^^^
EOFError: EOF when reading a line
| |
s140691275 | p02536 | u609258687 | 1601174233 | Python | PyPy3 (7.3.0) | py | Runtime Error | 268 | 91164 | 690 | n,m = map(int, input().split())
brdg = []
for _ in range(m):
brdg.append(list(map(int, input().split())))
# 島つくる
for i in range(m):
for j in range(i+1,m):
if brdg[i][0] in brdg[j]:
brdg.append(list(set(brdg[i]+brdg[j])))
brdg.remove(brdg[i])
brdg.remove(brdg[j])
... | Traceback (most recent call last):
File "/tmp/tmpfogrn5j_/tmp7rt00qxe.py", line 1, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s675110527 | p02536 | u210545407 | 1601174229 | Python | Python (3.8.2) | py | Runtime Error | 3952 | 148964 | 685 | N, M=map(int, input().split(" "))
graph=[[] for i in range(N)]
for i in range(M):
temp=list(map(lambda x: x-1, map(int, input().split(" "))))
graph[temp[0]].append(temp[1])
graph[temp[1]].append(temp[0])
print(graph)
seen=[False for i in range(N)]
todo=[]
def seek(graph, current):
seen[current]=True
for ci... | Traceback (most recent call last):
File "/tmp/tmp2okb24ml/tmpkgmskq88.py", line 1, in <module>
N, M=map(int, input().split(" "))
^^^^^^^
EOFError: EOF when reading a line
| |
s674967214 | p02536 | u473172054 | 1601174201 | Python | Python (3.8.2) | py | Runtime Error | 207 | 19560 | 348 | n, m = map(int, input().split())
par = [i for i in range(n)]
connection = [i for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
cur = connection[b]
connection[b] = connection[a]
par[cur] = par[a]
for i in range(n):
num = connection[i]
connection[i] = par[num]
ans = len(set(... | Traceback (most recent call last):
File "/tmp/tmpa2gz0b7m/tmp0x8itcwc.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s887052932 | p02536 | u252828980 | 1601174178 | Python | Python (3.8.2) | py | Runtime Error | 200 | 10668 | 918 | n,m = map(int,input().split())
#L = [list(map(int,input().split())) for i in range(m)]
class Unionfind:
def __init__(self,n):
self.uf = [-1]*n
def find(self,x):
if self.uf[x] < 0:
return x
else:
self.uf[x] = self.find(self.uf[x])
return self.... | Traceback (most recent call last):
File "/tmp/tmpuin_3fuo/tmp6d3mowb3.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s694255985 | p02536 | u359641414 | 1601174169 | Python | Python (3.8.2) | py | Runtime Error | 217 | 16828 | 472 | n, m = map(int, input().split())
a = []
b = []
for i in range(m):
inp = list(map(int,input().split()))
a.append(inp[0])
b.append(inp[1])
f = [[]]
cnt=0
for i in range(m):
flg=0
for j in range(cnt):
if a[i] in f[j]:
f[j].append(b[i])
flg = 1
elif b[i] in f[j]... | Traceback (most recent call last):
File "/tmp/tmp2c0mvi5x/tmptjkto4da.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s911153317 | p02536 | u912330011 | 1601174166 | Python | Python (3.8.2) | py | Runtime Error | 367 | 9572 | 709 | N, M = map(int, input().split())
rootedPoints = set()
points = []
for _ in range(M):
A, B = map(int, input().split())
A -= 1
B -= 1
rootedPoints.add(A)
rootedPoints.add(B)
Aindex = False
Bindex = False
for i, ps in enumerate(points):
if A in ps: Aindex = i
if B in ps: Bindex = i
if Aindex ... | Traceback (most recent call last):
File "/tmp/tmpmxxqk7m1/tmp95m7avdd.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s044400066 | p02536 | u352198227 | 1601174154 | Python | Python (3.8.2) | py | Runtime Error | 236 | 24844 | 1097 | 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:
#print(cities)
#print(lands)
if cities[r[0]-1] == 0:
cities[r[0]-1] = r[0]
lands[r[0]] = [r... | Traceback (most recent call last):
File "/tmp/tmp_cprwrgk/tmpc5al_4g3.py", line 1, in <module>
a = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s561337806 | p02536 | u609258687 | 1601174147 | Python | PyPy3 (7.3.0) | py | Runtime Error | 253 | 86972 | 684 | n,m = map(int, input().split())
brdg = []
for _ in range(m):
brdg.append(list(map(int, input().split())))
# 島つくる
for i in range(m):
for j in range(i+1,m):
if brdg[i][0] in brdg[j]:
brdg.append(list(set(brdg[i]+brdg[j])))
brdg.remove(brdg[i])
brdg.remove(brdg[j])
... | Traceback (most recent call last):
File "/tmp/tmpomd6x9f4/tmp27i7bl7f.py", line 1, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s971624920 | p02536 | u266675845 | 1601174145 | Python | Python (3.8.2) | py | Runtime Error | 272 | 17744 | 1402 | N, M = map(int, input().split())
A = [0 for _ in range(M)]
B = [0 for _ in range(M)]
S = set()
for i in range(M):
A[i] , B[i] = map(int, input().split())
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
... | Traceback (most recent call last):
File "/tmp/tmpcldly18v/tmprf3z4ccr.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s110446094 | p02536 | u310337637 | 1601174132 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 62676 | 2369 | n, m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]
can_stay = []
branch_stay = []
can_flag_a = 0
can_flag_b = 0
branch_node = 0
need_road = 0
can_stay.append(a[0])
can_stay.append(b[0])
for road in range(1, m):
can_flag_a = 0
can_flag_b = 0... | Traceback (most recent call last):
File "/tmp/tmpul6a5t35/tmphuuoh03z.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s638200803 | p02536 | u491916915 | 1601174120 | Python | Python (3.8.2) | py | Runtime Error | 27 | 8980 | 206 | c, r = input("").split(" ")
cityOne, cityTwo = input("").split(" ")
c, r, cityOne, cityTwo = int(c), int(r), int(cityOne), int(cityTwo)
nr = 0
if r %2==0 and != c - 1:
nr += 1
else:
nr+=2
print(nr) | File "/tmp/tmppgeqx8oo/tmpu1cjp22r.py", line 6
if r %2==0 and != c - 1:
^^
SyntaxError: invalid syntax
| |
s638129350 | p02536 | u912330011 | 1601174112 | Python | Python (3.8.2) | py | Runtime Error | 304 | 9736 | 691 | N, M = map(int, input().split())
rootedPoints = set()
points = []
for _ in range(M):
A, B = map(int, input().split())
rootedPoints.add(A)
rootedPoints.add(B)
Aindex = False
Bindex = False
for i, ps in enumerate(points):
if A in ps: Aindex = i
if B in ps: Bindex = i
if Aindex is not False and B... | Traceback (most recent call last):
File "/tmp/tmpyl_ojjkn/tmp7k5i71pt.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s749943408 | p02536 | u320681122 | 1601174077 | Python | Python (3.8.2) | py | Runtime Error | 197 | 17584 | 384 | def main():
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 = [0] * n
for i in range(m):
c[a[i]] = 1
c[b[i]] = 1
count = 0
for i in range(n):
if c[i] == 0:
count +... | Traceback (most recent call last):
File "/tmp/tmpeb3hq1ss/tmpt2hcys5t.py", line 27, in <module>
main()
File "/tmp/tmpeb3hq1ss/tmpt2hcys5t.py", line 2, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s532902522 | p02536 | u894856270 | 1601174055 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 73320 | 310 | N, M = input().split()
N = int(N)
M = int(M)
l = []
l2 = []
for i in range(N):
l.append(i)
for i in range(M):
A, B = input().split()
A = int(A)
B = int(B)
if A in l:
pass
else:
l2.append(l.pop(int(A) - 1))
if B in l:
pass
else:
l2.append(l.pop(int(B) - 1))
print(N - len(l) + 1) | Traceback (most recent call last):
File "/tmp/tmp42ttzo2e/tmpssi6cwq6.py", line 1, in <module>
N, M = input().split()
^^^^^^^
EOFError: EOF when reading a line
| |
s661308310 | p02536 | u364741711 | 1601174036 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9216 | 185 | n,m = map(int,input().split())
cl_c=[]
ans = 0
for i in range(m) :
a,b = map(int,input().split())
cl_c.append(a,b)
if a != 1 :
ans += 1
set(cl_c)
print(n-len(cl_c)+ans) | Traceback (most recent call last):
File "/tmp/tmpf4jom4rl/tmp159nw49x.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s239061132 | p02536 | u319245933 | 1601174014 | Python | Python (3.8.2) | py | Runtime Error | 326 | 19392 | 409 | N,M = map(int, input().split())
seen = [False] * N
def dfs(G, v):
global seen
seen[v] = True
for n_v in G[v]:
if seen[n_v]:
continue
dfs(G, n_v)
G = [[]] * N
for _ in range(M):
a,b = map(int, input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
count = 0
for v i... | Traceback (most recent call last):
File "/tmp/tmpd6obzmk2/tmp21pmletx.py", line 1, in <module>
N,M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s149406753 | p02536 | u415581265 | 1601173998 | Python | Python (3.8.2) | py | Runtime Error | 3070 | 139864 | 204 | n, m = [int(s) for s in input().split(' ')]
c = [False] * n
for i in range(m):
node = input().split(' ')
for j in range(2):
c[int(node[j]) - 1] = True
print(c)
print(c.count(False)) | Traceback (most recent call last):
File "/tmp/tmpf8lq7709/tmp5s245pka.py", line 1, in <module>
n, m = [int(s) for s in input().split(' ')]
^^^^^^^
EOFError: EOF when reading a line
| |
s709817706 | p02536 | u473172054 | 1601173989 | Python | Python (3.8.2) | py | Runtime Error | 203 | 19272 | 369 | n, m = map(int, input().split())
par = [i for i in range(n)]
connection = [i for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
cur = connection[b]
connection[b] = connection[a]
if par[cur] != a:
par[cur] = a
for i in range(n):
num = connection[i]
connection[i] = pa... | Traceback (most recent call last):
File "/tmp/tmpg5k64ik1/tmphe5jjx7v.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s811554798 | p02536 | u210545407 | 1601173962 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 30732 | 592 | N, M=map(int, input().split(" "))
graph=[[] for i in range(N)]
for i in range(M):
temp=list(map(lambda x: x-1, map(int, input().split(" "))))
graph[temp[0]].append(temp[1])
graph[temp[1]].append(temp[0])
seen=[False for i in range(N)]
todo=[]
def seek(graph, current):
seen[current]=True
for city in graph[c... | Traceback (most recent call last):
File "/tmp/tmpy8_k5o0a/tmpo16bwxvn.py", line 1, in <module>
N, M=map(int, input().split(" "))
^^^^^^^
EOFError: EOF when reading a line
| |
s465826031 | p02536 | u635252313 | 1601173952 | Python | Python (3.8.2) | py | Runtime Error | 203 | 12892 | 1376 | 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, ... | Traceback (most recent call last):
File "/tmp/tmps6t5yh1c/tmp5kyhbjuo.py", line 48, in <module>
n, m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s688154606 | p02536 | u491916915 | 1601173918 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9012 | 206 | c, r = input("").split(" ")
cityOne, cityTwo = input("").split(" ")
c, r, cityOne, cityTwo = int(c), int(r), int(cityOne), int(cityTwo)
nr = 0
if r %2!=0 and != c - 1:
nr += 1
else:
nr+=2
print(nr) | File "/tmp/tmpbhnew110/tmpufkhc55l.py", line 6
if r %2!=0 and != c - 1:
^^
SyntaxError: invalid syntax
| |
s521422533 | p02536 | u320681122 | 1601173892 | Python | Python (3.8.2) | py | Runtime Error | 187 | 17576 | 501 | from math import factorial
def main():
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 = [0] * n
for i in range(m):
c[a[i]] = 1
c[b[i]] = 1
sum = factorial(n) / 2 * factorial(n - 2)
if sum ... | Traceback (most recent call last):
File "/tmp/tmpkau344j5/tmp407c145k.py", line 35, in <module>
main()
File "/tmp/tmpkau344j5/tmp407c145k.py", line 5, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s732402993 | p02536 | u415581265 | 1601173857 | Python | Python (3.8.2) | py | Runtime Error | 5702 | 139852 | 225 | n, m = [int(s) for s in input().split(' ')]
c = [False] * n
print(c)
for i in range(m):
node = input().split(' ')
for j in range(2):
c[int(node[j]) - 1] = True
print(c)
print(c)
print(c.count(False))
| Traceback (most recent call last):
File "/tmp/tmpoaatfuu5/tmp3_0gd324.py", line 1, in <module>
n, m = [int(s) for s in input().split(' ')]
^^^^^^^
EOFError: EOF when reading a line
| |
s432847761 | p02536 | u750058957 | 1601173856 | Python | Python (3.8.2) | py | Runtime Error | 313 | 39216 | 528 | N,M = map(int, input().split())
G = [[] for i in range(N)]
for v in range(M):
for w, c in enumerate(map(lambda x: int(x)-1, input().split())):
if c != -1:
G[v].append((w, c))
from heapq import heappush, heappop, heapify
used = [0]*N
que = [(c, w) for w, c in G[0]]
used[0] = 1
heapify(que)
ans... | Traceback (most recent call last):
File "/tmp/tmpicjo_j6k/tmp3cqf0tzl.py", line 1, in <module>
N,M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s581519334 | p02536 | u881675205 | 1601173850 | Python | PyPy3 (7.3.0) | py | Runtime Error | 381 | 107732 | 627 | def s(way):
global w
global wc
for i in way:
c[i] = 1
if wc[i] == 0:
wc[i] =1
for j in w[i]:
c[j]=1
for j in w[i]:
s(w[j])
n,m = map(int,input().split())
a = [0 for i in range(m)]
b = [0 for i in range(m)]
w = [[] for i i... | Traceback (most recent call last):
File "/tmp/tmp5x39gtzd/tmpr30l72aw.py", line 15, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s247066658 | p02536 | u912330011 | 1601173836 | Python | Python (3.8.2) | py | Runtime Error | 1261 | 32156 | 632 | N, M = map(int, input().split())
rootedPoints = set()
points = []
for _ in range(M):
A, B = map(int, input().split())
rootedPoints.add(A)
rootedPoints.add(B)
Aindex = False
Bindex = False
for i, ps in enumerate(points):
if A in ps: Aindex = i
if B in ps: Bindex = i
if Aindex is False and Bindex ... | Traceback (most recent call last):
File "/tmp/tmpa_6eg5m3/tmpp9lqc99g.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s323906526 | p02536 | u352198227 | 1601173798 | Python | Python (3.8.2) | py | Runtime Error | 246 | 24836 | 1051 | 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:
#print(cities)
#print(lands)
if cities[r[0]-1] == 0:
cities[r[0]-1] = r[0]
lands[r[0]] = [r... | Traceback (most recent call last):
File "/tmp/tmpr3iln61b/tmpskmt5h6y.py", line 1, in <module>
a = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s415571909 | p02536 | u016843859 | 1601173787 | Python | Python (3.8.2) | py | Runtime Error | 468 | 44684 | 412 | from collections import defaultdict
N,M=map(int,input().split())
AB=list()
memo=[False]*N
G=defaultdict(set)
def dfs(i):
memo[i]=True
for j in G[i]:
if memo[j]==False:
dfs(j)
count=0
for i in range(M):
AB=list(map(int,input().split()))
G[AB[1]-1].add(AB[0]-1)
G[AB[0]-1].add(AB[1]... | Traceback (most recent call last):
File "/tmp/tmp57gy2pz9/tmpccr8z3an.py", line 2, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s942244699 | p02536 | u006728642 | 1601173786 | Python | Python (3.8.2) | py | Runtime Error | 231 | 31652 | 680 | N,M = map(int,input().split())
cityList = set()
loadList = []
for i in range(M):
loadList.append(set(list(map(int,input().split()))))
if(i >= 1):
if(len(loadList[0] & loadList[i]) != 0):
loadList[0] = loadList[0] | loadList[i]
del loadList[i]
for i in range(N):
cityList.add(i... | Traceback (most recent call last):
File "/tmp/tmpruw7ambg/tmpgqb89yyt.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s114650136 | p02536 | u491916915 | 1601173781 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9192 | 173 | c, r = input("").split(" ")
cityOne, cityTwo = input("").split(" ")
c, r, cityOne, cityTwo = int(c), int(r), int(cityOne), int(cityTwo)
nr=0
if r!=i-1:
nr+=1
print(nr) | Traceback (most recent call last):
File "/tmp/tmpjrg5w8q2/tmpf2813eqi.py", line 1, in <module>
c, r = input("").split(" ")
^^^^^^^^^
EOFError: EOF when reading a line
| |
s991690769 | p02536 | u944396627 | 1601173772 | Python | Python (3.8.2) | py | Runtime Error | 557 | 36276 | 1115 | class UnionFind:
pairs = {}
def __init__(self, n):
for i in range(n):
self.pairs[i] = i
def set(self, s, t):
if s in self.pairs and self.pairs[s] == s:
self.pairs[s] = t
else:
self.pairs[t] = s
def root(self, x):
if self.pairs[x] == x... | Traceback (most recent call last):
File "/tmp/tmptgx07i6t/tmp_2bnhzai.py", line 50, in <module>
main()
File "/tmp/tmptgx07i6t/tmp_2bnhzai.py", line 26, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s378740769 | p02536 | u674588203 | 1601173757 | Python | Python (3.8.2) | py | Runtime Error | 202 | 13028 | 1358 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | Traceback (most recent call last):
File "/tmp/tmpmx9n3gqg/tmp8nwxupe7.py", line 49, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s013614359 | p02536 | u959139907 | 1601173739 | Python | PyPy3 (7.3.0) | py | Runtime Error | 415 | 85188 | 2168 | # There are N cities numbered 1 through N, and M bidirectional roads numbered 1
# through M. Road i connects City A_i and City B_i.
#
# Snuke can perform the following operation zero or more times:
#
# * Choose two distinct cities that are not directly connected by a road, and
# build a new road between the two c... | Traceback (most recent call last):
File "/tmp/tmpotn5fdva/tmpkd2lmfy1.py", line 26, in <module>
N, M = [int(x) for x in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s291559447 | p02536 | u912330011 | 1601173706 | Python | Python (3.8.2) | py | Runtime Error | 325 | 9656 | 629 | N, M = map(int, input().split())
rootedPoints = set()
points = []
for _ in range(M):
A, B = map(int, input().split())
rootedPoints.add(A)
rootedPoints.add(B)
Aindex = False
Bindex = False
for i, ps in enumerate(points):
if A in ps: Aindex = i
if B in ps: Bindex = i
if Aindex is False and Bindex ... | Traceback (most recent call last):
File "/tmp/tmppgab295l/tmpp_rm1k7_.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s387785406 | p02536 | u753971348 | 1601173700 | Python | Python (3.8.2) | py | Runtime Error | 903 | 12828 | 426 | n, m = map(int,input().split())
allone = list(range(1,n+1))
paths = []
for l in range(m):
tempa,tempb = map(int,input().split())
paths.append([tempa,tempb])
allone.remove(tempa)
allone.remove(tempb)
cou = 0
if allone:
for r in allone:
su = False
for o in paths:
if r == o[0] or r == o[1]:
... | Traceback (most recent call last):
File "/tmp/tmpcx4tkq_b/tmpg46d8se4.py", line 1, in <module>
n, m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s183486329 | p02536 | u881675205 | 1601173644 | Python | PyPy3 (7.3.0) | py | Runtime Error | 398 | 118356 | 600 | def s(way):
global w
global wc
for i in way:
c[i] = 1
if wc[i] == 0:
wc[i] =1
for j in w[i]:
c[j]=1
s(w[j])
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)]
wc = [0 for i i... | Traceback (most recent call last):
File "/tmp/tmp84fski11/tmpiu5oe6cf.py", line 14, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s010245931 | p02536 | u753971348 | 1601173638 | Python | Python (3.8.2) | py | Runtime Error | 803 | 12648 | 378 | n, m = map(int,input().split())
allone = list(range(1,n+1))
paths = []
for l in range(m):
tempa,tempb = map(int,input().split())
paths.append([tempa,tempb])
allone.remove(tempa)
allone.remove(tempb)
cou = 0
for r in allone:
su = False
for o in paths:
if r == o[0] or r == o[1]:
continue
else:
... | Traceback (most recent call last):
File "/tmp/tmprqhkr7km/tmpd3tao0hg.py", line 1, in <module>
n, m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s973657251 | p02536 | u125799132 | 1601173609 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 13676 | 727 | # C
[N, M] = [int(k) for k in input().split()]
dic = {}
L = []
for j in range(M):
[A, B] = [int(i) for i in input().split()]
if A in dic:
if B in dic:
L.pop(dic[B])
for m in dic:
if dic[m] == dic[B]:
dic[m] = dic[A]
else:
L... | Traceback (most recent call last):
File "/tmp/tmp6ow435tb/tmphu44yiav.py", line 2, in <module>
[N, M] = [int(k) for k in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s226038842 | p02536 | u958820283 | 1601173593 | Python | Python (3.8.2) | py | Runtime Error | 299 | 27788 | 390 | n,m = map(int,input().split())
road=[[] for i in range(n)]
for i in range(m):
a,b= map(int,input().split())
road[a-1].append(b-1)
road[b-1].append(a-1)
d=[-1]*n
d[0]=1
f=[-1]*n
count=1
def dfs(src):
d[src]=count
for dst in road[src]:
if d[dst]==-1:
dfs(dst)
for root in range(n):... | Traceback (most recent call last):
File "/tmp/tmp103j4957/tmpzrpyld03.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s110180050 | p02536 | u216728327 | 1601173589 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 73248 | 175 | N,M = map(int, input().split())
c = []
for i in range(N):
A,B = map(int, input().split())
if A not in c:
c.append(A)
if B not in c:
c.append(B)
print(N - len(c)) | Traceback (most recent call last):
File "/tmp/tmpet1zek0n/tmp5r5udq9s.py", line 1, in <module>
N,M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s467138592 | p02536 | u319245933 | 1601173582 | Python | Python (3.8.2) | py | Runtime Error | 325 | 19304 | 392 | N,M = map(int, input().split())
def dfs(G, v):
seen[v] = True
for n_v in G[v]:
if seen[n_v]:
continue
dfs(G, n_v)
seen = [False] * N
G = [[]] * N
for _ in range(M):
a,b = map(int, input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
count = 0
for v in range(N):
i... | Traceback (most recent call last):
File "/tmp/tmpqnllolis/tmp75zm4vwj.py", line 1, in <module>
N,M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s560222301 | p02536 | u352198227 | 1601173572 | Python | Python (3.8.2) | py | Runtime Error | 244 | 24984 | 1022 | 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:
#print(cities)
#print(lands)
if cities[r[0]-1] == 0:
cities[r[0]-1] = r[0]
lands[r[0]] = [r... | Traceback (most recent call last):
File "/tmp/tmp6sgavwvw/tmpitzpkul0.py", line 1, in <module>
a = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s657542570 | p02536 | u881675205 | 1601173550 | Python | PyPy3 (7.3.0) | py | Runtime Error | 357 | 117980 | 600 | def s(way):
global w
global wc
for i in way:
c[i] = 1
if wc[i] == 0:
wc[i] =1
for j in w[i]:
c[j]=1
s(w[i])
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)]
wc = [0 for i i... | Traceback (most recent call last):
File "/tmp/tmprz7e4k7m/tmp2f0oycs3.py", line 14, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s120181607 | p02536 | u884644739 | 1601173504 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 12260 | 765 | from functools import reduce
from collections import defaultdict
def read_int(x):
return int(x)
def dec(x):
return x - 1
def inc(x):
return x + 1
def update_dic(dic,key):
_ = dic[key]
return dic
def read_lst(x):
return list(map(read_int,x.split(' ')))
def read_roads(cnt):
return reduce(lambda x,_: x... | Traceback (most recent call last):
File "/tmp/tmpyhyovjbl/tmp9mmeaw_f.py", line 36, in <module>
main()
File "/tmp/tmpyhyovjbl/tmp9mmeaw_f.py", line 32, in main
[n,m] = read_lst(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s782050895 | p02536 | u306241759 | 1601173456 | Python | Python (3.8.2) | py | Runtime Error | 399 | 38632 | 730 | def dfs(now_node):
seen[now_node] = True
connect_nodes = graph[now_node]
for node in connect_nodes:
if seen[node] == True:#探索済みだったらスルー
continue
dfs(node)
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(M)]
graph = [[] for i in range(N+1)... | Traceback (most recent call last):
File "/tmp/tmp0xwy38s8/tmpbhn9b1bu.py", line 9, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s674081741 | p02536 | u912330011 | 1601173361 | Python | Python (3.8.2) | py | Runtime Error | 308 | 9708 | 608 | N, M = map(int, input().split())
rootedPoints = set()
points = []
for _ in range(M):
A, B = map(int, input().split())
rootedPoints.add(A)
rootedPoints.add(B)
Aindex = False
Bindex = False
for i, ps in enumerate(points):
if A in ps: Aindex = i
if B in ps: Bindex = i
if Aindex==False and Bindex==F... | Traceback (most recent call last):
File "/tmp/tmpp7mdlg3u/tmpybra0p9c.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s474241536 | p02536 | u016843859 | 1601173176 | Python | Python (3.8.2) | py | Runtime Error | 352 | 30864 | 419 | from collections import defaultdict
N,M=map(int,input().split())
AB=list()
memo=[False]*N
G=defaultdict(list)
def dfs(i):
memo[i]=True
for j in G[i]:
if memo[j]==False:
dfs(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].appen... | Traceback (most recent call last):
File "/tmp/tmpl80xinql/tmp4yocw18b.py", line 2, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s268308584 | p02536 | u400982556 | 1601173173 | Python | Python (3.8.2) | py | Runtime Error | 240 | 22916 | 331 | C = []
N, M = map(int,input().split())
for i in range(M):
a,b=input().split()
C.append(int(a))
C.append(int(b))
test = sorted(list(set(C)))
cnt = 1
x =len(test)
for i in range(1,x):
keep = test[i] - test[i-1]
if keep > 1:
keep = test[i+1] - test[i]
if keep > 1:
cnt +=1... | Traceback (most recent call last):
File "/tmp/tmp31mle_dq/tmp0ibgc7av.py", line 2, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s906491122 | p02536 | u797106134 | 1601173172 | Python | Python (3.8.2) | py | Runtime Error | 1255 | 693936 | 593 | import sys
sys.setrecursionlimit(10**7+1)
N,M = map(int,input().split())
ans = N
V = [i for i in range(N)]
inp = []
E =[[] for i in range(N)]
for _ in range(M):
a,b = map(int,input().split())
E[a-1].append(b-1)
E[b-1].append(a-1)
visited = [False for _ in range(N)]
def dfs(v,parent,origin):
visited[v] ... | Traceback (most recent call last):
File "/tmp/tmp7nsbhbjj/tmpaooyb3m4.py", line 4, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s876132788 | p02536 | u149966539 | 1601173172 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 31580 | 1027 | import copy
def check_root(root,num):
if(root[num-1]==num):
return num
else:
ans = check_root(root,root[num-1])
root[ans-1]=ans
return ans
def reset_root(root):
new_root = copy.copy(root)
for i in range(len(root)):
new_root[i] = check_root(root,i)
return new_root
def connect_root(root,A,... | Traceback (most recent call last):
File "/tmp/tmp586d42et/tmpbir7h7fm.py", line 37, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s944485189 | p02536 | u945342410 | 1601173076 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9252 | 790 | n,m = map(int, input().split())
loadList = []
loadList.append(load)
for i in range(m):
loadList.append(list(map(int,input().split())))
cityGroupList = []
cityGroup = []
cityGroup.append(loadList[0][0])
cityGroup.append(loadList[0][1])
cityGroupList.append(cityGroup)
for oneLoad in loadList:
isAdded = False
for ... | Traceback (most recent call last):
File "/tmp/tmpnybaq90l/tmpg9rqh7ow.py", line 1, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s144562093 | p02536 | u265506056 | 1601173055 | Python | PyPy3 (7.3.0) | py | Runtime Error | 128 | 68604 | 1358 | N,K=map(int,input().split())
A=[]
for i in range(N):
a=int(input())
A.append(a)
def segfunc(x, y):
return max(x,y)
ide_ele =0
class SegTree:
def __init__(self, init_val, segfunc, ide_ele):
n = len(init_val)
self.segfunc = segfunc
self.ide_ele = ide_ele
self.num = 1 << (... | Traceback (most recent call last):
File "/tmp/tmpzbtiojdn/tmpqegw1qno.py", line 1, in <module>
N,K=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s021896531 | p02536 | u797106134 | 1601173042 | Python | PyPy3 (7.3.0) | py | Runtime Error | 311 | 108156 | 550 | N,M = map(int,input().split())
ans = N
V = [i for i in range(N)]
inp = []
E =[[] for i in range(N)]
for _ in range(M):
a,b = map(int,input().split())
E[a-1].append(b-1)
E[b-1].append(a-1)
visited = [False for _ in range(N)]
def dfs(v,parent,origin):
visited[v] = True
for e in E[v]:
if e == p... | Traceback (most recent call last):
File "/tmp/tmpn2sdmo3e/tmp0r9atz9h.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s362324134 | p02536 | u023762741 | 1601173041 | Python | Python (3.8.2) | py | Runtime Error | 2252 | 2934128 | 341 | import numpy as np
from scipy.sparse.csgraph import connected_components
N, M = map(int, input().split())
cities = np.zeros((N, N))
for i in range(M):
i1, i2 = map(int, input().split())
cities[i1-1][i2-1] = 1
cities[i2-1][i1-1] = 1
# print(cities)
# print(cities)
n, lasbel = connected_componen... | Traceback (most recent call last):
File "/tmp/tmp4tmqybnh/tmpz7rgtlvp.py", line 5, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s753977172 | p02536 | u907515644 | 1601172995 | Python | Python (3.8.2) | py | Runtime Error | 1161 | 221584 | 249 | import numpy as np
N, M= map(int, input().split())
listA=np.zeros((N,N))
for _ in range(M):
a, b=map(int, input().split())
listA[a-1][b-1]+=1
#print(listA)
a = np.sum(listA, axis=0)
#print(a)
sum=-1
for i in a:
if i == 0:
sum+=1
print(sum) | Traceback (most recent call last):
File "/tmp/tmp8ksh0597/tmpbzie7rwh.py", line 2, in <module>
N, M= map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s530026898 | p02536 | u881675205 | 1601172961 | Python | PyPy3 (7.3.0) | py | Runtime Error | 354 | 88848 | 561 | def s(way):
global w
w2 =[]
for i in way:
c[i] = 1
for j in w[i]:
if c[j] == 0:
w2.append(i)
if not w2 ==[]:
s(w2)
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 fo... | Traceback (most recent call last):
File "/tmp/tmpvhnhqstr/tmpv5q37tej.py", line 13, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s778190750 | p02536 | u149966539 | 1601172939 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 31404 | 996 | import copy
def check_root(root,num):
if(root[num-1]==num):
return num
else:
return check_root(root,root[num-1])
def reset_root(root):
new_root = copy.copy(root)
for i in range(len(root)):
new_root[i] = check_root(root,i)
return new_root
def connect_root(root,A,B):
if root.count(A) < root.c... | Traceback (most recent call last):
File "/tmp/tmpgkl3p098/tmpztb99jer.py", line 36, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s032452730 | p02536 | u171460096 | 1601172929 | Python | Python (3.8.2) | py | Runtime Error | 567 | 62796 | 859 | NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]
xy = [map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]
def my_index(l, x):
if x in l:
return l.index(x)
else:
return -1
group = []
for i in range(M):
index = -1
bo = True
for j in range(len(gro... | Traceback (most recent call last):
File "/tmp/tmploitpo_b/tmp24mnx3dg.py", line 1, in <module>
NM = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s736798304 | p02536 | u455809703 | 1601172919 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 82748 | 343 | def inclusive_index(lst, purpose):
for i, e in enumerate(lst):
if purpose in e: return i
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[a] + lst[b]
del ls... | Traceback (most recent call last):
File "/tmp/tmpw2uh5alu/tmp98xgq_fi.py", line 5, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s621083656 | p02536 | u881675205 | 1601172820 | Python | PyPy3 (7.3.0) | py | Runtime Error | 363 | 88844 | 561 | def s(way):
global w
w2 =[]
for i in way:
c[i] = 1
for j in w[i]:
if c[j] == 0:
w2.append(i)
if not w2 ==[]:
s(w2)
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 fo... | Traceback (most recent call last):
File "/tmp/tmprhz2_pgr/tmpj_al18y_.py", line 13, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s305898336 | p02536 | u480139706 | 1601172819 | Python | PyPy3 (7.3.0) | py | Runtime Error | 167 | 68632 | 869 | import sys
sys.setrecursionlimit(100000)
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_... | Traceback (most recent call last):
File "/tmp/tmp6wmg_8d3/tmpozz2lkak.py", line 45, in <module>
main()
File "/tmp/tmp6wmg_8d3/tmpozz2lkak.py", line 9, in main
n_num, m_num = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s144233741 | p02536 | u401810884 | 1601172816 | Python | Python (3.8.2) | py | Runtime Error | 181 | 12816 | 1169 | import math
n, M= map(int,input().split())
#AB=[]
#N = int(input())
#C = input()
parents = [-1] * n
def find( x):
if parents[x] < 0:
return x
else:
parents[x] = find(parents[x])
return parents[x]
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
if p... | Traceback (most recent call last):
File "/tmp/tmp87xcxb9a/tmpo224eb5l.py", line 3, in <module>
n, M= map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s055620053 | p02536 | u300114786 | 1601172732 | Python | Python (3.8.2) | py | Runtime Error | 317 | 28060 | 1499 | 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/tmpj3mhfgb7/tmpe5ldobo4.py", line 51, in <module>
n,m = map(int, input().split()) # 3個の数字の入力を受け取る
^^^^^^^
EOFError: EOF when reading a line
| |
s360319866 | p02536 | u480139706 | 1601172703 | Python | Python (3.8.2) | py | Runtime Error | 2216 | 189600 | 869 | import sys
sys.setrecursionlimit(100000)
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_... | Traceback (most recent call last):
File "/tmp/tmpi_pm7e8h/tmpol6egr_r.py", line 45, in <module>
main()
File "/tmp/tmpi_pm7e8h/tmpol6egr_r.py", line 9, in main
n_num, m_num = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s923984446 | p02536 | u959139907 | 1601172688 | Python | PyPy3 (7.3.0) | py | Runtime Error | 327 | 90592 | 2232 | # There are N cities numbered 1 through N, and M bidirectional roads numbered 1
# through M. Road i connects City A_i and City B_i.
#
# Snuke can perform the following operation zero or more times:
#
# * Choose two distinct cities that are not directly connected by a road, and
# build a new road between the two c... | Traceback (most recent call last):
File "/tmp/tmpooov_29d/tmpl0q0hibr.py", line 29, in <module>
N, M = [int(x) for x in IN.readline().split()]
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s492581341 | p02536 | u517682687 | 1601172679 | Python | PyPy3 (7.3.0) | py | Runtime Error | 297 | 79980 | 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/tmp2hl4y3m8/tmpqpdcb8hr.py", line 37, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s184500425 | p02536 | u944396627 | 1601172656 | Python | Python (3.8.2) | py | Runtime Error | 372 | 24152 | 772 | class UnionFind:
pairs = {}
def __init__(self, n):
for i in range(n):
self.pairs[i] = i
def set(self, s, t):
if s in self.pairs and self.pairs[s] != s:
self.pairs[t] = s
else:
self.pairs[s] = t
def root(self, x):
if self.pairs[x] == x... | Traceback (most recent call last):
File "/tmp/tmpfw8xyq43/tmp64m96leb.py", line 34, in <module>
main()
File "/tmp/tmpfw8xyq43/tmp64m96leb.py", line 20, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s143050792 | p02536 | u352198227 | 1601172652 | Python | Python (3.8.2) | py | Runtime Error | 251 | 24996 | 727 | 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/tmp9b_kroke/tmpcnn8rrae.py", line 1, in <module>
a = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s759715802 | p02536 | u881675205 | 1601172638 | Python | PyPy3 (7.3.0) | py | Runtime Error | 336 | 88256 | 555 | def s(way):
global w
w2 =[]
for i in way:
for j in w[i]:
if c[j] == 0:
w2.append(i)
c[i] = 1
if not w2 ==[]:
s(w2)
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 for i in... | Traceback (most recent call last):
File "/tmp/tmpr6cofaqf/tmpym1kxyat.py", line 15, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s091612125 | p02536 | u865383026 | 1601172630 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 70816 | 630 | from sys import setrecursionlimit
def Search(n):
L[n-1] = 1
for i in R[n]:
if L[i-1] == 0:
Search(i)
setrecursionlimit(200000)
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] = ... | Traceback (most recent call last):
File "/tmp/tmpyk306uqc/tmp_esurdqx.py", line 10, 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.