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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s224088982 | p02573 | u102655885 | 1598746099 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9076 | 2842 | # UnionFind
# 配列で、子のID番目:(親のID), 親のID番目:(その塊の-サイズ)
# Union Findを使う
class UnionFind:
def __init__(self, size):
self.parent_indexes = [-1] * size
def find_parent(self, n):
# print(self.parent_indexes[n])
if self.parent_indexes[n] < 0:
return n
# print('hewe')
... | File "/tmp/tmpz7xp7mjl/tmp1qlvn203.py", line 44
class UnionFind:
IndentationError: expected an indented block after function definition on line 39
| |
s094214977 | p02573 | u102655885 | 1598746065 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9416 | 261 | # from collections import defaultdict
from collections import deque
n, m = map(lambda x: int(x), input().split())
uf = UnionFind(n)
for _ in range(m):
a, b = map(lambda x: int(x), input().split())
uf.union(a-1, b-1)
print(-min(uf.parent_indexes)) | Traceback (most recent call last):
File "/tmp/tmpmu5we4dp/tmpm9t4wwnc.py", line 3, in <module>
n, m = map(lambda x: int(x), input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s747601916 | p02573 | u361464773 | 1598745833 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 87760 | 613 | from collections import defaultdict
s = input().split()
n = int(s[0])
m = int(s[1])
graph = defaultdict(set)
for i in range(m):
s = input().split(" ")
graph[int(s[0])].add(int(s[1]))
graph[int(s[1])].add(int(s[0]))
visited = [False] * (n+1)
def dfs(root):
visited[root] = True
for child in graph[ro... | Traceback (most recent call last):
File "/tmp/tmpbmpu4hic/tmp1xtp5al5.py", line 2, in <module>
s = input().split()
^^^^^^^
EOFError: EOF when reading a line
| |
s241609339 | p02573 | u361464773 | 1598745643 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 59964 | 620 | from collections import defaultdict
s = input().split()
n = int(s[0])
m = int(s[1])
graph = defaultdict(list)
for i in range(m):
s = input().split(" ")
graph[int(s[0])].append(int(s[1]))
graph[int(s[1])].append(int(s[0]))
visited = [False] * (n+1)
def dfs(root):
visited[root] = True
for child in g... | Traceback (most recent call last):
File "/tmp/tmpy40w5fqh/tmpj90hcei4.py", line 2, in <module>
s = input().split()
^^^^^^^
EOFError: EOF when reading a line
| |
s603057443 | p02573 | u628285938 | 1598743339 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 77400 | 285 | N, M = map(int,input().split())
sets = list()
for i in range(M):
s, t = map(int,input().split())
for st in sets:
if s in st or t in st:
st.add(s)
st.add(t)
break
sets.append({s,t})
ans = max([len(st) for st in sets])
print(ans) | Traceback (most recent call last):
File "/tmp/tmpyftvzz1h/tmppac3foy4.py", line 1, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s240226121 | p02573 | u272525952 | 1598743200 | Python | Python (3.8.2) | py | Runtime Error | 481 | 40376 | 371 | import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
if par[x]==x:
return x
else:
par[x]=find(par[x])
for _ in range(m):
a,b=map(int,input().split())
A=find(a)
B=find(b)
par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
l.append(find(... | Traceback (most recent call last):
File "/tmp/tmpz8is17dt/tmpdpd5di6a.py", line 2, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s357406072 | p02573 | u628285938 | 1598743176 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 77292 | 369 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 30 01:08:52 2020
@author: liang
"""
N, M = map(int,input().split())
sets = list()
for i in range(M):
s, t = map(int,input().split())
for st in sets:
if s in st or t in st:
st.add(s)
st.add(t)
break
sets.append({s,t}... | Traceback (most recent call last):
File "/tmp/tmpbl1z0l3e/tmpebi7iuhc.py", line 7, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s256323193 | p02573 | u272525952 | 1598743153 | Python | PyPy3 (7.3.0) | py | Runtime Error | 303 | 122228 | 371 | import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
if par[x]==x:
return x
else:
par[x]=find(par[x])
for _ in range(m):
a,b=map(int,input().split())
A=find(a)
B=find(b)
par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
l.append(find(... | Traceback (most recent call last):
File "/tmp/tmpqk4ez4rw/tmpvzrt6p8m.py", line 2, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s037618416 | p02573 | u103136263 | 1598743128 | Python | Python (3.8.2) | py | Runtime Error | 549 | 12868 | 6351 | # /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisec... | Traceback (most recent call last):
File "/tmp/tmpm_9dnoi8/tmpl74pxx7p.py", line 6, in <module>
from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/root/miniconda3/envs/sandbox-runtime/lib/python3.11/fractions.py)
| |
s318263825 | p02573 | u628285938 | 1598743116 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 77428 | 369 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 30 01:08:52 2020
@author: liang
"""
N, M = map(int,input().split())
sets = list()
for i in range(M):
s, t = map(int,input().split())
for st in sets:
if s in st or t in st:
st.add(s)
st.add(t)
break
sets.append({s,t}... | Traceback (most recent call last):
File "/tmp/tmpcdifyufg/tmp_us4aqp2.py", line 7, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s262402855 | p02573 | u673101577 | 1598743029 | Python | Python (3.8.2) | py | Runtime Error | 2219 | 407864 | 934 | from sys import stdin
# from pprint import pprint
# import math
# import collections
# n = stdin.readline().rstrip()
# n = int(n)
n, m = [int(x) for x in stdin.readline().rstrip().split()]
# a = [int(x) for x in l]
d = [stdin.readline().rstrip().split() for _ in range(m)]
d = [tuple(map(int, x)) for x in d]
# most... | Traceback (most recent call last):
File "/tmp/tmpf_nt904g/tmpxhcw0ckd.py", line 10, in <module>
n, m = [int(x) for x in stdin.readline().rstrip().split()]
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s997357708 | p02573 | u103136263 | 1598742989 | Python | Python (3.8.2) | py | Runtime Error | 601 | 12700 | 6347 | # /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisec... | Traceback (most recent call last):
File "/tmp/tmp031v_bbd/tmpkax50300.py", line 6, in <module>
from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/root/miniconda3/envs/sandbox-runtime/lib/python3.11/fractions.py)
| |
s522033414 | p02573 | u628285938 | 1598742966 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 77456 | 369 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 30 01:08:52 2020
@author: liang
"""
N, M = map(int,input().split())
sets = list()
for i in range(M):
s, t = map(int,input().split())
for st in sets:
if s in st or t in st:
st.add(s)
st.add(t)
break
sets.append({s,t}... | Traceback (most recent call last):
File "/tmp/tmp63tepj36/tmplfwfn3q9.py", line 7, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s339458047 | p02573 | u628285938 | 1598742939 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 77416 | 285 | N, M = map(int,input().split())
sets = list()
for i in range(M):
s, t = map(int,input().split())
for st in sets:
if s in st or t in st:
st.add(s)
st.add(t)
break
sets.append({s,t})
ans = max([len(st) for st in sets])
print(ans) | Traceback (most recent call last):
File "/tmp/tmp2qwjhb56/tmpm1p83nu4.py", line 1, in <module>
N, M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s129495785 | p02573 | u818213347 | 1598742926 | Python | Python (3.8.2) | py | Runtime Error | 2370 | 174144 | 613 | n,m = map(int,input().split())
branch = set(tuple(map(int,input().split())) for i in range(m))
print(branch)
que = range(n)
flag = -1
friend = [{0}]
for a,b in branch:
for i in range(len(friend)):
if (a in friend[i]) or (b in friend[i]):
friend[i].add(a)
friend[i].add(b)
... | Traceback (most recent call last):
File "/tmp/tmpgmpzsv23/tmpk0zxwez1.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s420316159 | p02573 | u103136263 | 1598742911 | Python | Python (3.8.2) | py | Runtime Error | 690 | 12864 | 6357 | # /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisec... | Traceback (most recent call last):
File "/tmp/tmpb1x4_prm/tmp9kft4_q3.py", line 6, in <module>
from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/root/miniconda3/envs/sandbox-runtime/lib/python3.11/fractions.py)
| |
s914405836 | p02573 | u319245933 | 1598742607 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9120 | 773 | from collections import Counter
class UnionFindBasic():
"""via https://note.nkmk.me/python-union-find/#_3
"""
def __init__(self, n):
self.parents = list(range(n))
def find(self, x: int) -> int:
if self.parents[x] == x: return x
return self.find(self.parents[x])
def union(s... | File "/tmp/tmp5ahohias/tmp3bble6t7.py", line 25
return
^^^^^^
SyntaxError: 'return' outside function
| |
s229554867 | p02573 | u764066313 | 1598742384 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8944 | 604 | #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
vector<int>v[200005];
int vis[200005];
int dfs(int now){
vis[now]=1;
int num=1... | File "/tmp/tmpqfr19wvj/tmpjri1d_fr.py", line 8
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
s285855629 | p02573 | u764066313 | 1598742263 | Python | Python (3.8.2) | py | Runtime Error | 739 | 44652 | 1181 | n,t = list(map(int,input().split()))
graph = [[] for _ in range(n)]
visited = [0]*n
for _ in range(t):
a,b = list(map(int,input().split()))
a -= 1;b -= 1
graph[a].append(b)
graph[b].append(a)
def dfs(now):
visited[now] = 1
num = 1
for i in graph[now]:
if not visited[i]:
n... | Traceback (most recent call last):
File "/tmp/tmpu9tctckj/tmp8xs7sn2z.py", line 1, in <module>
n,t = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s702520916 | p02573 | u319245933 | 1598741990 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 43124 | 737 | from collections import Counter
class UnionFindBasic():
"""via https://note.nkmk.me/python-union-find/#_3
"""
def __init__(self, n):
self.parents = list(range(n))
def find(self, x):
if self.parents[x] == x: return x
return self.find(self.parents[x])
def union(self, x, y):
... | Traceback (most recent call last):
File "/tmp/tmp0w0uo4m6/tmp34yruxjg.py", line 20, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s528910899 | p02573 | u103136263 | 1598741838 | Python | Python (3.8.2) | py | Runtime Error | 667 | 12748 | 6357 | # /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisec... | Traceback (most recent call last):
File "/tmp/tmplxq0zgbn/tmpj8_rv3b_.py", line 6, in <module>
from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/root/miniconda3/envs/sandbox-runtime/lib/python3.11/fractions.py)
| |
s454649450 | p02573 | u628633224 | 1598741705 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 29004 | 699 | n, m = map(int, input().split())
t = [-1*(i+1) for i in range(n)]
count = 0
for _ in range(m):
a, b = map(lambda x: int(x) - 1, input().split())
if t[a] <= -1 and t[b] <= -1:
count += 1
t[a] = count
t[b] = count
continue
if t[a] > -1 and t[b] > -1 and t[a] != t[b]:
ma... | Traceback (most recent call last):
File "/tmp/tmp9hm85zcb/tmpd2523smn.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s251530453 | p02573 | u933129390 | 1598741604 | Python | Python (3.8.2) | py | Runtime Error | 887 | 48356 | 680 | n, m = map(int, input().split())
tree = [[] for i in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
tree[a].append(b)
tree[b].append(a)
for i in range(n+1):
tree[i] = list(set(tree[i]))
visited = [False for i in range(n+1)]
def add(x, count):
for i in range(len(tree[x])):
... | Traceback (most recent call last):
File "/tmp/tmp08_v3h83/tmpl6fi9sww.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s033784350 | p02573 | u818213347 | 1598741559 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 47364 | 559 | n,m = map(int,input().split())
branch = set(tuple(map(int,input().split())) for i in range(m))
que = range(n)
flag = -1
friend = [{1}]
for a,b in branch:
for i in range(len(friend)):
if (a in friend[i]) or (b in friend[i]):
friend[i].add(a)
friend[i].add(b)
if flag >= 0:... | Traceback (most recent call last):
File "/tmp/tmpn840wduv/tmp_zl0zxf_.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s096037685 | p02573 | u903396129 | 1598741317 | Python | Python (3.8.2) | py | Runtime Error | 1063 | 58680 | 389 | n, m = map(int, input().split())
g = [[False, []] for _ in range(n)]
for _ in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
g[a][1].append(b)
g[b][1].append(a)
def dfs(i):
if g[i][0]:
return 0
v = 1
g[i][0] = True
for j in g[i][1]:
v += dfs(j)
return ... | Traceback (most recent call last):
File "/tmp/tmplklqctx5/tmpitjq4ogr.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s954977333 | p02573 | u658181634 | 1598741305 | Python | Python (3.8.2) | py | Runtime Error | 2212 | 249012 | 289 | """
自分の解答
"""
N, M = list(map(int, input().split(" ")))
R = [set(map(int, input().split(" "))) for i in range(M)]
groups = []
while len(R) > 0:
r = R.pop()
for r_ in R:
if len(r & r_) > 0:
r |= r_
groups.append(r)
print(max(map(len, groups)))
| Traceback (most recent call last):
File "/tmp/tmp88yc7qpq/tmperlzq0ji.py", line 5, in <module>
N, M = list(map(int, input().split(" ")))
^^^^^^^
EOFError: EOF when reading a line
| |
s729470115 | p02573 | u585963734 | 1598741197 | Python | Python (3.8.2) | py | Runtime Error | 1030 | 54980 | 689 | from collections import defaultdict as dd
from collections import deque
import collections as col
d=dd(list)
q=deque([])
N,M=map(int, input().split())
for _ in range(M):
f=0
i,j=map(int, input().split())
if i>j:
i,j=j,i
d[i].append(j)
chk=[0]*N
chk[0]=1
temp=1
a=0
while a<N:
for i in range(... | Traceback (most recent call last):
File "/tmp/tmpgrb_r_zk/tmpg1uu51p_.py", line 7, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s615128932 | p02573 | u818213347 | 1598741184 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 57612 | 560 | n,m = map(int,input().split())
branch = list(tuple(map(int,input().split())) for i in range(m))
que = range(n)
flag = -1
friend = [{1}]
for a,b in branch:
for i in range(len(friend)):
if (a in friend[i]) or (b in friend[i]):
friend[i].add(a)
friend[i].add(b)
if flag >= 0... | Traceback (most recent call last):
File "/tmp/tmpc2q4ymec/tmpmqtxhl4n.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s642300676 | p02573 | u658181634 | 1598741152 | Python | Python (3.8.2) | py | Runtime Error | 2212 | 248856 | 264 | N, M = list(map(int, input().split(" ")))
R = [set(map(int, input().split(" "))) for i in range(M)]
groups = []
while len(R) > 1:
r = R.pop()
for r_ in R:
if len(r & r_) > 0:
r |= r_
groups.append(r)
print(max(map(len, groups)))
| Traceback (most recent call last):
File "/tmp/tmpn23yd35p/tmpr1ygdlao.py", line 1, in <module>
N, M = list(map(int, input().split(" ")))
^^^^^^^
EOFError: EOF when reading a line
| |
s754837337 | p02573 | u818213347 | 1598741112 | Python | Python (3.8.2) | py | Runtime Error | 2058 | 59748 | 574 | n,m = map(int,input().split())
branch = list(tuple(map(int,input().split())) for i in range(m))
que = range(n)
flag = -1
friend = [{1}]
for a,b in branch:
for i in range(len(friend)):
if (a in friend[i]) or (b in friend[i]):
friend[i].add(a)
friend[i].add(b)
if flag >= 0... | Traceback (most recent call last):
File "/tmp/tmpnw4p4afz/tmp1p624q35.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s187495559 | p02573 | u658181634 | 1598741086 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2216 | 439848 | 263 | N, M = list(map(int, input().split(" ")))
R = [set(map(int, input().split(" "))) for i in range(M)]
groups = []
while len(R) > 1:
r = R.pop()
for r_ in R:
if len(r & r_) > 0:
r |= r_
groups.append(r)
print(max(map(len, groups))) | Traceback (most recent call last):
File "/tmp/tmpvpur3rou/tmp1alw6dx7.py", line 1, in <module>
N, M = list(map(int, input().split(" ")))
^^^^^^^
EOFError: EOF when reading a line
| |
s946382364 | p02573 | u585963734 | 1598740978 | Python | Python (3.8.2) | py | Runtime Error | 1023 | 54140 | 654 | from collections import defaultdict as dd
from collections import deque
import collections as col
d=dd(list)
q=deque([])
N,M=map(int, input().split())
for _ in range(M):
f=0
i,j=map(int, input().split())
if i>j:
i,j=j,i
d[i].append(j)
chk=[0]*N
chk[0]=1
temp=1
a=0
while a<N:
for i in range(... | Traceback (most recent call last):
File "/tmp/tmpopqp91ix/tmpyfyo_gcg.py", line 7, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s682440179 | p02573 | u585963734 | 1598740635 | Python | Python (3.8.2) | py | Runtime Error | 890 | 61396 | 612 | from collections import defaultdict as dd
from collections import deque
import collections as col
d=dd(list)
q=deque([])
N,M=map(int, input().split())
for _ in range(M):
f=0
i,j=map(int, input().split())
if i>j:
i,j=j,i
d[i].append(j)
chk=[0]*N
chk[0]=1
temp=1
a=0
while a<N:
for i in range(... | Traceback (most recent call last):
File "/tmp/tmp6l1wud20/tmps2p50pbl.py", line 7, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s620649563 | p02573 | u456936625 | 1598740436 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1424 | 384232 | 2734 | # @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-29 22:53
# @url:https://atcoder.jp/contests/abc177/tasks/abc177_d
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio
BUFSIZE = 8192
BUFSIZE = 8192
class F... | Traceback (most recent call last):
File "/tmp/tmpy7mzmu3d/tmpsi83yrfa.py", line 97, in <module>
main()
File "/tmp/tmpy7mzmu3d/tmpsi83yrfa.py", line 64, in main
n,m=map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s126022978 | p02573 | u498677593 | 1598740377 | Python | PyPy3 (7.3.0) | py | Runtime Error | 87 | 74796 | 270 | from UnionFind import UnionFind as UF
N,M=map(int,input().split())
uf = UF(N)
for i in range(M):
a,b=map(int,input().split())
a-=1
b-=1
uf.union(a,b)
z=0
c=[0]*N
for i in range(N):
p=uf.root(i)
c[p]+=1
if z<c[p]:
z=c[p]
print(z)
| Traceback (most recent call last):
File "/tmp/tmpecy3k5au/tmp4eqcbh5j.py", line 1, in <module>
from UnionFind import UnionFind as UF
ModuleNotFoundError: No module named 'UnionFind'
| |
s718697267 | p02573 | u585963734 | 1598740328 | Python | Python (3.8.2) | py | Runtime Error | 782 | 60612 | 617 | from collections import defaultdict as dd
from collections import deque
import collections as col
d=dd(list)
q=deque([])
N,M=map(int, input().split())
for _ in range(M):
f=0
i,j=map(int, input().split())
if i>j:
i,j=j,i
d[i].append(j)
chk=[0]*N
chk[0]=1
temp=1
a=0
while a<N:
for i in range(... | Traceback (most recent call last):
File "/tmp/tmp0ovytr79/tmpli7uqlb6.py", line 7, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s818427440 | p02573 | u585963734 | 1598740088 | Python | Python (3.8.2) | py | Runtime Error | 644 | 60524 | 578 | from collections import defaultdict as dd
from collections import deque
d=dd(list)
q=deque([])
N,M=map(int, input().split())
for _ in range(M):
f=0
i,j=map(int, input().split())
if i>j:
i,j=j,i
d[i].append(j)
chk=[0]*N
chk[0]=1
temp=1
a=0
while a<N:
for i in range(len(d[temp])):
chk... | Traceback (most recent call last):
File "/tmp/tmpds5dwrwm/tmporhx04i1.py", line 6, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s130785111 | p02573 | u456936625 | 1598739690 | Python | PyPy3 (7.3.0) | py | Runtime Error | 832 | 196528 | 2734 | # @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-29 22:53
# @url:https://atcoder.jp/contests/abc177/tasks/abc177_d
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio
BUFSIZE = 8192
BUFSIZE = 8192
class F... | Traceback (most recent call last):
File "/tmp/tmphfnpx0hq/tmpgwodtr0l.py", line 97, in <module>
main()
File "/tmp/tmphfnpx0hq/tmpgwodtr0l.py", line 64, in main
n,m=map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s388827013 | p02573 | u106118504 | 1598739457 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 83472 | 593 | N,M = map(int,input().split())
if M == 0:
print(1)
else:
F = list((sorted(map(int,input().split()))) for i in range(M))
L = list(map(list,set(map(tuple,F))))
team = []
for i in range(len(L)):
if i == 0:
team.append(L[i])
else:
for j in range(len(team)):
if L[i][0] in team[j] and... | Traceback (most recent call last):
File "/tmp/tmpnik59b4w/tmp5ap_vj9s.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s096279864 | p02573 | u691332320 | 1598739200 | Python | Python (3.8.2) | py | Runtime Error | 853 | 18544 | 684 |
class UnionFind:
def __init__(self, n):
self.parent = [-1 for _ in range(n)]
def find(self, s):
if self.parent[s] < 0:
return s
self.parent[s] = self.find(self.parent[s])
return self.parent[s]
def union(self, a, b):
a, b = self.find(a), self.find(b)
... | Traceback (most recent call last):
File "/tmp/tmpbkklghn3/tmpajly97z_.py", line 22, in <module>
n, m = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s014775370 | p02573 | u127499732 | 1598739199 | Python | Python (3.8.2) | py | Runtime Error | 1721 | 57248 | 498 | def main():
n, m, *ab, = map(int, open(0).read().split())
p = [-1] * (n + 1)
def f(x):
if p[x] < 0:
return x
else:
return f(p[x])
ans = -1
for i, j in zip(ab[::2], ab[1::2]):
if i > j:
i, j = j, i
pi, pj = f(i), f(j)
if ... | Traceback (most recent call last):
File "/tmp/tmpga9_f6c0/tmp3m7106l7.py", line 29, in <module>
main()
File "/tmp/tmpga9_f6c0/tmp3m7106l7.py", line 2, in main
n, m, *ab, = map(int, open(0).read().split())
^^^^^^^^^^
ValueError: not enough values to unpack (expected at least 2, got 0)
| |
s064760235 | p02573 | u970348538 | 1598739117 | Python | Python (3.8.2) | py | Runtime Error | 970 | 111848 | 499 | def search(x, num):
nodes.remove(x)
# for y in edge[x]:
# edge[y].discard(x)
# for y in list(edge[x]):
for y in edge[x]:
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x ... | Traceback (most recent call last):
File "/tmp/tmpg_y5tehk/tmpz7sgk62d.py", line 11, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s140442973 | p02573 | u106118504 | 1598739085 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 162076 | 601 | N,M = map(int,input().split())
if M == 0:
print(1)
else:
F = list((sorted(map(int,input().split()))) for i in range(M))
L = sorted(list(map(list,set(map(tuple,F)))))
team = []
for i in range(len(L)):
if i == 0:
team.append(L[i])
else:
for j in range(len(team)):
if L[i][0] in tea... | Traceback (most recent call last):
File "/tmp/tmpjvxwmqdh/tmpnbx98qoz.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s955721144 | p02573 | u970348538 | 1598739006 | Python | Python (3.8.2) | py | Runtime Error | 931 | 111780 | 475 | def search(x, num):
nodes.remove(x)
# for y in edge[x]:
# edge[y].discard(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x in d:
edge[x[0]].add... | Traceback (most recent call last):
File "/tmp/tmp8d5y_l2v/tmpjuchf9b5.py", line 10, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s877665439 | p02573 | u970348538 | 1598738966 | Python | Python (3.8.2) | py | Runtime Error | 1001 | 111980 | 471 | def search(x, num):
nodes.remove(x)
for y in edge[x]:
edge[y].discard(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x in d:
edge[x[0]].add(x[1... | Traceback (most recent call last):
File "/tmp/tmp0x9p4oku/tmpu7pgbcxg.py", line 10, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s479698028 | p02573 | u760961723 | 1598738892 | Python | Python (3.8.2) | py | Runtime Error | 769 | 254696 | 1572 | import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
#input = lambda: sys.stdin.readline().strip()
#◆◆◆◆◆◆提出前には上の#を削除する◆◆◆◆◆◆
NI = lambda: int(input())
NMI = lamb... | Traceback (most recent call last):
File "/tmp/tmp6fcqm9sk/tmpbro5i3ni.py", line 68, in <module>
main()
File "/tmp/tmp6fcqm9sk/tmpbro5i3ni.py", line 21, in main
N, M = NMI()
^^^^^
File "/tmp/tmp6fcqm9sk/tmpbro5i3ni.py", line 15, in <lambda>
NMI = lambda: map(int, input().split())
... | |
s269702140 | p02573 | u898868742 | 1598738780 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 98684 | 669 | n,m=map(int,input().split())
val=1
dic={}
friends={1:[]}
for i in range(n+1):
dic[i]=0
a,b=map(int,input().split())
friends[1].append(a)
friends[1].append(b)
for i in range(m-1):
a,b=map(int,input().split())
flag=0
for j in list(friends.keys()):
if a in friends[j] and (b not in friends[j]):
... | Traceback (most recent call last):
File "/tmp/tmpeemg5b4i/tmpqo5mukhd.py", line 1, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s270626690 | p02573 | u513434790 | 1598738742 | Python | Python (3.8.2) | py | Runtime Error | 697 | 15388 | 552 | N, M = map(int, input().split())
UF = [-1] * (N+1)
def find(x):
global UF
if UF[x] == -1:
return x
else:
UF[x] = find(UF[x])
return UF[x]
def union(x,y):
global UF
xx = find(x)
yy = find(y)
if UF[x] == UF[y] == -1:
UF[y] = xx
return
elif xx == yy:
... | Traceback (most recent call last):
File "/tmp/tmpavt74k2k/tmp8nh42k7x.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s110217552 | p02573 | u456936625 | 1598738406 | Python | PyPy3 (7.3.0) | py | Runtime Error | 563 | 197104 | 2644 | # @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-29 22:53
# @url:https://atcoder.jp/contests/abc177/tasks/abc177_d
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio
BUFSIZE = 8192
BUFSIZE = 8192
class F... | Traceback (most recent call last):
File "/tmp/tmps8fzxwgj/tmpz092xao4.py", line 92, in <module>
main()
File "/tmp/tmps8fzxwgj/tmpz092xao4.py", line 64, in main
n,m=map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s238350135 | p02573 | u273507800 | 1598738405 | Python | Python (3.8.2) | py | Runtime Error | 448 | 12676 | 474 | N, M = map(int, input().strip().split())
pg = [-1] * (N + 1) # person's group
gpc = [] # group person count
gc = 0 # group count
for _ in range(M):
Ai, Bj = map(int, input().strip().split())
if pg[Ai] > -1 and pg[Bj] > -1:
continue
if pg[Ai] < 0 and pg[Bj] < 0:
pg[Ai] = gc
pg[Bj] = gc
gpc.append(2)
... | Traceback (most recent call last):
File "/tmp/tmpi4k6kgg4/tmprin3f2xe.py", line 1, in <module>
N, M = map(int, input().strip().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s996695276 | p02573 | u335406314 | 1598738263 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 66648 | 442 | N,M=map(int,input().split())
if M==0:
print(len(N))
else:
A = [list(map(int,input().split())) for _ in range(M)]
frends=[{*A[0]}]
for (a,b) in A:
flg = True
for ifre in frends:
if (a in ifre)^(b in ifre):
ifre.add(a)
ifre.add(b)
... | Traceback (most recent call last):
File "/tmp/tmped1kg4r1/tmpr7tkopha.py", line 1, in <module>
N,M=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s791277105 | p02573 | u127499732 | 1598738201 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2212 | 241340 | 812 | def main():
n, m, *ab, = map(int, open(0).read().split())
f = [set() for _ in range(n)]
for i, j in zip(ab[::2], ab[1::2]):
f[i].add(j)
f[j].add(i)
group = []
i = 1
g = {i}
nx = {i}
checked = set()
m = 0
ans = 0
while i <= n:
if i in checked:
... | Traceback (most recent call last):
File "/tmp/tmp7bdcd3yc/tmpygz8lo6y.py", line 44, in <module>
main()
File "/tmp/tmp7bdcd3yc/tmpygz8lo6y.py", line 2, in main
n, m, *ab, = map(int, open(0).read().split())
^^^^^^^^^^
ValueError: not enough values to unpack (expected at least 2, got 0)
| |
s549010861 | p02573 | u942051624 | 1598738138 | Python | PyPy3 (7.3.0) | py | Runtime Error | 749 | 178856 | 436 |
N,M=map(int, input().split())
l=[[]for j in range(N)]
field=[True]*N
for i in range(M):
a,b=map(int,input().split())
l[a-1].append(b-1)
l[b-1].append(a-1)
for i in range(N):
l[i]=list(set(l[i]))
def dfs(x):
conn=1
field[x]=False
for j in range(len(l[x])):
if field[l[x][j]]:
... | Traceback (most recent call last):
File "/tmp/tmpzz9cln6g/tmpkcgk48if.py", line 2, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s025451698 | p02573 | u583285098 | 1598737878 | Python | Python (3.8.2) | py | Runtime Error | 564 | 32476 | 514 | import collections
n, m = map(int, input().split())
if m == 0:
print(1)
exit()
if m == 1:
print(2)
exit()
ids = {i: 0 for i in range(1, n+1)}
id = 1
for _ in range(m):
a, b = map(int, input().split())
if ids[a] == 0 and ids[b] != 0:
ids[a] = ids[b]
elif ids[a] != 0 and ids[b] == 0:
... | Traceback (most recent call last):
File "/tmp/tmp3vy1cdgy/tmphuvbg1f2.py", line 3, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s640485244 | p02573 | u970348538 | 1598737757 | Python | Python (3.8.2) | py | Runtime Error | 1042 | 112048 | 471 | def search(x, num):
nodes.remove(x)
for y in edge[x]:
edge[y].discard(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x in d:
edge[x[0]].add(x[1... | Traceback (most recent call last):
File "/tmp/tmpakk3ionv/tmp4nylcota.py", line 10, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s275528010 | p02573 | u942051624 | 1598737647 | Python | PyPy3 (7.3.0) | py | Runtime Error | 612 | 112592 | 427 |
N,M=map(int, input().split())
l=[[]for j in range(N)]
field=[True]*N
for i in range(M):
a,b=map(int,input().split())
l[min(a,b)-1].append(max(a,b)-1)
for i in range(N):
l[i]=list(set(l[i]))
def dfs(x):
conn=1
field[x]=False
for j in range(len(l[x])):
if field[l[x][j]]:
conn... | Traceback (most recent call last):
File "/tmp/tmpumiohix8/tmp1tch6qfn.py", line 2, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s433234368 | p02573 | u727717182 | 1598737588 | Python | Python (3.8.2) | py | Runtime Error | 349 | 45596 | 761 | import sys
parents = [-1] * 20000
def main():
input = sys.stdin.readline
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
A,B = AB[i]
A = A - 1
B = B - 1
union(A,B)
ans = 1
for i in range(20000):
... | Traceback (most recent call last):
File "/tmp/tmpc18l9xu3/tmp9_6hawhf.py", line 53, in <module>
main()
File "/tmp/tmpc18l9xu3/tmp9_6hawhf.py", line 9, in main
N,M = map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s518168370 | p02573 | u970348538 | 1598737525 | Python | Python (3.8.2) | py | Runtime Error | 1104 | 123804 | 572 | def search(x, num):
nodes.remove(x)
for y in edge[x]:
edge[y].discard(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = {}
for x in d:
if x[0] in edge:
edge[x[0]].add(x[1... | Traceback (most recent call last):
File "/tmp/tmpdbwfip8m/tmpn5fo49vd.py", line 10, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s134846474 | p02573 | u602740328 | 1598737480 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 32484 | 654 | class UFTree():
def __init__(self,n):
self.N = n
self.parent = {i:i for i in range(1,n+1)}
def root(self,n):
if self.parent[n]==n: return n
else:
self.parent[n] = self.root(self.parent[n])
return self.parent[n]
def unite(self,x,y):
rx,ry = self.root(x), self.root(y)
... | Traceback (most recent call last):
File "/tmp/tmp1zn7nrwc/tmpy9slp_z4.py", line 21, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s405945861 | p02573 | u335406314 | 1598737473 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 66424 | 368 | (N,M),*A = [[*map(int,t.split())] for t in open(0)]
frends=[{*A[0]}]
for (a,b) in A:
flg = True
for ifre in frends:
if (a not in ifre)&(b not in ifre):
continue
else:
ifre.add(a)
ifre.add(b)
flg=False
break
if flg:
frends.ap... | Traceback (most recent call last):
File "/tmp/tmpqpwjbz3k/tmpoi3utoom.py", line 1, in <module>
(N,M),*A = [[*map(int,t.split())] for t in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s779570077 | p02573 | u727717182 | 1598737188 | Python | Python (3.8.2) | py | Runtime Error | 261 | 9080 | 719 | import sys
parents = [-1] * 20000
def main():
input = sys.stdin.readline
N,M = map(int,input().split())
for _ in range(M):
A,B = map(int,input().split())
A = A - 1
B = B - 1
union(A,B)
ans = 1
for i in range(20000):
ans = max(ans,size(i))
print(a... | Traceback (most recent call last):
File "/tmp/tmpx_egnuiy/tmp9tswrfyd.py", line 51, in <module>
main()
File "/tmp/tmpx_egnuiy/tmp9tswrfyd.py", line 9, in main
N,M = map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s612258859 | p02573 | u002663801 | 1598737135 | Python | PyPy3 (7.3.0) | py | Runtime Error | 432 | 163048 | 1189 | n,m = list(map(int,input().split()))
dic = dict()
dicSet = set()
dicList = dict()
count = 0
countList= set()
ans = 0
for i in range(m):
a,b = list(map(int,input().split()))
if not(a in dicSet) and not(b in dicSet):
dic[count] = set()
dic[count].add(a)
dic[count].add(b)
dicList... | Traceback (most recent call last):
File "/tmp/tmpp724tkwp/tmp6uisgrom.py", line 1, in <module>
n,m = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s819017592 | p02573 | u231570044 | 1598737043 | Python | Python (3.8.2) | py | Runtime Error | 956 | 225144 | 659 | import array
#import random
import sys
#N, M = 100000, 100000
N, M = list(map(int, input().split()))
R = [[] for _ in range(N+1)]
sys.setrecursionlimit(200000)
def grp(R, i, S):
S[i] = True
ret = 1
for j in range(len(R[i])):
if S[ R[i][j] ]: continue
ret += grp(R, R[i][j], S)
return re... | Traceback (most recent call last):
File "/tmp/tmpo9g009__/tmp4wtaflqi.py", line 6, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s782782260 | p02573 | u347502437 | 1598736982 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9152 | 431 | N, M = map(int, input().split())
if M == 0:
print(1)
else:
D = {}
count = 0
friends = []
while count < M:
A, B = map(int,input().split())
Info += {A,B}
count += 1
for i in Info:
k = Info.index(i)
for j in Info:
if len(i.intersection(j)) != 0:
... | Traceback (most recent call last):
File "/tmp/tmpye386zqo/tmp0esexgkt.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s138309515 | p02573 | u727717182 | 1598736965 | Python | PyPy3 (7.3.0) | py | Runtime Error | 154 | 70112 | 717 | import sys
parents = [-1] * 20000
def main():
input = sys.stdin.readline
N,M = map(int,input().split())
for _ in range(M):
A,B = map(int,input().split())
A = A - 1
B = B - 1
union(A,B)
ans = 1
for i in range(20000):
ans = max(ans,size(i))
print(a... | Traceback (most recent call last):
File "/tmp/tmpas884nfs/tmpee_5s8me.py", line 51, in <module>
main()
File "/tmp/tmpas884nfs/tmpee_5s8me.py", line 9, in main
N,M = map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s051425830 | p02573 | u089376182 | 1598736938 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 58088 | 449 | n,m = map(int, input().split())
friends = {i:[] for i in range(1, n+1)}
for _ in range(m):
a,b = map(int, input().split())
friends[a].append(b)
friends[b].append(a)
seen = []
def dfs(n):
if n not in seen:
seen.append(n)
for f_i in friends[n]:
if f_i in seen:
continue
else:
... | Traceback (most recent call last):
File "/tmp/tmpdxg5j312/tmpx88exfda.py", line 1, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s267844419 | p02573 | u627600101 | 1598736891 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9156 | 975 | from math import gcd
# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]
primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
if sgn[k] == -1:
primenum.append(k)
add = k*k
ok = k
while ok**2 <= ... | Traceback (most recent call last):
File "/tmp/tmpltm89fxp/tmpqm9c6ik1.py", line 4, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s739213252 | p02573 | u727717182 | 1598736803 | Python | Python (3.8.2) | py | Runtime Error | 242 | 9188 | 713 | import sys
parents = [-1] * 20000
def main():
input = sys.stdin.readline
N,M = map(int,input().split())
for _ in range(M):
A,B = map(int,input().split())
A = A - 1
B = B - 1
union(A,B)
ans = 1
for i in range(N):
ans = max(ans,size(i))
print(ans)
... | Traceback (most recent call last):
File "/tmp/tmpn636yt9h/tmpigtyrz7p.py", line 51, in <module>
main()
File "/tmp/tmpn636yt9h/tmpigtyrz7p.py", line 9, in main
N,M = map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s538651329 | p02573 | u411923565 | 1598736795 | Python | Python (3.8.2) | py | Runtime Error | 707 | 38148 | 561 | N,M = map(int,input().split())
lis = [[] for _ in range(N+1)]
for i in range(M):
A,B = map(int,input().split())
A,B = min(A,B),max(A,B)
lis[A].append(B)
cnt = 0
seen = [False]*(N+1)
def dfs(v,graph):
global cnt
seen[v] = True
for next_v in graph[v]:
if seen[next_v] == True:
... | Traceback (most recent call last):
File "/tmp/tmpfm051995/tmpm4j95eqy.py", line 1, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s777017308 | p02573 | u231570044 | 1598736740 | Python | Python (3.8.2) | py | Runtime Error | 868 | 44716 | 519 | import array
N, M = list(map(int, input().split()))
R = [[] for _ in range(N+1)]
def grp(R, i, S):
S[i] = True
ret = 1
for j in range(len(R[i])):
if S[ R[i][j] ]: continue
ret += grp(R, R[i][j], S)
return ret
for i in range(M):
a, b = list(map(int, input().split()))
R[a].appen... | Traceback (most recent call last):
File "/tmp/tmp6a3akyqf/tmpd820je3k.py", line 3, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s711284267 | p02573 | u970348538 | 1598736719 | Python | Python (3.8.2) | py | Runtime Error | 1182 | 112128 | 499 | def search(x, num):
nodes.remove(x)
for y in edge[x]:
if x in edge[y]:
edge[y].remove(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x ... | Traceback (most recent call last):
File "/tmp/tmphczpw3h0/tmpo4ugqta7.py", line 11, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s662931410 | p02573 | u727717182 | 1598736695 | Python | PyPy3 (7.3.0) | py | Runtime Error | 162 | 70396 | 743 | import sys
from collections import deque
parents = [-1] * 20000
def main():
input = sys.stdin.readline
N,M = map(int,input().split())
for _ in range(M):
A,B = map(int,input().split())
A = A - 1
B = B - 1
union(A,B)
ans = 0
for i in range(N):
ans = max... | Traceback (most recent call last):
File "/tmp/tmputdacwll/tmpv00rxch1.py", line 52, in <module>
main()
File "/tmp/tmputdacwll/tmpv00rxch1.py", line 10, in main
N,M = map(int,input().split())
^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s606109492 | p02573 | u970348538 | 1598736683 | Python | PyPy3 (7.3.0) | py | Runtime Error | 723 | 191280 | 471 | def search(x, num):
nodes.remove(x)
for y in edge[x]:
edge[y].discard(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x in d:
edge[x[0]].add(x[1... | Traceback (most recent call last):
File "/tmp/tmp0xyda49j/tmp72b0at_b.py", line 10, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s876483071 | p02573 | u970348538 | 1598736625 | Python | Python (3.8.2) | py | Runtime Error | 1128 | 111680 | 471 | def search(x, num):
nodes.remove(x)
for y in edge[x]:
edge[y].discard(x)
for y in list(edge[x]):
if y in nodes:
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x in d:
edge[x[0]].add(x[1... | Traceback (most recent call last):
File "/tmp/tmpmhre2tr1/tmpaigbfpqu.py", line 10, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s910721478 | p02573 | u002663801 | 1598736619 | Python | PyPy3 (7.3.0) | py | Runtime Error | 442 | 161148 | 1013 | n,m = list(map(int,input().split()))
dic = dict()
dicSet = set()
dicList = dict()
count = 0
ans = 0
for i in range(m):
a,b = list(map(int,input().split()))
if not(a in dicSet) and not(b in dicSet):
dic[count] = set()
dic[count].add(a)
dic[count].add(b)
dicList[a] = count
... | Traceback (most recent call last):
File "/tmp/tmp3ngzf84_/tmpwogszswf.py", line 1, in <module>
n,m = list(map(int,input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s461204354 | p02573 | u583285098 | 1598736492 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9624 | 452 | n, m = map(int, input().split())
ab = [list(map(int, input().split()))]
for _ in range(m-1):
a, b = map(int, input().split())
for i in ab:
if a not in i and b in i:
i.append(a)
break
elif b not in i and a in i:
i.append(b)
break
elif a in i... | Traceback (most recent call last):
File "/tmp/tmp3sqr615x/tmprcc2bhn0.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s035324533 | p02573 | u401481862 | 1598736405 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 37664 | 751 | n, m = map(int, input().split())
a = []
b = []
for i in range(m):
aa, bb = input().split()
a.append(aa)
b.append(bb)
f1 = []
f1.append(a[0])
for i in range(m):
if a[i] in f1:
if not(b[i] in f1):
f1.append(b[i])
elif b[i] in f1:
if not(a[i] in f1):
f1.append(a[i])
... | Traceback (most recent call last):
File "/tmp/tmpea8vja9a/tmprt7lcgf9.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s713524819 | p02573 | u407267131 | 1598736308 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 84872 | 793 | n,m = map(int,input().split())
f = []
f.append([])
nn=[]
for i in range(1,n+1):
f[0].append(i)
for i in range(0,n+1):
nn.append(0)
for i in range(m):
a,b = map(int,input().split())
if nn[a]==0 and nn[b]==0:
f[0].remove(a)
f[0].remove(b)
f.append([a,b])
nn[a]=len(f)-1... | Traceback (most recent call last):
File "/tmp/tmp0rb7i5vf/tmpgj6c5zsj.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s384372280 | p02573 | u794521826 | 1598736303 | Python | Python (3.8.2) | py | Runtime Error | 2217 | 301896 | 350 |
n, m = map(int, input().split())
a, b = map(int, input().split())
g = [[a, b]]
ma = 0
for i in range(0, m - 1, 1):
a, b = map(int, input().split())
for j in g:
if a in j or b in j:
j.extend([a, b])
j = set(j)
ma = len(j) if len(j) > ma else ma
else:
... | Traceback (most recent call last):
File "/tmp/tmpq16grqh2/tmp4ojmso7_.py", line 2, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s946361987 | p02573 | u407267131 | 1598736282 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 84712 | 690 | n,m = map(int,input().split())
f = []
f.append([])
nn=[]
for i in range(1,n+1):
f[0].append(i)
for i in range(0,n+1):
nn.append(0)
for i in range(m):
a,b = map(int,input().split())
if nn[a]==0 and nn[b]==0:
f[0].remove(a)
f[0].remove(b)
f.append([a,b])
nn[a]=len(f)-1... | Traceback (most recent call last):
File "/tmp/tmp1z5xik44/tmpvfg_tv4u.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s555906991 | p02573 | u231570044 | 1598736179 | Python | Python (3.8.2) | py | Runtime Error | 908 | 44732 | 513 | import array
N, M = list(map(int, input().split()))
R = [[] for _ in range(N+1)]
def grp(R, i, S):
S[i] = True
ret = 1
for j in range(len(R[i])):
if S[ R[i][j] ]: continue
ret += grp(R, R[i][j], S)
return ret
for i in range(M):
a, b = list(map(int, input().split()))
R[a].appen... | Traceback (most recent call last):
File "/tmp/tmpvdalqbja/tmp9kx1apm0.py", line 3, in <module>
N, M = list(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
s735517319 | p02573 | u407267131 | 1598736146 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1154 | 100232 | 748 | n,m = map(int,input().split())
f = []
f.append([])
nn=[]
for i in range(1,n+1):
f[0].append(i)
for i in range(0,n+1):
nn.append(0)
for i in range(m):
a,b = map(int,input().split())
if nn[a]==0 and nn[b]==0:
f[0].remove(a)
f[0].remove(b)
f.append([a,b])
nn[a]=len(f)-1... | Traceback (most recent call last):
File "/tmp/tmp2jt9avq1/tmp6_8ycmhp.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s144712060 | p02573 | u970348538 | 1598736056 | Python | Python (3.8.2) | py | Runtime Error | 1043 | 111840 | 454 | def search(x, num):
for y in list(edge[x]):
if y in nodes:
nodes.remove(y)
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x in d:
edge[x[0]].add(x[1])
edge[x[1]].add(x[0])
nodes = set(... | Traceback (most recent call last):
File "/tmp/tmphzynhfdg/tmpnxr_vjij.py", line 8, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s172935588 | p02573 | u013864607 | 1598736017 | Python | Python (3.8.2) | py | Runtime Error | 493 | 12636 | 539 | N,M=map(int, input().split())
groups = [1e10 for i in range(N)]
new_group = 0
for _ in range(M):
i, j = map(int, input().split())
i-=1
j-=1
if groups[i]==1e10 and groups[j]==1e10:
groups[i] = new_group
groups[j] = new_group
new_group+=1
elif groups[i]==1e10:
group = ... | Traceback (most recent call last):
File "/tmp/tmpiflx4jkr/tmpfwki_740.py", line 1, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s367619079 | p02573 | u407267131 | 1598736007 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1122 | 87320 | 748 | n,m = map(int,input().split())
f = []
f.append([])
nn=[]
for i in range(1,n+1):
f[0].append(i)
for i in range(0,n+1):
nn.append(0)
for i in range(m):
a,b = map(int,input().split())
if nn[a]==0 and nn[b]==0:
f[0].remove(a)
f[0].remove(b)
f.append([a,b])
nn[a]=len(f)-1... | Traceback (most recent call last):
File "/tmp/tmprgfazb1k/tmp4d9sbzul.py", line 1, in <module>
n,m = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s329847548 | p02573 | u602740328 | 1598735979 | Python | Python (3.8.2) | py | Runtime Error | 2208 | 59292 | 578 | class UFTree():
def __init__(self,n):
self.parent = {i:i for i in range(1,n+1)}
def root(self,n):
if self.parent[n]==n: return n
else: return self.root(self.parent[n])
def unite(self,x,y):
rx,ry = self.root(x), self.root(y)
if rx!=ry: self.parent[rx] = ry
def same(self,x,y):
... | Traceback (most recent call last):
File "/tmp/tmp3qr2merb/tmpemvdecu1.py", line 16, in <module>
N,M = map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s208849620 | p02573 | u473781743 | 1598735960 | Python | Python (3.8.2) | py | Runtime Error | 667 | 112004 | 404 | import collections
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components
n, m = map(int, input().split())
edge = np.array([input().split() for _ in range(m)], dtype = np.int64).T
tmp = np.ones(m, dtype = np.int64).T
graph = csr_matrix((tmp, (edge[:] -1)), (n, n))
... | Traceback (most recent call last):
File "/tmp/tmp_dphnyau/tmp2rgvrrcb.py", line 6, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s291581001 | p02573 | u572271833 | 1598735907 | Python | Python (3.8.2) | py | Runtime Error | 593 | 32384 | 807 | #Union Find
#xの根を求める
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
#xとyの属する集合の併合
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return False
else:
#sizeの大きいほうがx
if par[x] > par[y]:
x,y = y,x
... | Traceback (most recent call last):
File "/tmp/tmpx3dag_1x/tmpt6nfys57.py", line 34, in <module>
n, m = map(int, input().split( ))
^^^^^^^
EOFError: EOF when reading a line
| |
s055341274 | p02573 | u878518432 | 1598735876 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2243 | 1097568 | 747 | N, M = [int(i) for i in input().split()]
a, b = input().split()
s = {a,b}
tomodachi_list = [s] #同じグループにしてはいけないリスト
#print(tomodachi_list)
for _ in range(M-1):
a,b = input().split()
flag = 0
for group in tomodachi_list:
if a in group and b in group:
break
elif a in group and b not... | Traceback (most recent call last):
File "/tmp/tmpbu7_i50g/tmpyo0208jc.py", line 1, in <module>
N, M = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s645996264 | p02573 | u814781830 | 1598735792 | Python | PyPy3 (7.3.0) | py | Runtime Error | 646 | 152372 | 422 | N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
a, b = map(int, input().split())
a, b = a-1,b-1
edge[a].append(b)
edge[b].append(a)
visited = [0] * N
cnt = 0
def dfs(n):
global cnt
if visited[n]: return
cnt += 1
visited[n] = True
for nv in edge[n]:
... | Traceback (most recent call last):
File "/tmp/tmpifvrovwo/tmpkp4oo62n.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s310403203 | p02573 | u380854465 | 1598735731 | Python | PyPy3 (7.3.0) | py | Runtime Error | 710 | 129724 | 761 | import sys
import math
from collections import deque
n,m = map(int, input().split())
q = [0]*(n+1)
graph = [[] for _ in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0
if m == 0:
print(0)
exit()
d ... | Traceback (most recent call last):
File "/tmp/tmpmfqq31qh/tmptpxc31bu.py", line 4, in <module>
n,m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s421476536 | p02573 | u970348538 | 1598735682 | Python | Python (3.8.2) | py | Runtime Error | 929 | 111984 | 513 | def search(x, num):
for y in list(edge[x]):
if y in nodes:
nodes.remove(y)
edge[y].discard(x)
num = search(y, num)
return num + 1
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
edge = [set() for _ in range(n+1)]
for x in d:
edge[x[0]].add(x[1])
ed... | Traceback (most recent call last):
File "/tmp/tmp1ix96k_h/tmpi7xi_mas.py", line 10, in <module>
(n,m),*d = [list(map(int, s.split())) for s in open(0)]
^^^^^^^^
ValueError: not enough values to unpack (expected at least 1, got 0)
| |
s488708981 | p02573 | u085717502 | 1598735678 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9088 | 611 | #!/usr/bin/env python
# coding: utf-8
# In[140]:
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return False
if par[x] > par[y]:
x,y = y,x
par[x] += par[y]
par[y... | Traceback (most recent call last):
File "/tmp/tmpjompdpew/tmp3za88a0w.py", line 32, in <module>
par = [-1]*N
^
NameError: name 'N' is not defined
| |
s970033211 | p02573 | u751843916 | 1598735592 | Python | Python (3.8.2) | py | Runtime Error | 2217 | 298860 | 205 | import networkx as nx
n,m=map(int,input().split())
a=[[tuple(i) for i in input().split()] for _ in range(m)]
g=nx.Graph()
g.add_edges_from(a)
print(sorted([len(i) for i in nx.connected_components(g)])[-1]) | Traceback (most recent call last):
File "/tmp/tmp97o3e25j/tmpyke72kpj.py", line 2, in <module>
n,m=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s720332191 | p02573 | u401481862 | 1598735574 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 38512 | 738 | n, m = map(int, input().split())
a = [] * m
b = [] * m
for i in range(m):
aa, bb = input().split()
a.append(aa)
b.append(bb)
ans = n
f1 = []
f1.append(a[0])
for i in range(m):
if a[i] in f1:
f1.append(b[i])
elif b[i] in f1:
f1.append(a[i])
rans = len(f1)
if rans < ans:
ans = rans... | Traceback (most recent call last):
File "/tmp/tmpg1qpzzbu/tmph31g48la.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s331213026 | p02573 | u942051624 | 1598735538 | Python | Python (3.8.2) | py | Runtime Error | 734 | 38136 | 382 |
N,M=map(int, input().split())
l=[[]for j in range(N)]
field=[True]*N
for i in range(M):
a,b=map(int,input().split())
l[min(a,b)-1].append(max(a,b)-1)
def dfs(x):
conn=1
field[x]=False
for j in range(len(l[x])):
if field[l[x][j]]:
conn+=dfs(l[x][j])
return conn
nax=0
for i ... | Traceback (most recent call last):
File "/tmp/tmpmpy9c8tt/tmpgb8xomc2.py", line 2, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s926068472 | p02573 | u942051624 | 1598735484 | Python | PyPy3 (7.3.0) | py | Runtime Error | 502 | 102980 | 382 |
N,M=map(int, input().split())
l=[[]for j in range(N)]
field=[True]*N
for i in range(M):
a,b=map(int,input().split())
l[min(a,b)-1].append(max(a,b)-1)
def dfs(x):
conn=1
field[x]=False
for j in range(len(l[x])):
if field[l[x][j]]:
conn+=dfs(l[x][j])
return conn
nax=0
for i ... | Traceback (most recent call last):
File "/tmp/tmp01q1dl5g/tmp224tbqaa.py", line 2, in <module>
N,M=map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s858453764 | p02573 | u401481862 | 1598735463 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 38428 | 753 | n, m = map(int, input().split())
a = [] * m
b = [] * m
for i in range(m):
aa, bb = input().split()
a.append(aa)
b.append(bb)
ans = n
f1 = []
f1.append(a[0])
for i in range(m):
if a[i] in f1:
f1.append(b[i])
elif b[i] in f1:
f1.append(a[i])
rans = len(f1)
if rans < ans:
ans = rans... | Traceback (most recent call last):
File "/tmp/tmpjzpbuhmb/tmpmxq5zect.py", line 1, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s296521053 | p02573 | u295585689 | 1598735423 | Python | Python (3.8.2) | py | Runtime Error | 2137 | 29232 | 791 | import numpy as np
class union_find:
def __init__(self,N):
self.r = np.ones(N)*-1
def root(self,x):
if self.r[x]<0:
return int(x)
else:
self.r[x] = self.root(int(self.r[x]))
return int(self.r[x])
def unite(self,x,y):
x = self... | Traceback (most recent call last):
File "/tmp/tmpa2p2jpfw/tmpetkbm51t.py", line 28, in <module>
N,M = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s826771644 | p02573 | u473172054 | 1598735408 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9080 | 351 | N, M = map(int, input().split())
friends_set_list = [set(i) for i in range(N+1)]
ans = 1
for i in range(M):
A, B = map(int, input().split())
friends_set_list[B].add(A)
friends_set_list[A] |= friends_set_list[B]
friends_set_list[B] = friends_set_list[A]
num = len(friends_set_list[A])
if ans < num... | Traceback (most recent call last):
File "/tmp/tmp2v9tjnq7/tmpso4y5x0u.py", line 1, in <module>
N, M = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.