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
s769985001
p03855
u375870553
1573330169
Python
Python (3.4.3)
py
Runtime Error
831
25792
1300
road_par = [] road_rank = [] rail_par = [] rail_rank = [] c1 = [] c2 = [] def init(par, rank, c, n): for i in range(n): par.append(i) rank.append(0) c.append(0) def find(par,x): if par[x] == x: return x par[x] = find(par, par[x]) return par[x] def unite(par, rank, x,...
s797191193
p03855
u937642029
1571950126
Python
PyPy3 (2.4.0)
py
Runtime Error
419
54000
1440
def change(after,index,li): before = li[index] for i in range(len(li)): if li[i]==before: li[i]=after def main(): n,k,l = map(int,input().split()) road=[0 for _ in range(n)] train=[0 for _ in range(n)] r=t=1 for _ in range(k): p,q = map(int,input().split()) ...
s061702667
p03855
u893478938
1571440297
Python
PyPy3 (2.4.0)
py
Runtime Error
1252
75900
916
N,K,L = map(int,input().split()) root_road = list(range(N)) root_rail = list(range(N)) depth_road = [1 for _ in range(N)] depth_rail = [1 for _ in range(N)] def find(a,root): if root[a] == a: return a else: root[a] = find(root[a],root) return root[a] def unite(a,b,root,depth): A =...
s306078380
p03855
u314050667
1571251682
Python
Python (3.4.3)
py
Runtime Error
570
23540
1536
import sys import collections as c sys.setrecursionlimit(10**6) import sys sys.setrecursionlimit(10**7) class UnionFind(): def __init__(self, n): self.n = n self.root = [-1]*(n+1) self.rnk = [0]*(n+1) def Find_Root(self, x): if(self.root[x] < 0): return x e...
s522821517
p03855
u314050667
1571249434
Python
Python (3.4.3)
py
Runtime Error
2128
640808
1392
import sys import collections as c sys.setrecursionlimit(10**6) class UnionFind(): def __init__(self, n): self.size = n self.root = [-1 for _ in range(n+1)] self.rnk = [0 for _ in range(n+1)] def findRoot(self, a): if self.root[a] < 0: return a else: return self.findRoot(self.root[a]) def uniteTre...
s935716957
p03855
u314050667
1571249180
Python
Python (3.4.3)
py
Runtime Error
2161
640776
1405
import sys import collections as c sys.setrecursionlimit(10**6) class UnionFind(): def __init__(self, n): self.size = n self.root = [-1 for _ in range(n+1)] self.rnk = [0 for _ in range(n+1)] def findRoot(self, a): if self.root[a] < 0: return a else: return self.findRoot(self.root[a]) def uniteTre...
s901846540
p03855
u314050667
1571232041
Python
Python (3.4.3)
py
Runtime Error
2150
640400
1417
import sys sys.setrecursionlimit(10**6) class UnionFind(): def __init__(self, n): self.size = n self.root = [-1 for _ in range(n+1)] self.rnk = [0 for _ in range(n+1)] def findRoot(self, a): if self.root[a] < 0: return a else: return self.findRoot(self.root[a]) def uniteTree(self, a, b): a = se...
s728173610
p03855
u314050667
1571231880
Python
Python (3.4.3)
py
Runtime Error
2105
24100
1375
class UnionFind(): def __init__(self, n): self.size = n self.root = [-1 for _ in range(n+1)] self.rnk = [0 for _ in range(n+1)] def findRoot(self, a): if self.root[a] < 0: return a else: return self.findRoot(self.root[a]) def uniteTree(self, a, b): a = self.findRoot(a) b = self.findRoot(b) i...
s888668968
p03855
u047816928
1570742715
Python
Python (3.4.3)
py
Runtime Error
17
2940
896
class UF: def __init__(self, N): self.uf = [-1]*N self.n = N def find(self, x): if self.uf[x]<0: return x self.uf[x] = self.find(self.uf[x]) return self.uf[x] def size(self, x): return -self.uf[self.find(x)] def union(self, x, y): x, y = self.find(x), ...
s030248582
p03855
u047816928
1570739394
Python
Python (3.4.3)
py
Runtime Error
179
14532
791
import sys sys.setrecursionlimit(10000) class UF: def __init__(self, N): self.uf = [-1]*N def find(self, x): if self.uf[x]<0: return x self.uf[x] = self.find(self.uf[x]) return self.uf[x] def size(self, x): return -self.uf[self.find(x)] def union(self, x, y): ...
s910662034
p03855
u047816928
1570738865
Python
Python (3.4.3)
py
Runtime Error
157
7008
750
class UF: def __init__(self, N): self.uf = [-1]*N def find(self, x): if self.uf[x]<0: return x self.uf[x] = self.find(self.uf[x]) return self.uf[x] def size(self, x): return -self.uf[self.find(x)] def union(self, x, y): x, y = self.find(x), self.find(y)...
s144024186
p03855
u047816928
1570738776
Python
Python (3.4.3)
py
Runtime Error
17
2940
694
class UF: def __init__(self, N): self.uf = [-1]*N def find(self, x): if self.uf[x]<0: return x self.uf[x] = self.find(self.uf[x]) return self.uf[x] def size(self, x): return -self.uf[self.find(x)] def union(self, x, y): x, y = self.find(x), self.find(y) if self.size(x) > self.size(y): x...
s633915916
p03855
u842689614
1567011892
Python
Python (3.4.3)
py
Runtime Error
1647
106120
2103
#import sys #input=sys.stdin.readline N,K,L=map(int,input().split()) pq=[list(map(int,input().split())) for _ in range(K)] rs=[list(map(int,input().split())) for _ in range(L)] city_road=set() city_train=set() city_road_train=set() city_roadgroup_dict={} roadgroup_city_dict={} city_traingroup_dict={} traingroup_ci...
s868681790
p03855
u842689614
1567011804
Python
Python (3.4.3)
py
Runtime Error
1377
106092
2101
import sys input=sys.stdin.readline N,K,L=map(int,input().split()) pq=[list(map(int,input().split())) for _ in range(K)] rs=[list(map(int,input().split())) for _ in range(L)] city_road=set() city_train=set() city_road_train=set() city_roadgroup_dict={} roadgroup_city_dict={} city_traingroup_dict={} traingroup_city...
s597556293
p03855
u347640436
1566662720
Python
Python (3.4.3)
py
Runtime Error
58
17200
815
def create_links(n, k): links = [[] for _ in range(n)] for i in range(k): p, q = map(int, readline().split()) links[p - 1].append(q - 1) links[q - 1].append(p - 1) return links def create_groups(n, links): groups = list(range(n)) for i in range(n): if groups[i] != i: continue q = [i...
s550074846
p03855
u347640436
1566657107
Python
Python (3.4.3)
py
Runtime Error
18
3064
824
from sys import stdin def main(): def find(parent, i): t = parent[i] if t == -1: return i t = find(parent, t) parent[i] = t return t def unite(parent, i, j): i = find(parent, i) j = find(parent, j) if i == j: return parent[i] = j from builtins import int, map, ra...
s065249037
p03855
u347640436
1566650859
Python
Python (3.4.3)
py
Runtime Error
2113
152596
1215
from collections import deque from sys import stdin def create_groups(n, links): from builtins import len, set groups = [-1 for _ in range(n)] group_number = 0 d = deque() for i in range(n): if groups[i] == -1: group_member = [] d.append(i) while len(d) != 0: j = d.popleft() ...
s224231143
p03855
u186838327
1566623447
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38384
1107
mport sys input = sys.stdin.readline def Find(x, par): if par[x] < 0: return x else: # 経路圧縮 par[x] = Find(par[x], par) return par[x] def Unite(x, y, par, rank): x = Find(x, par) y = Find(y, par) if x != y: # rankの低い方を高い方につなげる if rank[x] < rank[y]: par[y] += par[x] par...
s335794691
p03855
u353241315
1565909163
Python
Python (3.4.3)
py
Runtime Error
2108
76040
1446
def find_root(edges, root, group, before, now): group.append(now) children = edges[now] for child in children: if child != before and child not in group: root, group = find_root(edges, root, group, now, child) return root, group if __name__ == '__main__': N, K, L = map(int, ...
s209303782
p03855
u353241315
1565902092
Python
Python (3.4.3)
py
Runtime Error
1618
169988
1366
if __name__ == '__main__': N, K, L = map(int, input().split()) PQ = [None]*K RS = [None]*L roads = [set() for _ in range(N)] rails = [set() for _ in range(N)] answer = [None]*N for i in range(K): PQ[i] = list(map(int, input().split())) #PQ = sorted(PQ, key=min) ...
s745149806
p03855
u227082700
1565835261
Python
Python (3.4.3)
py
Runtime Error
2104
35292
365
from collections import* n,k,l=map(int,input().split());d=[-1]*n;t=[-1]*n;M=lambda:map(int,input().split()) def f(l,x):return x if l[x]<0else f(l,l[x]) def u(l,x,y): if f(l,x)!=f(l,y):l[f(l,y)]=f(l,x) for _ in range(k):a,b=M();u(d,a-1,b-1) for _ in range(l):a,b=M();u(t,a-1,b-1) p=[(f(d,i),f(t,i))for i in range(n)];c=...
s683306608
p03855
u227082700
1565834922
Python
Python (3.4.3)
py
Runtime Error
140
7352
375
from collections import* n,k,l=map(int,input().split());d=[-1]*n;t=[-1]*n def f(l,x): if l[x]<0:return x else:l[x]=f(l,l[x]);return l[x] def u(l,x,y):l[f(l,y)]=f(l,x) for _ in range(k):a,b=map(int,input().split());u(d,a-1,b-1) for _ in range(l):a,b=map(int,input().split());u(t,a-1,b-1) p=[(f(d,i),f(t,i))for i in ra...
s243418291
p03855
u399721252
1563252820
Python
PyPy3 (2.4.0)
py
Runtime Error
1051
110412
939
import sys input = sys.stdin.readline n, k, l = [ int(v) for v in input().split() ] road_parent = [ i for i in range(n) ] rail_parent = [ i for i in range(n) ] def parent(x,a,inlist): if inlist[x] == x: return x, a else: return parent(inlist[x],a+1,inlist) def union(z,inlist): x, y = z[0],...
s755709676
p03855
u133886644
1562823107
Python
Python (3.4.3)
py
Runtime Error
2121
278848
1207
import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.data = [0] * N self.dd = [{i} for i in range(N)] for i in range(N): self.data[i] = i def get_root(self, x): r = self.data[x] if r == x: return r ...
s585686963
p03855
u133886644
1562822858
Python
Python (3.4.3)
py
Runtime Error
2221
1813764
1239
import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.data = [0] * N self.dd = [{i} for i in range(N)] for i in range(N): self.data[i] = i def get_root(self, x): r = self.data[x] if r == x: return r ...
s382001649
p03855
u969190727
1560659163
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38416
1168
input = sys.stdin.readline n,k,l=map(int,input().split()) parD,parT=[-1]*n,[-1]*n def findD(x): if parD[x]<0: return x else: parD[x]=findD(parD[x]) return parD[x] def uniteD(x,y): x=findD(x) y=findD(y) if x==y: return False else: if parD[x]>parD[y]: x,y=y,x parD[x]+=parD[y] ...
s876748673
p03855
u978494963
1560036193
Python
Python (3.4.3)
py
Runtime Error
2104
43696
878
import copy class UnionFind: def __init__(self, N): self._parent = [i for i in range(N)] def find(self, x): if self._parent[x] == x: return x else: return self.find(self._parent[x]) def unite(self, a, b): ta = self.find(a) tb = self.find(b) if(ta == tb): return self._parent[ta] = tb # make ...
s839466942
p03855
u978494963
1560033837
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38384
881
import copy class UnionFind: def __init__(self, N): self._parent = [i for i in range(N)] self._rank = [1 for i in range(N)] def find(self, x): if self._parent[x] == x: return x else: return self.find(self._parent[x]) def unite(self, a, b): ta = self.find(a) tb = self.find(b) if(ta == tb): r...
s129381408
p03855
u365364616
1558643882
Python
Python (3.4.3)
py
Runtime Error
2106
54664
1022
from collections import defaultdict def dfs(i, V, E, num): V[i] = num for j in E[i]: if V[j] > 0: continue V = dfs(j, V, E, num) return V n, k, l = map(int, input().split()) Er = defaultdict(list) for i in range(k): p, q = map(int, input().split()) Er[p].append(q) E...
s534702409
p03855
u238510421
1557364334
Python
PyPy3 (2.4.0)
py
Runtime Error
967
81240
2176
from collections import Counter N,K,L = map(int, input().split()) pq_list = [] for _ in range(K): pq_list.append(list(map(int, input().split()))) rs_list = [] for _ in range(L): rs_list.append(list(map(int, input().split()))) class UnionFind(): def __init__(self): self.roots = {} self.ran...
s687081231
p03855
u319818856
1554621830
Python
Python (3.4.3)
py
Runtime Error
1255
64380
1466
class UnionFind: def __init__(self, size: int): self.__size = size self.__root = [-1] * size def root(self, x: int)->int: if self.__root[x] < 0: return x self.__root[x] = self.root(self.__root[x]) return self.__root[x] def size(self, x: int)->int: ...
s807766071
p03855
u983918956
1554479424
Python
Python (3.4.3)
py
Runtime Error
607
57272
1353
import sys input = sys.stdin.readline class Unionfind: __slots__ = ['nodes','size'] def __init__(self, n): self.nodes = list(range(n)) self.size = [1]*n def root(self, x): if self.nodes[x] == x: return x else: root_x = self.root(self.nodes[x]) ...
s860593415
p03855
u619819312
1553352946
Python
Python (3.4.3)
py
Runtime Error
110
19896
598
def root(x,d): if d[x]!=x: d[x]=root(x,d) return d[x] def unite(x,y,h): x=root(x,h) y=root(y,h) if x!=y: h[x]=min(x,y) h[y]=h[x] from collections import defaultdict n,k,l=map(int,input().split()) a=[i for i in range(n+1)] b=[i for i in range(n+1)] for i in range(k): s,t=m...
s392360639
p03855
u785578220
1552794743
Python
Python (3.4.3)
py
Runtime Error
28
3692
1553
from collections import defaultdict n,k,l = map(int, input().split()) class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.rank = [0] * n self.size = [1] * n # 検索 def find(self, x): if self.par[x] == x: return x else: ...
s730689591
p03855
u785578220
1552794693
Python
Python (3.4.3)
py
Runtime Error
21
3316
1555
from collections import defaultdict N, K, L = map(int, input().split()) class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.rank = [0] * n self.size = [1] * n # 検索 def find(self, x): if self.par[x] == x: return x else: ...
s524469335
p03855
u785578220
1552794682
Python
PyPy3 (2.4.0)
py
Runtime Error
161
38256
1555
from collections import defaultdict N, K, L = map(int, input().split()) class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.rank = [0] * n self.size = [1] * n # 検索 def find(self, x): if self.par[x] == x: return x else: ...
s946307206
p03855
u588341295
1548358605
Python
Python (3.4.3)
py
Runtime Error
662
23692
2075
# -*- coding: utf-8 -*- """ 参考:https://img.atcoder.jp/arc065/editorial.pdf ・Union-Find木 """ import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) INF = float('inf') MOD = 10 ** 9 + 7 from collections import Counter # Union-Find木 class UnionFind: def __init__(self, n): ...
s473964063
p03855
u844789719
1547866809
Python
Python (3.4.3)
py
Runtime Error
23
3440
876
import copy N, M = [int(_) for _ in input().split()] AB = [[int(_) - 1 for _ in input().split()] for _ in range(M)] G = [set() for _ in range(N)] a = set() for ab in AB: G[ab[0]].add(ab[1]) def find(a, x): stack = [] while a[x] != x: stack += [x] x = a[x] while stack: a[stack....
s917998869
p03855
u844789719
1547866175
Python
Python (3.4.3)
py
Runtime Error
1319
47504
735
N, K, L = [int(_) for _ in input().split()] def find(a, x): stack = [] while a[x] != x: x = a[x] stack += [x] while stack: a[stack.pop()] = x return x def unite(a, x, y): x = find(a, x) y = find(a, y) a[x] = a[y] = min(x, y) a_road = [i for i in range(N)] for _ ...
s595489297
p03855
u844789719
1547866132
Python
Python (3.4.3)
py
Runtime Error
1314
47508
735
N, K, L = [int(_) for _ in input().split()] def find(a, x): stack = [] while a[x] != x: x = a[x] stack += [x] while stack: a[stack.pop()] = x return x def unite(a, x, y): x = find(a, x) y = find(a, y) a[x] = a[y] = min(x, y) a_road = [i for i in range(N)] for _ ...
s050256386
p03855
u391331433
1546553870
Python
Python (2.7.6)
py
Runtime Error
1595
205044
1682
import sys from collections import deque import copy import math def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline def bfs(N, path, res): is_visited = [False for i in range(N + 1)] for i in range(1, N + 1): if is_visited[i]...
s051113756
p03855
u215329188
1546466443
Python
Python (3.4.3)
py
Runtime Error
2109
139880
905
import numpy as np N,K,L = map(int, input().split()) #print(N,K,L,D,T) array_D = np.eye(N,N,dtype=int) array_T = np.eye(N,N,dtype=int) root_D = [i for i in range(N)] root_T = [i for i in range(N)] for _ in range(K): d0, d1 = map(int, input().split()) d0 = d0 - 1 d1 = d1 - 1 r0 = root_D[d0] r1 = ...
s117638613
p03855
u215329188
1546464166
Python
Python (3.4.3)
py
Runtime Error
538
121924
903
N,K,L = map(int, input().split()) #print(N,K,L,D,T) list_D = [set([i]) for i in range(N)] list_T = [set([i]) for i in range(N)] root_D = [i for i in range(N)] root_T = [i for i in range(N)] #print(list_D) for _ in range(K): d = map(int, input().split()) d0 = d[0] - 1 d1 = d[1] - 1 r0 = root_D[d0] ...
s841534297
p03855
u215329188
1546464138
Python
Python (3.4.3)
py
Runtime Error
17
3064
907
N,K,L = map(int, input().split()) #print(N,K,L,D,T) list_D = [set([i]) for i in range(N)] list_T = [set([i]) for i in range(N)] root_D = [i for i in range(N)] root_T = [i for i in range(N)] #print(list_D) for _ in range(K): d = map(int, input().split()) d0 = d[0] - 1 d1 = d[1] - 1 r0 = root_D[d0] ...
s357325689
p03855
u215329188
1546464064
Python
Python (3.4.3)
py
Runtime Error
2124
303336
934
N,K,L = map(int, input().split()) D = [list(map(int, input().split())) for _ in range(K)] T = [list(map(int, input().split())) for _ in range(L)] #print(N,K,L,D,T) list_D = [set([i]) for i in range(N)] list_T = [set([i]) for i in range(N)] root_D = [i for i in range(N)] root_T = [i for i in range(N)] #print(list_D) ...
s523634596
p03855
u920299620
1543267364
Python
Python (3.4.3)
py
Runtime Error
17
2940
2186
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++) typedef long long llong; char moji[26]={'a','b','c','d','e','f','g','h'...
s995858737
p03855
u366133198
1542065137
Python
Python (3.4.3)
py
Runtime Error
18
3188
1821
u'''Return all length combination''' def all_comb(iterable): for i in range(0, len(iterable) + 1): comb = itertools.combinations(iterable, i) for pair in comb: yield(pair) class UnionFind: def __init__(self, elems=None): class KeyDict(dict): def __missing__(self...
s115005141
p03855
u658993896
1541726618
Python
Python (3.4.3)
py
Runtime Error
1701
83712
887
def bps(gr,p,s,num): if gr[s]!=-1: return gr[s]=num for x in p[s]: bps(gr,p,x,num) N,K,L=list(map(int,input().split())) dic={} road=[[] for _ in range(N)] rail=[[] for _ in range(N)] for i in range(K): p,q=list(map(int,input().split())) road[p-1].append(q-1) road[q-1].append(p-...
s733231867
p03855
u883048396
1539896143
Python
Python (3.4.3)
py
Runtime Error
17
3064
1312
#Union-Find木の構築 import sys def 解(): iN,iK,iL = [int(_) for _ in input().split()] aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] def buildTree(a): aT = [0]*(iN+1) for p,q in a: #if p > q : # p,q = q,p thisroot = max(aT[q],aT[p]...
s505332805
p03855
u883048396
1539831285
Python
Python (3.4.3)
py
Runtime Error
17
2940
1772
mport sys sys.setrecursionlimit(10**5) def 解(): iN,iK,iL = [int(_) for _ in input().split()] aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] a道 = aD[0:iK] a鉄道 = aD[iK:] d道 = {} d鉄道 = {} # for i in range(1,iN+1): # d道[i] = {i} # d鉄道[i] ={i} def fMakeSe...
s945835154
p03855
u883048396
1539819646
Python
Python (3.4.3)
py
Runtime Error
18
3064
824
import sys sys.setrecursionliit(10**5) def 解(): iN,iK,iL = [int(_) for _ in input().split()] aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] a道 = aD[0:iK] a鉄道 = aD[iK:] d道 = {} d鉄道 = {} for i in range(1,iN+1): d道[i] = {i} d鉄道[i] ={i} for p,q in...
s824467625
p03855
u883048396
1539819364
Python
Python (3.4.3)
py
Runtime Error
2115
208456
672
import sys iN,iK,iL = [int(_) for _ in input().split()] aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] a道 = aD[0:iK] a鉄道 = aD[iK:] d道 = {} d鉄道 = {} for i in range(1,iN+1): d道[i] = {i} d鉄道[i] ={i} for p,q in a道: d道[p].add(q) d道[q].add(p) for r,s in a鉄道: d鉄道[r].add(s) ...
s398583389
p03855
u069838609
1535849840
Python
Python (3.4.3)
py
Runtime Error
17
2940
37
7 4 4 1 2 2 3 2 5 6 7 3 5 4 5 3 4 6 7
s022405525
p03855
u826263061
1534360856
Python
Python (3.4.3)
py
Runtime Error
18
3192
1605
# -*- coding: utf-8 -*- """ Created on Wed Aug 15 14:20:12 2018 ABC049D @author: maezawa """ n, k, l = list(map(int, input().split())) road = [{}] rail = [{}] for i in range(k): pi, qi = list(map(int, input().split())) j = 0 while j<len(road): if road[j] == {}: road[j] = {pi, qi} ...
s127434133
p03855
u826263061
1534360672
Python
Python (3.4.3)
py
Runtime Error
18
3192
1601
# -*- coding: utf-8 -*- """ Created on Wed Aug 15 14:20:12 2018 ABC049D @author: maezawa """ n, k, l = list(map(int, input().split())) road = [{}] rail = [{}] for i in range(k): pi, qi = list(map(int, input().split())) j = 0 while j<len(road): if road[j] == {}: road[j] = {pi, qi} ...
s074702191
p03855
u232852711
1532155860
Python
Python (3.4.3)
py
Runtime Error
17
3064
1094
n, k, l = list(map(int, input().split())) def get_groups(n, m): road = [[] for _ in range(n+1)] for _ in range(m): p, q = list(map(int, input().split())) road[p].append(q) road[q].append(p) groups = [0]*(n+1) group_idx = 1 for i in range(1, n+1): if groups[i] == 0: ...
s206541388
p03855
u333945892
1530239825
Python
Python (3.4.3)
py
Runtime Error
17
3064
888
import sys sys.setrecursionlimit(10**8) def find(x,table): #xの根を返す if table[x] == x: return x else: table[x] = find(table[x],table) #親の更新(根を直接親にして参照距離を短く) return table[x] def union(x,y,table,rank): #xとyを繋げる x = find(x,table) y = find(y,table) if x == y: return if rank[x] > rank[y]: table[y] = x...
s185585233
p03855
u941884460
1530009599
Python
Python (3.4.3)
py
Runtime Error
669
53612
1454
N,K,L = map(int,input().split()) roads = [list(map(int,input().split())) for _ in range(K)] rails = [list(map(int,input().split())) for _ in range(L)] outputs = [1 for _ in range(N)] class UF(): def __init__(self,size): self.table = [-1 for _ in range(size)] self.results = {} def find(self,x): tar...
s204598248
p03855
u132434645
1526898712
Python
Python (3.4.3)
py
Runtime Error
2119
89720
765
import sys sys.setrecursionlimit(1000) n, k, l = map(int, input().split()) a = [list() for _ in range(n)] b = [list() for _ in range(n)] for _ in range(k): p, q = [int(x) - 1 for x in input().split()] a[p].append(q) a[q].append(p) for _ in range(l): r, s = [int(x) - 1 for x in input().split()] b[r]...
s437652819
p03855
u132434645
1526898648
Python
Python (3.4.3)
py
Runtime Error
1315
89720
724
n, k, l = map(int, input().split()) a = [list() for _ in range(n)] b = [list() for _ in range(n)] for _ in range(k): p, q = [int(x) - 1 for x in input().split()] a[p].append(q) a[q].append(p) for _ in range(l): r, s = [int(x) - 1 for x in input().split()] b[r].append(s) b[s].append(r) def g(a, ...
s569993973
p03855
u394271841
1525204534
Python
Python (3.4.3)
py
Runtime Error
2106
33712
830
import sys sys.setrecursionlimit(10000) def root(n, tree): if tree[n] == n: return n else: tree[n] = root(tree[n], tree) return tree[n] n, k, l = map(int, input().split()) road = [i for i in range(n+1)] railway = [i for i in range(n+1)] tree = [i for i in range(n+1)] for _ in range(k)...
s264413988
p03855
u394271841
1525204442
Python
Python (3.4.3)
py
Runtime Error
2106
35760
788
def root(n, tree): if tree[n] == n: return n else: tree[n] = root(tree[n], tree) return tree[n] n, k, l = map(int, input().split()) road = [i for i in range(n+1)] railway = [i for i in range(n+1)] tree = [i for i in range(n+1)] for _ in range(k): p, q = map(int, input().split()) ...
s624976368
p03855
u813098295
1522724349
Python
Python (2.7.6)
py
Runtime Error
1290
55340
1032
class uf_tree: def __init__(self, n): self.sizes = [0] * n self.par = range(n) def find(self, x): if x == self.par[x]: return x self.par[x] = self.find(self.par[x]) return self.par[x] def unite(self, x, y): x, y = self.find(x), self.find(y) ...
s995617685
p03855
u899866687
1522277028
Python
Python (3.4.3)
py
Runtime Error
2229
2041204
1288
N,K,L=map(int,input().split()) road=[[0]*N for i in range(N)] train=[[0]*N for j in range(N)] for i in range(K): p,q=map(int,input().split()) road[p-1][q-1]=1 road[q-1][p-1]=1 for j in range(L): r,s=map(int,input().split()) train[r-1][s-1]=1 train[s-1][r-1]=1 def count_r(node,visited): v...
s611567523
p03855
u899866687
1522274475
Python
Python (3.4.3)
py
Runtime Error
2235
2031988
1365
N,K,L=map(int,input().split()) road=[[0]*N for i in range(N)] train=[[0]*N for j in range(N)] for i in range(K): p,q=map(int,input().split()) road[p-1][q-1]=1 road[q-1][p-1]=1 for j in range(L): r,s=map(int,input().split()) train[r-1][s-1]=1 train[s-1][r-1]=1 def count_r(node,visited): vi...
s578025079
p03855
u665415433
1507152222
Python
Python (3.4.3)
py
Runtime Error
2153
709700
1493
import copy N, K, L = [int(i) for i in input().split()] ROAD = [[] for i in range(N + 1)] TRAIN = [[] for i in range(N + 1)] path = set([]) ans = [[0] * 2 for i in range(N + 1)] ans_num = [0] * (N + 1) for i in range(K): a, b = [int(i) for i in input().split()] ROAD[a].append(b) ROAD[b].append(a) for i in ...
s353883679
p03855
u665415433
1506979346
Python
Python (3.4.3)
py
Runtime Error
2145
672780
1126
import copy N, K, L = [int(i) for i in input().split()] ROAD = [[] for i in range(N + 1)] TRAIN = [[] for i in range(N + 1)] path = set([]) ans = [[0] * 2 for i in range(N+1)] ans_num = [0]*(N+1) for i in range(K): a, b = [int(i) for i in input().split()] ROAD[a].append(b) ROAD[b].append(a) for i in range(...
s631937176
p03855
u353919145
1505833742
Python
Python (2.7.6)
py
Runtime Error
15
2892
1046
import collections def solution(): pArr = [] qArr = [] rArr = [] sArr = [] cities = [] answer = [] line = raw_input() n, k, l = line.split(' ') for i in range (n): cities.append(i) for i in range(k): line = raw_input() p, q = line.split(' ') pArr.append(p) qArr.append(q) for i in range(l): ...
s434814552
p03855
u863370423
1505833582
Python
Python (3.4.3)
py
Runtime Error
2113
115608
1988
class Node(): def __init__(self, value): self.value = value self.connect = [] self.visited = False def getConnect(self): return self.connect def setConnect(self, connects): self.connect = connects def getConnectValues(self): res = [] for node in self.connect: res.append(node.getValue()) return...
s247655483
p03855
u863370423
1505832654
Python
Python (2.7.6)
py
Runtime Error
10
2568
2701
import java.util.*; public class Main { public static void main(String... args){ Scanner sc= new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int l = sc.nextInt(); // int n = 100000; // int k = 100000; // int l = 100000; List<Set<Integ...
s276881158
p03855
u596276291
1501169610
Python
Python (3.4.3)
py
Runtime Error
2109
99396
1929
from collections import defaultdict class UnionFind: def __init__(self, size): self.parent = list(range(size + 1)) def is_same_set(self, x: int, y: int) -> bool: return self.find_root(x) == self.find_root(y) def union_set(self, x: int, y: int): x = self.find_root(x) y = s...
s529795948
p03855
u761320129
1496870727
Python
Python (2.7.6)
py
Runtime Error
667
17868
1892
N,K,L = map(int, raw_input().split()) roads = [-1 for i in range(N)] rails = [-1 for i in range(N)] same_roads = {} same_rails = {} max_road_id = -1 for i in range(K): p,q = map(int, raw_input().split()) p -= 1 q -= 1 if roads[p] < 0 and roads[q] < 0: max_road_id += 1 roads[p] = max_road_id roads[q...
s441779431
p03855
u639045280
1482073193
Python
PyPy3 (2.4.0)
py
Runtime Error
1555
126720
548
from collections import Counter n,k,l = map(int, input().split()) def f(m): a = [[] for _ in range(n)] for _ in range(m): p,q = map(int, input().split()) a[p-1].append(q-1) a[q-1].append(p-1) b = list(range(n)) for i in range(n): def g(j): if b[j] != j: ...
s334744540
p03855
u639045280
1482073078
Python
Python (3.4.3)
py
Runtime Error
1449
47388
547
from collections import Counter n,k,l = map(int, input().split()) def f(m): a = [[] for _ in range(n)] for _ in range(m): p,q = map(int, input().split()) a[p-1].append(q-1) a[q-1].append(p-1) b = list(range(n)) for i in range(n): def g(j): if b[j] != j: ...
s316993724
p03855
u591287669
1481752570
Python
Python (3.4.3)
py
Runtime Error
1592
91116
819
from collections import defaultdict n,k,l=map(int,input().split()) st=[] # streets rr=[] # railroads for _ in range(n): st.append([]) rr.append([]) for _ in range(k): p,q = map(int,input().split()) st[p-1].append(q-1) st[q-1].append(p-1) for _ in range(l): p,q = map(int,input().split()) ...
s191990755
p03855
u237316771
1481429784
Python
Python (2.7.6)
py
Runtime Error
15
2568
1760
#include <bits/stdc++.h> using namespace std; int table[2][200000] = {{}, {}}; int uffind(int i, int x) { if (table[i][x] == -1) { return x; } return (table[i][x] = uffind(i, table[i][x])); } void ufunion(int i, int x, int y) { int s1 = uffind(i, x), s2 = uffind(i, y); if (s1 != s2) { table[i][s2]...
s490440463
p03856
u973972117
1600028547
Python
Python (3.8.2)
py
Runtime Error
41
9168
411
S = input() N = len(S) i = 0 while i < N: sig = 0 S5 = S[i:i+5] if S5 == 'dream': sig = 1 if S[i+5:i+7] == 'er' and S[i+7] != 'a': i += 2 i += 5 elif S5 == 'erase': sig = 1 if S[i+5:i+6] == 'r': i += 1 i += 5 if sig == 0: ...
s184391707
p03856
u973972117
1600028511
Python
Python (3.8.2)
py
Runtime Error
39
9156
411
S = input() N = len(S) i = 0 while i < N: sig = 0 S5 = S[i:i+5] if S5 == 'dream': sig = 1 if S[i+5:i+7] == 'er' and S[i+7] != 'a': i += 2 i += 5 elif S5 == 'erase': sig = 1 if S[i+5:i+6] == 'r': i += 1 i += 5 if sig == 0: ...
s480912085
p03856
u973972117
1600028462
Python
Python (3.8.2)
py
Runtime Error
38
9136
411
S = input() N = len(S) i = 0 while i < N: sig = 0 S5 = S[i:i+5] if S5 == 'dream': sig = 1 if S[i+5:i+7] == 'er' and S[i+7] != 'a': i += 2 i += 5 elif S5 == 'erase': sig = 1 if S[i+5:i+6] == 'r': i += 1 i += 5 if sig == 0: ...
s573952995
p03856
u018679195
1597693252
Python
Python (3.8.2)
py
Runtime Error
27
9180
218
s=input() s=s.replace('eraser','#') s=s.replace('erase','#') s=s.replace('dreamer','#') s=s.replace('dream') f=1 for it in s: if it !='#': f=0 break if f==1: print("YES") else : print("NO")
s673481865
p03856
u554590385
1596770889
Python
Python (3.8.2)
py
Runtime Error
23
8968
358
S=input() for x in S: if("dream" in S and "erase" in S): print("YES") break elif("dream" in S and "eraser" in S): print("YES") break elif( "dreamer" in S and "erase" in S): print("YES") break if( "dreamer" in S and "eraser" in S): print("YES") ...
s850062014
p03856
u102242691
1585394079
Python
Python (3.4.3)
py
Runtime Error
2104
3316
258
s = input() l = ["eraser","erase","dreamer","dream"] while len(s) > 0: for i in range(len(l)): if l[i] in s: s = s.replase(l[i],"") else: break if len(s) == 0: print("YES") else: print("NO")
s766839335
p03856
u102242691
1585394052
Python
Python (3.4.3)
py
Runtime Error
17
3188
258
s = input() l = ["dream","dreamer","erase","eraser"] while len(s) > 0: for i in range(len(l)): if l[i] in s: s = s.replase(l[i],"") else: break if len(s) == 0: print("YES") else: print("NO")
s752058154
p03856
u983918956
1574814735
Python
PyPy3 (2.4.0)
py
Runtime Error
182
42576
1885
def main(): import sys input = sys.stdin.readline from collections import defaultdict class Unionfind: __slots__ = ['parents','sizes'] def __init__(self, n): self.parents = list(range(n)) self.sizes = [1]*n def root(self, x): if self.paren...
s429548972
p03856
u405660020
1567975191
Python
Python (3.4.3)
py
Runtime Error
20
3188
143
s=input() s=s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","") if s: print("NO") else: print("YES")
s494798780
p03856
u947883560
1561025120
Python
Python (3.4.3)
py
Runtime Error
127
98476
711
#!/usr/bin/env python3 import sys INF = float("inf") def yes(): print("YES") # type: str def no(): print("NO") # type: str template = ["dream", "dreamer", "erase", "eraser"] def dfs(s): if len(s) == 0: return True for t in template: if s.startswith(t): if dfs(s[len(...
s181584945
p03856
u367130284
1556509176
Python
Python (3.4.3)
py
Runtime Error
21
3564
1717
from collections import* class UNION_FIND(object): def __init__(self,n): #親の番号を格納する。親だった場合は-(その集合のサイズ) #作るときはParentの値を全て-1にする #こうすると全てバラバラになる self.parent=[-1 for i in range(n)] def root(self,x): #Aがどのグループに属しているか調べる if self.parent[x]<0: return ...
s703633877
p03856
u623819879
1554958629
Python
PyPy3 (2.4.0)
py
Runtime Error
168
42480
1234
# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**9) from collections import Counter from collections import defaultdict n,k,l=map(int,input().split()) p=[0]*(k+1) q=[0]*(k+1) rd=[[] for _ in range(n+1)] r=[0]*(l+1) s=[0]*(l+1) rw=[[] for _ in range(n+1)] for i in range(k): a,b=map(int,input(...
s061885079
p03856
u280512618
1551645563
Python
Python (3.4.3)
py
Runtime Error
2104
3444
497
from collections import deque def solve(s): que = deque() que.append(s) while len(que) > 0: top = que.pop() if top == '': return 'YES' if top[:5] == 'dream': if top[5:7] == 'er': que.append(s[:7]) que.append(s[:5]) elif to...
s345262493
p03856
u280512618
1551644854
Python
Python (3.4.3)
py
Runtime Error
18
3188
214
s = input() while s != '': if s[:5] == 'dream' or s[:5] == 'erase': if s[5] == 'r': s = s[6:] else: s = s[5:] else: print('NO') quit(0) print('YES')
s423214975
p03856
u280512618
1551644817
Python
Python (3.4.3)
py
Runtime Error
18
2940
213
s = input() while s != '': if s[:5] == 'dream' or s[:5] == 'erase': if s[5] = 'r': s = s[6:] else: s = s[5:] else: print('NO') quit(0) print('YES')
s104421300
p03856
u593063683
1549623944
Python
Python (3.4.3)
py
Runtime Error
127
7368
590
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Feb 8 05:12:38 2019 @author: shinjisu """ def db(x): global debug if debug: print(x) def gen(tstr): if len(tstr) <= len(S): for w in words: yield w + tstr for w2 in gen(w + tstr): ...
s408627313
p03856
u054106284
1548770327
Python
Python (3.4.3)
py
Runtime Error
81
3188
369
S = ' ' + input() while True: if len(S) >= 5 and S[len(S)-5:] == 'dream': S = S[:len(S)-5] elif len(S) >= 7 and S[len(S)-7:] == 'dreamer': S = S[:len(S)-7] elif len(S) >= 5 and S[len(S)-5:] == 'erase': S = S[:len(S)-5] elif len(S) >= 6 and S[len(S)-6:] == 'eraser': S = S[:len(S)-6] else: b...
s784478548
p03856
u054106284
1548769945
Python
Python (3.4.3)
py
Runtime Error
79
3188
356
S = input() while True: if len(S) >= 5 and S[len(S)-5:] == 'dream': S = S[:len(S)-5] elif len(S) >= 7 and S[len(S)-7:] == 'dreamer': S = S[:len(S)-7] elif len(S) >= 5 and S[len(S)-5:] == 'erase': S = S[:len(S)-5] elif len(S) >= 6 and S[len(S)-6:] == 'eraser': S = S[:len(S)-6] else: break i...
s446890033
p03856
u054106284
1548769154
Python
Python (3.4.3)
py
Runtime Error
2104
3188
356
S = input() while True: if len(S) >= 5 and S[len(S)-5:] == 'dream': S = S[len(S)-5:] elif len(S) >= 7 and S[len(S)-7:] == 'dreamer': S = S[len(S)-7:] elif len(S) >= 5 and S[len(S)-5:] == 'erase': S = S[len(S)-5:] elif len(S) >= 6 and S[len(S)-6:] == 'eraser': S = S[len(S)-6:] else: break i...
s686783264
p03856
u054106284
1548768986
Python
Python (3.4.3)
py
Runtime Error
2104
3188
356
S = input() while True: if len(S) >= 5 and S[len(S)-5:] == 'dream': S = S[len(S)-5:] elif len(S) >= 7 and S[len(S)-7:] == 'dreamer': S = S[len(S)-7:] elif len(S) >= 5 and S[len(S)-5:] == 'erase': S = S[len(S)-5:] elif len(S) >= 6 and S[len(S)-6:] == 'eraser': S = S[len(S)-6:] else: break i...
s285937396
p03856
u054106284
1548768907
Python
Python (3.4.3)
py
Runtime Error
20
3188
352
S = input() while True: if len(S) >= 5 and S[len(S)-5:] == 'dream': S = S[len(S)-5] elif len(S) >= 7 and S[len(S)-7:] == 'dreamer': S = S[len(S)-7] elif len(S) >= 5 and S[len(S)-5:] == 'erase': S = S[len(S)-5] elif len(S) >= 6 and S[len(S)-6:] == 'eraser': S = S[len(S)-6] else: break if S:...
s933656095
p03856
u054106284
1548768824
Python
Python (3.4.3)
py
Runtime Error
19
3188
337
S = input() while True: if len(S) >= 5 and S[len(S)-5:] == 'dream': S = S[len(S)-5] elif len(S) >= 7 and S[len(S)-7:] == 'dreamer': S = S[len(S)-7] elif len(S) >= 5 and S[len(S)-5:] == 'erase': S = S[len(S)-5] elif len(S) >= 6 and S[len(S)-6:] == 'eraser': S = S[len(S)-6] else: break if S: print(YES) e...
s604224220
p03856
u054106284
1548768773
Python
Python (3.4.3)
py
Runtime Error
18
3188
337
S = input() while True: if len(S) >= 5 and S[len(S)-5:] == 'dream': S = S[len(S)-5] elif len(S) >= 7 and S[len(S)-7:] == 'dreamer': S = S[len(S)-7] elif len(S) >= 5 and S[len(S)-7:] == 'erase': S = S[len(S)-5] elif len(S) >= 7 and S[len(S)-7:] == 'eraser': S = S[len(S)-6] else: break if S: print(YES) e...
s159476943
p03856
u054106284
1548768622
Python
Python (3.4.3)
py
Runtime Error
18
3188
336
S = input() while True: if len(S) >= 5 and S[len(s)-5:] == 'dream': S = S[len(s)-5] elif len(S) >= 7 and S[len(s)-7:] == 'dreamer': S = S[len(s)-7] elif len(S) >= 5 and S[len(s)-7:] == 'erase': S = S[len(s)-5] elif len(S) >= 7 and S[len(s)-7:] == 'eraser': S = S[len(s)-6] else: break if S: print(YES) e...