s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s000132706
p02573
u238786149
1600592265
Python
PyPy3 (7.3.0)
py
Runtime Error
83
68760
227
import networkx as nx G = nx.Graph() n, m = map(int, input().split()) for i in range(m): a, b = map(int, input().split()) G.add_edge(a, b) largest_cc = max(nx.connected_components(G), key=len) print(len(largest_cc))
s680024884
p02573
u941645670
1600462568
Python
Python (3.8.2)
py
Runtime Error
880
78420
411
n,m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] a, b = [list(i) for i in zip(*ab)] ans = [i for i in range(1,n+1,1)] #now = [1]*n now_num = 1 link = [[] * 1 for i in range(n)] for i in ab: link[i[0]-1].append(i[1]) link[i[1]-1].append(i[0]) a = max(len(link[i[0]-1]...
s504140099
p02573
u342563578
1600456466
Python
PyPy3 (7.3.0)
py
Runtime Error
90
74784
1212
par = [] for i in range(n): par.append(-1) #初期親 rank = [1 for i in range(n)] #初期ランク cut = [] def find(n): #親検索andランク短縮 global cut if par[n] < 0: for i in range(len(cut)): par[cut[i]] = n cut = [] return n else: cut.append(n) find(par[n]) retur...
s317119677
p02573
u342563578
1600456369
Python
PyPy3 (7.3.0)
py
Runtime Error
91
74792
1182
par = [] for i in range(n): par.append(-1) #初期親 rank = [1 for i in range(n)] #初期ランク cut = [] def find(n): #親検索andランク短縮 global cut if par[n] < 0: for i in range(len(cut)): par[cut[i]] = n cut = [] return n else: cut.append(n) find(par[n]) retur...
s129233289
p02573
u342563578
1600448163
Python
PyPy3 (7.3.0)
py
Runtime Error
118
101192
378
n,m = map(int,input().split()) par = [] for i in range(n): par.append(i) #初期親 rank = [1 for i in range(n)] #初期ランク cut = [] for i in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 unite(a,b) for i in range(n): shorten(i) import collections c = collections.Counter(par) ans = 0 for i in ra...
s746492813
p02573
u322171361
1600445100
Python
Python (3.8.2)
py
Runtime Error
2207
53056
429
n, m = map(int, input().split()) g = [[] for _ in range(n+1)] for i in range(m): a, b = map(int, input().split()) g[a].append(b) g[b].append(a) seen = [False]*(n+1) seen[0] = True def dfs(root): depth=0 seen[root] = True for i in g[root]: if seen[i]: continue depth ...
s630884415
p02573
u322171361
1600443228
Python
Python (3.8.2)
py
Runtime Error
2206
44744
427
n, m = map(int, input().split()) g = [[] for _ in range(n+1)] for i in range(m): a, b = map(int, input().split()) g[a].append(b) g[b].append(a) seen = [False]*(n+1) seen[0] = True def dfs(root): depth=0 seen[root] = True for i in g[root]: if seen[i]: continue depth ...
s508402274
p02573
u729972685
1600410202
Python
PyPy3 (7.3.0)
py
Runtime Error
385
211068
574
from sys import stdin from itertools import accumulate input = stdin.readline from collections import Counter N, M = map(int, input().split()) friends = [tuple(map(int, inp.strip().split())) for inp in stdin.read().splitlines()] father = list(range(N)) def getfather(x): if father[x] != x: father[x] = ge...
s487141809
p02573
u729972685
1600409322
Python
PyPy3 (7.3.0)
py
Runtime Error
398
209680
547
from sys import stdin from itertools import accumulate input = stdin.readline from collections import Counter N,M = map(int,input().split()) friends = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()] father = list(range(N)) def getfather(x): if father[x] != x: father[x] = getfather(father[...
s803224251
p02573
u630211216
1600237745
Python
Python (3.8.2)
py
Runtime Error
693
19108
417
N,M=map(int,input().split()) parent=[i for i in range(N)] def find(x,par): y=par[x] while y!=par[y]: y=find(y,par) par[x]=y return par[x] def unite(a,b,par): x=find(a,par) y=find(b,par) if x!=y: par[x]=y for _ in range(M): A,B=map(int,input().split()) unite(A-1,B-1,...
s710900851
p02573
u243535639
1600209632
Python
PyPy3 (7.3.0)
py
Runtime Error
744
167252
755
from typing import Counter def main(): N, M = map(int, input().split()) friend = [set([]) for _ in range(N)] for _ in range(M): A, B = map(int, input().split()) friend[A-1].add(B-1) friend[B-1].add(A-1) ans = 0 global visited visited = [0] * N for n in range(N): ...
s870873946
p02573
u510582860
1600200223
Python
Python (3.8.2)
py
Runtime Error
2206
26460
290
N,M=map(int,input().split()) V=[] for _ in range(M): s=set(map(int,input().split())) f=True for v in V: l=len(s&v) if l>0: f=False if l==1: v.update(s) break if f: V.append(s) print(max(map(len,V)))
s585022718
p02573
u510582860
1600199555
Python
Python (3.8.2)
py
Runtime Error
2206
26404
254
N,M=map(int,input().split()) V=[] for _ in range(M): s=set(map(int,input().split())) f=True for v in V: if len(s&v)>0: v.update(s) f=False break if f: V.append(s) print(max(map(len,V)))
s350444653
p02573
u510582860
1600197356
Python
Python (3.8.2)
py
Runtime Error
2206
9780
339
N,M=map(int,input().split()) V=[] for _ in range(M): a,b=map(int,input().split()) flg=True for v in V: if (a in v) or (b in v): if a not in v: v.append(a) if b not in v: v.append(b) flg=False if flg: V.append([a,b]) prin...
s085821373
p02573
u798818115
1600189392
Python
Python (3.8.2)
py
Runtime Error
903
47980
500
# coding: utf-8 # Your code here! N,M=map(int,input().split()) visited=[0]*N frnds=[[] for i in range(N)] for _ in range(M): a,b=map(int,input().split()) frnds[a-1].append(b-1) frnds[b-1].append(a-1) for i in range(N): frnds[i]=list(set(frnds[i])) def saiki(num): value=1 visited[num]=1 f...
s407862967
p02573
u974402118
1600115189
Python
Python (3.8.2)
py
Runtime Error
2207
68424
351
N,M = (int(x) for x in input().split()) m = [] for i in range(M): a,b = (int(x)-1 for x in input().split()) m.append({a,b}) m_merge = [m.pop(0)] while m: for j in range(len(m_merge)): if m_merge[j]&m[0]: m_merge[j] = m_merge[j]|m.pop(0) break else: m_merge.append(m.pop(0)) m_size = [len(x) for x...
s535678180
p02573
u974402118
1600115081
Python
Python (3.8.2)
py
Runtime Error
2208
68648
352
N,M = (int(x) for x in input().split()) m = [] for i in range(M): a,b = (int(x)-1 for x in input().split()) m.append({a,b}) m_merge = [m.pop(0)] while m: for j in range(len(m_merge)): if m_merge[j]&m[0]: m_merge[j] = m_merge[j]|m.pop(0) break else: m_merge.append(m.pop(0)) m_size = [size(x) for ...
s922251463
p02573
u528470578
1600095434
Python
Python (3.8.2)
py
Runtime Error
764
45056
444
N, M = map(int, input().split()) ki = [[] for _ in range(N)] for _ in range(M): a, b = map(int, input().split()) ki[a-1].append(b-1) ki[b-1].append(a-1) tf = [False for _ in range(N)] # DFS def dfs(v): global eda tf[v] = True eda += 1 for nv in set(ki[v]): if not tf[nv]: ...
s845334829
p02573
u458412487
1600088468
Python
Python (3.8.2)
py
Runtime Error
2207
45652
465
N=list(map(int,input().split())) n=N[0] m=N[1] A = [] for i in range(m): array = list(map(int,input().split())) array.sort() A.append(array) def get_unique_list(seq): seen = [] return [x for x in seq if x not in seen and not seen.append(x)] X=get_unique_list(A) import collections t = map(tuple,X) count...
s539835414
p02573
u254221913
1600085162
Python
PyPy3 (7.3.0)
py
Runtime Error
2337
3509436
307
n, m = map(int, input().split()) friend = [[0]*n for i in range(n)] s = [0] * n for i in range(m): a, b = map(int, input().split()) if friend[a-1][b-1] != 1 and friend[b-1][a-1] != 1: friend[a-1][b-1] = 1 friend[b-1][a-1] = 1 s[a-1] += 1 s[b-1] += 1 print(max(s) + 1)
s374818022
p02573
u254221913
1600084984
Python
PyPy3 (7.3.0)
py
Runtime Error
2331
3510596
238
n, m = map(int, input().split()) friend = [[0]*n for i in range(n)] s = 0 for i in range(m): a, b = map(int, input().split()) friend[a-1][b-1] = 1 friend[b-1][a-1] = 1 for i in range(n): s = max(s, sum(friend[i])) print(s)
s683658898
p02573
u112007848
1600078025
Python
Python (3.8.2)
py
Runtime Error
900
188700
580
import sys import resource def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry return 0 sys.setrecursionlimit(10 ** 5 * 2) n, m=map(int, input().split(" ")) par = list(range(n + 1)) for i in range(m): a...
s774673334
p02573
u112007848
1600077521
Python
Python (3.8.2)
py
Runtime Error
496
19072
521
def root(x): if par[x] == x: return x par[x] = root(par[1]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry return 0 n, m=map(int, input().split(" ")) par = list(range(n + 1)) for i in range(m): a, b = map(int, input().split(" ")) union(a, b) #print(par...
s632932676
p02573
u112007848
1600075963
Python
Python (3.8.2)
py
Runtime Error
713
24080
533
def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry return 0 n, m=map(int, input().split(" ")) par = list(range(n + 1)) + [0 for i in range(200000)] for i in range(m): a, b = map(int, input().split("...
s914972478
p02573
u112007848
1600075921
Python
Python (3.8.2)
py
Runtime Error
684
18944
527
def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry return 0 n, m=map(int, input().split(" ")) par = list(range(n + 1)) + [0 for i in range(100)] for i in range(m): a, b = map(int, input().split(" ")...
s610253463
p02573
u112007848
1600073114
Python
Python (3.8.2)
py
Runtime Error
684
18904
467
def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry return 0 n, m=map(int, input().split(" ")) par = list(range(n + 1)) for i in range(m): a, b = map(int, input().split(" ")) union(a, b) #print(par...
s218253999
p02573
u112007848
1600070774
Python
Python (3.8.2)
py
Runtime Error
396
45336
532
def root(i): if par[i] == i: return i par[i] = root(par[i]) return par[i] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[ry] = rx def same(x, y): return par[x] == par[y] n,m = map(int, input().split(" ")) p = [0] + list(map(int, input().split(" "))) a = [(list(map(int, input().spli...
s087318715
p02573
u112007848
1600070751
Python
Python (3.8.2)
py
Runtime Error
399
45420
528
def root(i): if par[i] == i: return i par[i] = root(par[i]) return par[i] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[ry] = rx def same(x, y): return par[x] == par[y] n,m = map(int, input().split(" ")) p = [0] + list(map(int, input().split(" "))) a = [(list(map(int, input().spli...
s704293034
p02573
u112007848
1600070698
Python
Python (3.8.2)
py
Runtime Error
397
45180
532
def root(i): if par[i] == i: return i par[i] = root(par[i]) return par[i] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[ry] = rx def same(x, y): return par[x] == par[y] n,m = map(int, input().split(" ")) p = [0] + list(map(int, input().split(" "))) a = [(list(map(int, input().spli...
s091102342
p02573
u112007848
1600063411
Python
Python (3.8.2)
py
Runtime Error
585
19084
462
def root(x): if par[x] == x: return x par[x] = root(par[x]) return 1 def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry return 0 n, m=map(int, input().split(" ")) par = list(range(n + 1)) for i in range(m): a, b = map(int, input().split(" ")) union(a, b) #print(par) max...
s969310334
p02573
u112007848
1600062425
Python
Python (3.8.2)
py
Runtime Error
664
19028
467
def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry return 0 n, m=map(int, input().split(" ")) par = list(range(n + 1)) for i in range(m): a, b = map(int, input().split(" ")) union(a, b) #print(par...
s679594511
p02573
u248670337
1600057043
Python
Python (3.8.2)
py
Runtime Error
1598
299664
105
from networkx import * print(max(*map(len,connected_components(Graph([*map(str.split,open(0))][1:]))),1))
s326020154
p02573
u248670337
1600056805
Python
Python (3.8.2)
py
Runtime Error
1629
299920
103
from networkx import * print(max(*map(len,connected_components(Graph([*map(str.split,open(0))][1:])))))
s676302927
p02573
u248670337
1600056256
Python
Python (3.8.2)
py
Runtime Error
1635
299864
103
from networkx import * print(max(*map(len,connected_components(Graph([*map(str.split,open(0))][1:])))))
s381482904
p02573
u248670337
1600056152
Python
Python (3.8.2)
py
Runtime Error
352
70096
97
from networkx import * print(max(*map(len,connected_components(Graph([*map(str,open(0))][1:])))))
s767289675
p02573
u248670337
1600056130
Python
Python (3.8.2)
py
Runtime Error
332
53160
95
from networkx import * print(max(*map(len,connected_components(Graph([input().split()][1:])))))
s260306507
p02573
u112007848
1600045811
Python
Python (3.8.2)
py
Runtime Error
676
19204
535
def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry return 0 def same(x,y): rx = root(x) ry = root(y) return rx == ry n, m=map(int, input().split(" ")) par = list(range(n + 1)) for i in rang...
s832082129
p02573
u112007848
1600045135
Python
Python (3.8.2)
py
Runtime Error
669
19060
524
def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry def same(x,y): rx = root(x) ry = root(y) return rx == ry n, m=map(int, input().split(" ")) par = list(range(n + 1)) for i in range(m): a, ...
s776988618
p02573
u212831449
1600018632
Python
Python (3.8.2)
py
Runtime Error
626
45048
705
import collections n,m = map(int,input().split()) friend = [[] for i in range(n)] for i in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 friend[a].append(b) friend[b].append(a) q = collections.deque() visited = [0 for i in range(n)] def dfs(): while q: s = q.pop() for...
s582411710
p02573
u832943002
1600017848
Python
Python (3.8.2)
py
Runtime Error
371
14480
461
import sys n, m = [int(a) for a in sys.stdin.readline().strip().split(" ")] uf = [-1] * n def root(x): if uf[x] < 0: return x uf[x] = root(uf[x]) return uf[x] def merge(x, y): if(root(x) != root(y)): uf[x] += uf[root(y)] uf[root(y)] = x for i in range(m): a, b = [int...
s094695114
p02573
u360515075
1600008598
Python
PyPy3 (7.3.0)
py
Runtime Error
115
74164
432
import numpy as np from collections import defaultdict D = defaultdict(set) N, M = map(int,input().split()) L = np.zeros((N,N)) for _ in range(M): a, b = map(int,input().split()) D[a-1].add(b-1) D[b-1].add(a-1) Q = [] ans = 0 for i in range(N): vstd = set() Q.append(i) while Q: a = Q.pop() vstd.add...
s879464924
p02573
u334792253
1600006224
Python
PyPy3 (7.3.0)
py
Runtime Error
387
195464
1007
import sys from collections import Counter input = sys.stdin.readline N, M = map(int, input().split()) A_B = [list(map(int, input().split())) for _ in range(M)] class UnionFind: def __init__(self, n): self.par = [i for i in range(N+1)] self.rank = [0]*(N+1) #検索 def find(self, x): ...
s517794987
p02573
u112007848
1599996795
Python
Python (3.8.2)
py
Runtime Error
740
17576
658
def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def union(x, y): rx = root(x) ry = root(y) if rx != ry: par[rx] = ry def same(x,y): rx = root(x) ry = root(y) if rx == ry: print("Yes") else: print("No") n, m=map(int, input().split(" ")) par = list(...
s754286644
p02573
u750783400
1599940290
Python
PyPy3 (7.3.0)
py
Runtime Error
672
220868
1418
#スタック、キューを使う from collections import deque N,M = map(int,input().split()) G = [ set() for row in range(N)] for i in range(M): A,B = map(int,input().split()) G[A-1].add(B-1) G[B-1].add(A-1) for i in range(N): G[i] = set(G[i]) #1グループに所属する最大数 ans = 0 #友達グループの数 count = 0 #各頂点の状態を色で表す WHITE:未訪問 GRAY:...
s838314083
p02573
u820685137
1599932120
Python
Python (3.8.2)
py
Runtime Error
602
17680
1296
"""D.""" import sys #def input() -> str: # noqa: A001 # """Input.""" # return sys.stdin.readline()[:-1] class UnionFindTree: """Union-find.""" def __init__(self, n: int) -> None: """Init.""" self.n = n self.parent = [-1] * n def find_root(self, x: int) -> int: ""...
s968075873
p02573
u820685137
1599932046
Python
Python (3.8.2)
py
Runtime Error
817
17568
1283
"""D.""" import sys #def input() -> str: # noqa: A001 # """Input.""" # return sys.stdin.readline()[:-1] class UnionFindTree: """Union-find.""" def __init__(self, n: int) -> None: """Init.""" self.n = n self.parent = [-1] * n def find_root(self, x: int) -> int: ""...
s172694354
p02573
u820685137
1599931978
Python
Python (3.8.2)
py
Runtime Error
662
18684
1305
"""D.""" import sys from typing import List def input() -> str: # noqa: A001 """Input.""" return sys.stdin.readline()[:-1] class UnionFindTree: """Union-find.""" def __init__(self, n: int) -> None: """Init.""" self.n = n self.parent = [-1] * n def find_root(self, x: i...
s823827664
p02573
u820685137
1599923029
Python
Python (3.8.2)
py
Runtime Error
2206
37276
470
"""D.""" import sys from typing import List def input() -> str: # noqa: A001 """Input.""" return sys.stdin.readline()[:-1] n, m = map(int, input().split(' ')) groups: List[set] = [] for _ in range(m): a, b = map(int, input().split(' ')) for g in groups: if a in g: g.add(b) ...
s361596743
p02573
u964904181
1599921887
Python
Python (3.8.2)
py
Runtime Error
524
52168
891
from copy import deepcopy n, m = map(int, input().split()) pairs = [0] * m for i in range(m): pairs[i] = list(map(int, input().split())) # N = 5 # pairs = [[1,2], [3,4], [5,1]] print(pairs) class UnionFind: def __init__(self, N): self.r = [-1] * N def root(self, x): if self.r[x] < 0: ...
s256525951
p02573
u310286716
1599895659
Python
Python (3.8.2)
py
Runtime Error
2211
176008
672
# -*- coding: utf-8 -*- n, m = map(int, input().split()) friend_list = [] friend_list2 = [] for i in range(m): a, b = map(int, input().split()) friend_list.append([a, b]) while friend_list: friend = friend_list.pop() if not friend_list2: friend_list2.append(friend) else: temp_list = friend_list2.copy...
s603735117
p02573
u310286716
1599894937
Python
Python (3.8.2)
py
Runtime Error
2210
203076
697
# -*- coding: utf-8 -*- n, m = map(int, input().split()) friend_list = [] friend_list2 = [] for i in range(m): a, b = map(int, input().split()) friend_list.append([a, b]) while friend_list: friend = friend_list.pop() if not friend_list2: friend_list2.append(friend) else: temp_list = friend_list2.copy...
s007150269
p02573
u776860223
1599886110
Python
PyPy3 (7.3.0)
py
Runtime Error
357
78624
787
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 = ...
s017116482
p02573
u217131455
1599858650
Python
PyPy3 (7.3.0)
py
Runtime Error
356
78728
858
input_line = input().split() N = int(input_line[0]) M = int(input_line[1]) 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] ...
s080579019
p02573
u217131455
1599853129
Python
PyPy3 (7.3.0)
py
Runtime Error
2208
78936
535
input_line = input().split() N = int(input_line[0]) M = int(input_line[1]) groups = [] for i in range(M): date = input().split() per1 = int(date[0]) per2 = int(date[1]) for j in range(len(groups)): if per1 in groups[j]: if not per2 in groups[j]: groups[j].append(per2) break ...
s385610302
p02573
u526966088
1599850373
Python
Python (3.8.2)
py
Runtime Error
2206
66864
643
from collections import defaultdict N, M = map(int, input().split()) friend_info = [list(map(int, input().split())) for _ in range(M)] relation_dict = {} for person1, person2 in friend_info: add_flag = False for k, v in relation_dict.items(): if((person1 in v) or (person2 in v)): relation_...
s368568516
p02573
u250734103
1599834894
Python
Python (3.8.2)
py
Runtime Error
572
26416
818
N, M = map(int, input().split()) A = [0] * M B = [0] * M for i in range(M): A[i], B[i] = map(int, input().split()) class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * (n+1) def find(self, x): if self.parents[x] < 0: return x else: ...
s150625684
p02573
u729133443
1599795299
Python
Python (3.8.2)
py
Runtime Error
24
9040
668
import sys if sys.argv[-1] == 'ONLINE_JUDGE': import os, zlib, base64 open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${TYO>cuR480@qAH2g<Sknro9VRsPM>-Bp2oMbdN;6g4ub)FGU-bp-_x$|gq%wU6t>WT*wMOY0gzARgSm<PTl{O42M-acZ>GgR)gKaC@nKT&GwVX(kN~!u8ucZ|Y8b(B=Z50NhloinL<u!3pzz_z0QZz6)r3^d(FK|_Vvacc{$MMog(mI...
s453290629
p02573
u644171993
1599778870
Python
PyPy3 (7.3.0)
py
Runtime Error
518
171756
546
#!/usr/bin/env python def dfs(node, edge, vis): if vis[node]: return 0 vis[node] = True count = 1 for b in edge[node]: if not vis[b]: count += dfs(b, edge, vis) return count n, m = [int(i) for i in input().split(' ')] edge = [[] for i in range(n)] for _ in range(m): ...
s529303497
p02573
u375172966
1599771396
Python
PyPy3 (7.3.0)
py
Runtime Error
2243
1147304
376
n, m = map(int, input().split()) ab = [set(map(int, input().split())) for _ in range(m)] sets = [ab[0]] for a, b in ab[1:]: for i in range(len(sets)): if a in sets[i] or b in sets[i]: sets[i].add(a) sets[i].add(b) break else: sets.append({a, b,}) ans =...
s427801843
p02573
u375172966
1599771004
Python
Python (3.8.2)
py
Runtime Error
524
67636
149
n, m = map(int, input().split()) ab = [set(map(int, input().split())) for _ in range(m)] sets = [] sets.append(ab[0]) ans = 0 print(sets) print(ans)
s273578015
p02573
u375172966
1599770936
Python
Python (3.8.2)
py
Runtime Error
546
67652
167
n, m = map(int, input().split()) ab = [set(map(int, input().split())) for _ in range(m)] sets = [ab[0]] ans = 0 for s in sets: ans = max(len(s), ans) print(ans)
s197543761
p02573
u375172966
1599770777
Python
Python (3.8.2)
py
Runtime Error
532
67652
114
n, m = map(int, input().split()) ab = [set(map(int, input().split())) for _ in range(m)] sets = [ab[0]] print(ans)
s941730855
p02573
u375172966
1599770338
Python
Python (3.8.2)
py
Runtime Error
2218
361572
376
n, m = map(int, input().split()) ab = [set(map(int, input().split())) for _ in range(m)] sets = [ab[0]] for a, b in ab[1:]: for i in range(len(sets)): if a in sets[i] or b in sets[i]: sets[i].add(a) sets[i].add(b) break else: sets.append({a, b,}) ans =...
s804048831
p02573
u576335153
1599745702
Python
Python (3.8.2)
py
Runtime Error
143
11656
1728
import typing class DSU: ''' Implement (union by size) + (path compression) Reference: Zvi Galil and Giuseppe F. Italiano, Data structures and algorithms for disjoint set union problems ''' def __init__(self, n: int = 0): self._n = n self.parent_or_size = [-1] * n def...
s343714577
p02573
u124864167
1599736852
Python
Python (3.8.2)
py
Runtime Error
2206
15084
330
l=lambda:map(int, input().split()) n,m=l() p=[-1]*n p=[-1]*n def root(x): if p[x]<0:return x return (x:=root(p[x])) def union(x,y): x,y=root(x),root(y) if x==y: return p[x]+=p[y] p[y]=x def same(x,y): return root(x)==root(y) def size(x): return -p[r(x)] for _ in range(m): a,b=l() union(a-1,b-1) prin...
s463271967
p02573
u776860223
1599710963
Python
PyPy3 (7.3.0)
py
Runtime Error
457
151112
309
from collections import defaultdict friend_dict = defaultdict(list) N, M = map(int, input().split()) for m in range(M): x, y = map(int, input().split()) friend_dict[x].append(y) friend_dict[y].append(x) max_num_group = max([len(set(v)) for v in friend_dict.values()]) print(max_num_group + 1)
s528463264
p02573
u626337957
1599686471
Python
PyPy3 (7.3.0)
py
Runtime Error
104
74740
1363
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 = ...
s174141953
p02573
u488401358
1599683633
Python
Python (3.8.2)
py
Runtime Error
29
9096
487
mycode = r''' # distutils: language=c++ # cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True ctypedef long long LL from libc.stdio cimport scanf from libc.vector cimport vector ctypedef vector[LL] vec cdef: LL N,M vec A scanf("%lld %lld",N,M) ''' import sys import os if sys.argv[-1...
s053184784
p02573
u887833602
1599659237
Python
Python (3.8.2)
py
Runtime Error
2206
11396
588
def solve(N, M, fridens): parents = {} groups = {} for A, B in friends: parents[B] = A if A not in groups: if A not in parents: groups[A] = [A] else: continue groups[A].append(B) ans = len(max(groups.values(), key=len)) ...
s688875726
p02573
u697076802
1599657602
Python
Python (3.8.2)
py
Runtime Error
2207
39844
434
numbers = [int(i) for i in input().split()] N, M = numbers[0], numbers[1] AB = [] for m in range(M): numbers = [int(i) for i in input().split()] AB.append((numbers[0], numbers[1])) F = [] for A, B in AB: new = True for i, f in enumerate(F): if A in f or B in f: F[i] = f | {A} | {B...
s477415960
p02573
u235792800
1599629746
Python
Python (3.8.2)
py
Runtime Error
1264
107736
951
from sys import stdin import collections def ip(): return [int(i) for i in stdin.readline().split()] def sp(): return [str(i) for i in stdin.readline().split()] n,m = ip() # d = collections.defaultdict(list) d = {} seen = set() for i in range(m): x,y = ip() if (x,y) in seen or (y,x) in seen: continue ...
s502203025
p02573
u235792800
1599629377
Python
Python (3.8.2)
py
Runtime Error
1155
108080
796
from sys import stdin import collections def ip(): return [int(i) for i in stdin.readline().split()] def sp(): return [str(i) for i in stdin.readline().split()] n,m = ip() d = collections.defaultdict(list) seen = set() for i in range(m): x,y = ip() if (x,y) in seen or (y,x) in seen: continue d[x].a...
s221256978
p02573
u235792800
1599629248
Python
Python (3.8.2)
py
Runtime Error
1175
108052
770
from sys import stdin import collections def ip(): return [int(i) for i in stdin.readline().split()] def sp(): return [str(i) for i in stdin.readline().split()] n,m = ip() d = collections.defaultdict(list) seen = set() for i in range(m): x,y = ip() if (x,y) in seen or (y,x) in seen: continue d[x].a...
s327987307
p02573
u235792800
1599628975
Python
Python (3.8.2)
py
Runtime Error
1166
108040
759
from sys import stdin import collections def ip(): return [int(i) for i in stdin.readline().split()] def sp(): return [str(i) for i in stdin.readline().split()] n,m = ip() d = collections.defaultdict(list) seen = set() for i in range(m): x,y = ip() if (x,y) in seen or (y,x) in seen: continue d[x].a...
s697106980
p02573
u792720861
1599597814
Python
Python (3.8.2)
py
Runtime Error
806
19104
529
class UnionFind: def __init__(self, n): self.p = list(range(n+1)) def find(self, x): if x == self.p[x]: return x self.p[x] = self.find(self.p[x]) return self.p[x] def unite(self, x, y): x, y = self.find(x), self.find(y) if x != y: self.p[x] = y n...
s831837796
p02573
u792720861
1599597435
Python
Python (3.8.2)
py
Runtime Error
800
19068
529
class UnionFind: def __init__(self, n): self.p = list(range(n+1)) def find(self, x): if x == self.p[x]: return x self.p[x] = self.find(self.p[x]) return self.p[x] def unite(self, x, y): x, y = self.find(x), self.find(y) if x != y: self.p[x] = y n...
s196182863
p02573
u947664173
1599519368
Python
Python (3.8.2)
py
Runtime Error
2208
116736
562
n,m=map(int,input().split()) ab = [map(int, input().split()) for _ in range(m)] a,b = [list(i) for i in zip(*ab)] indexlist=[-1]*n def findroot(x): while 1: if indexlist[x-1] < 0: return x else: x=indexlist[x-1] def merge(a,b): art=findroot(a) brt=find...
s888425985
p02573
u947664173
1599519060
Python
PyPy3 (7.3.0)
py
Runtime Error
2209
152388
568
n,m=map(int,input().split()) ab = [map(int, input().split()) for _ in range(m)] a,b = [list(i) for i in zip(*ab)] indexlist=[-1]*n def findroot(x): while 1: if indexlist[x-1] < 0: return x else: x=indexlist[x-1] def merge(a,b): art=findroot(a) brt=fi...
s998944061
p02573
u947664173
1599518510
Python
PyPy3 (7.3.0)
py
Runtime Error
2210
151988
624
n,m=map(int,input().split()) ab = [map(int, input().split()) for _ in range(m)] a,b = [list(i) for i in zip(*ab)] indexlist=[-1]*n def findroot(x): while 1: if indexlist[x-1] < 0: return x else: x=indexlist[x-1] def merge(a,b): art=findroot(a) brt=fi...
s432156833
p02573
u358859892
1599495203
Python
Python (3.8.2)
py
Runtime Error
30
10420
632
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.pa...
s131294237
p02573
u434872492
1599493305
Python
PyPy3 (7.3.0)
py
Runtime Error
2209
140996
620
N,M = map(int,input().split()) G = [[] for i in range(N)] for i in range(M): a,b = map(int,input().split()) a-=1 b-=1 G[a].append(b) G[b].append(a) chk = [0 for i in range(N)] L = [0 for i in range(N)] def search(G,v,cnt,L,chk): chk[v]=1 L[v]=cnt for tmp in G[v]: if chk[tmp]!=0:...
s074698073
p02573
u092650292
1599479486
Python
Python (3.8.2)
py
Runtime Error
699
19392
678
import collections n, m = map(int, input().split()) par = [i for i in range(n + 5)] # print(par) s = list() # union find(parには0も入れているので、par[1]=1になる) def find(x): if par[x] == x: return x else: par[x] = find(par[x]) return par[x] def union(x, y): x = find(x) y = find(y) if...
s907306044
p02573
u021176439
1599479076
Python
Python (3.8.2)
py
Runtime Error
865
78160
552
n, m = map(int, input().split()) root = list(range(n + 1)) from collections import defaultdict d = defaultdict(set) def find(i): if i == root[i]: return i root[i] = find(root[i]) return root[i] def union(u, v): fu, fv = find(u), find(v) if fu == fv: d[min(fu, fv)].add(max(u, ...
s019934314
p02573
u021176439
1599478321
Python
Python (3.8.2)
py
Runtime Error
715
32564
484
n, m = map(int, input().split()) root = list(range(n + 1)) from collections import Counter d = Counter() def find(i): if i == root[i]: return i root[i] = find(root[i]) return root[i] def union(u, v): fu, fv = find(u), find(v) if fu == fv: return root[max(u, v)] = min(fu, ...
s594786560
p02573
u198336369
1599475764
Python
Python (3.8.2)
py
Runtime Error
688
24796
697
import collections n, m = map(int, input().split()) par = [i for i in range(0,n+1)] # print(par) s = list() # union find(parには0も入れているので、par[1]=1になる) def find(x): if par[x] == x: return x else: par[x] = find(par[x]) return par[x] def union(x,y): x = find(x) y = find(y) if x =...
s585056814
p02573
u198336369
1599475416
Python
Python (3.8.2)
py
Runtime Error
691
40156
684
import collections n, m = map(int, input().split()) par = [i for i in range(0,n+1)] # print(par) s = list() # union find(parには0も入れているので、par[1]=1になる) def find(x): if par[x] == x: return x else: par[x] = find(par[x]) return par[x] def union(x,y): x = find(x) y = find(y) if x =...
s039793385
p02573
u792720861
1599475403
Python
Python (3.8.2)
py
Runtime Error
784
18948
529
class UnionFind: def __init__(self, n): self.p = list(range(n+1)) def find(self, x): if x == self.p[x]: return x self.p[x] = self.find(self.p[x]) return self.p[x] def unite(self, x, y): x, y = self.find(x), self.find(y) if x != y: self.p[x] = y n...
s620180385
p02573
u794066762
1599442552
Python
PyPy3 (7.3.0)
py
Runtime Error
2209
126408
530
n, m = map(int, input().split(" ")) g = [[] for i in range(n)] vis = [False for j in range(n)] count = 0 def dfs(r): global count vis[r] = True count += 1 for v in g[r]: if not vis[v]: dfs(v) def solve(): global count mx = 0 for i in range(n): if i not in vis:...
s465245585
p02573
u092650292
1599439262
Python
Python (3.8.2)
py
Runtime Error
824
24900
1039
# 方針 union findで解く n, m = map(int, input().split()) # 入力の受け取り par = [i for i in range(1, n + 1)] # 親のリストを作成 # find関数を作成。自分の値とリスト番号を比べ、親ならば返し、子ならば親を探す # par[x-1]としているのは、例えばpar[0]=1になっているため def find(x): if par[x - 1] == x: return x else: par[x - 1] = find(par[x - 1]) return par[x - 1] ...
s280813923
p02573
u092650292
1599439111
Python
Python (3.8.2)
py
Runtime Error
816
40268
1026
# 方針 union findで解く n, m = map(int, input().split()) # 入力の受け取り par = [i for i in range(1, n + 1)] # 親のリストを作成 # find関数を作成。自分の値とリスト番号を比べ、親ならば返し、子ならば親を探す # par[x-1]としているのは、例えばpar[0]=1になっているため def find(x): if par[x - 1] == x: return x else: par[x - 1] = find(par[x - 1]) return par[x - 1] ...
s800387414
p02573
u092650292
1599439099
Python
Python (3.8.2)
py
Runtime Error
735
17140
1027
# 方針 union findで解く n, m = map(int, input().split()) # 入力の受け取り par = [i for i in range(1, n + 1)] # 親のリストを作成 # find関数を作成。自分の値とリスト番号を比べ、親ならば返し、子ならば親を探す # par[x-1]としているのは、例えばpar[0]=1になっているため def find(x): if par[x - 1] == x: return x else: par[x - 1] = find(par[x - 1]) return par[x - 1] ...
s200770965
p02573
u169042722
1599438822
Python
Python (3.8.2)
py
Runtime Error
2207
63296
773
N,M=[int(a) for a in input().split()] AB=list() for i in range(M): AB.append([int(a) for a in input().split()]) #print(N,M,AB) flists=list() for pair in AB: list0=-1 list1=-1 for j,flist in enumerate(flists): if pair[0] in flist: list0=j if pair[1] in flist: list...
s753894737
p02573
u198336369
1599437284
Python
Python (3.8.2)
py
Runtime Error
818
40316
1005
# 方針 union findで解く n, m = map(int, input().split()) # 入力の受け取り par = [i for i in range(1,n+1)] # 親のリストを作成 # find関数を作成。自分の値とリスト番号を比べ、親ならば返し、子ならば親を探す # par[x-1]としているのは、例えばpar[0]=1になっているため def find(x): if par[x-1] == x: return x else: par[x-1] = find(par[x-1]) return par[x-1] # union関数...
s960957269
p02573
u198336369
1599436123
Python
Python (3.8.2)
py
Runtime Error
822
40112
469
n, m = map(int, input().split()) par = [i for i in range(1,n+1)] def find(x): if par[x-1] == x: return x else: par[x-1] = find(par[x-1]) return par[x-1] def union(x,y): x = find(x) y = find(y) if x == y: return 0 par[x-1] = y for j in range(m): a,b = map(int, ...
s691369338
p02573
u185034753
1599427195
Python
Python (3.8.2)
py
Runtime Error
953
111156
805
from collections import defaultdict def main(): N, M = map(int, input().split()) g = defaultdict(set) for _ in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].add(b) g[b].add(a) from functools import lru_cache def dfs(u, visited: set): ...
s177693952
p02573
u185034753
1599427144
Python
Python (3.8.2)
py
Runtime Error
967
111404
757
from collections import defaultdict def main(): N, M = map(int, input().split()) g = defaultdict(set) for _ in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].add(b) g[b].add(a) from functools import lru_cache def dfs(u, visited: set): ...
s024194035
p02573
u061140245
1599426914
Python
Python (3.8.2)
py
Runtime Error
322
50156
609
import sys n, m = map(int, input().split()) info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()] pars = [-1]*n def get_root(x): if pars[x] < 0: return x else: pars[x] = get_root(pars[x]) return pars[x] def combine(x, y): if x == y: return r_x = get_root(x...
s374973957
p02573
u061140245
1599426581
Python
Python (3.8.2)
py
Runtime Error
26
9096
573
n, m = map(int, input().split()) info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()] pars = [-1]*n def get_root(x): if pars[x] < 0: return x else: return get_root(pars[x]) def combine(x, y): if x == y: return r_x = get_root(x) r_y = get_root(y) if r_x >...
s867893312
p02573
u061140245
1599426389
Python
Python (3.8.2)
py
Runtime Error
729
17516
767
nm = input().split(" ") n = int(nm[0]) m = int(nm[1]) pars = [-1]*n def get_root(x): if pars[x] < 0: return x else: return get_root(pars[x]) def combine(x, y): if x == y: return r_x = get_root(x) r_y = get_root(y) if r_x > r_y: r_x, r_y = r_y, r_x if r_x !...
s591316924
p02573
u061140245
1599425434
Python
Python (3.8.2)
py
Runtime Error
714
17536
736
nm = input().split(" ") n = int(nm[0]) m = int(nm[1]) pars = [-1]*n def get_root(x): if pars[x] < 0: return x else: return get_root(pars[x]) def combine(x, y): r_x = get_root(x) r_y = get_root(y) if r_x > r_y: r_x, r_y = r_y, r_x if r_x != r_y: pars[r_x] += pa...