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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s032683688 | p03854 | u143492911 | 1518065603 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 144 | s=input().replace("erase","").replace("dream",""),replace("eraser","").replace("dreamer","")
if s in "":
print("YES")
else:
print("NO")
|
s956958532 | p03854 | u875361824 | 1515188944 | Python | Python (3.4.3) | py | Runtime Error | 84 | 4316 | 1128 | def main():
S = input()
dfs(S)
def dfs(S):
l = len(S)
if _dfs(S, l, 0):
print("YES")
else:
print("NO")
def _dfs(S, l, idx, pattern=0):
# print(l, idx, pattern)
if idx == l:
return True
if S[idx:idx + 7] == "dreamer":
ok = _dfs(S, l, idx + 7, 1)
... |
s296629631 | p03854 | u652737716 | 1501637020 | Python | Python (3.4.3) | py | Runtime Error | 177 | 134396 | 459 | import sys
S = input()
while S:
prefix = S[0:5]
if prefix == 'dream':
if S[5:7] == 'er':
if len(S) >= 8 and S[7] == 'a':
S = S[5:]
else:
S = S[7:]
else:
S = S[5:]
elif prefix == 'erase':
if len(S) >= 6 and S[5] == ... |
s458241190 | p03854 | u652737716 | 1501636814 | Python | Python (3.4.3) | py | Runtime Error | 68 | 3188 | 444 | import sys
S = input()
while S:
prefix = S[0:5]
if prefix == 'dream':
if S[5:7] == 'er':
if len(S) > 8 and S[7] == 'a':
S = S[5:]
else:
S = S[7:]
else:
S = S[5:]
elif prefix == 'erase':
if S[5] == 'r':
... |
s543172931 | p03854 | u652737716 | 1501636739 | Python | Python (3.4.3) | py | Runtime Error | 68 | 3188 | 429 | import sys
S = input()
while S:
prefix = S[0:5]
if prefix == 'dream':
if S[5:7] == 'er':
if S[7] == 'a':
S = S[5:]
else:
S = S[7:]
else:
S = S[5:]
elif prefix == 'erase':
if S[5] == 'r':
S = S[6:]
... |
s431358455 | p03854 | u841907810 | 1492546443 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 2542 | import java.lang.*;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws java.lang.Exception {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(out... |
s176496337 | p03854 | u432042540 | 1492011288 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3316 | 524 | s = input()
# t = ['dream', 'dreamer', 'erase', 'eraser']
s = s[::-1]
for i in range(4):
t[i] = t[i][::-1]
# print(s,t)
tmp = s
while tmp != '':
d = tmp[:5] == 'maerd'
dr = tmp[:7] == 'remaerd'
e = tmp[:5] == 'esare'
er = tmp[:6] == 'resare'
# print(tmp[:5])
# print(d,dr,e,er)
if d... |
s488119986 | p03854 | u484412230 | 1490916774 | Python | Python (3.4.3) | py | Runtime Error | 124 | 98616 | 722 | input = input()
# 前から一意に分解することができないので, 後ろから分解していくことになる
reversed_str = input[::-1]
dream = 'dream'
dreamer = 'dreamer'
erase = 'erase'
eraser = 'eraser'
dream = dream[::-1]
dreamer = dreamer[::-1]
erase = erase[::-1]
eraser = eraser[::-1]
def check(str):
if str == '':
return True
if len(str) < 5:
... |
s846499492 | p03854 | u484412230 | 1490916324 | Python | Python (3.4.3) | py | Runtime Error | 137 | 98624 | 1195 | input = input()
"""
def check(str):
# 終了条件が分からない
str0 = str + 'dream'
str1 = str + 'dreamer'
str2 = str + 'erase'
str3 = str + 'eraser'
print(str)
if str0 == input or str1 == input or str2 == input or str3 == input:
return True
check(str0)
check(str1)
check(str2)
c... |
s004772024 | p03854 | u338686846 | 1487799948 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2692 | 171 | S = raw_input()
S = S.strip("dream", "")
S = S.strip("dreamer", "")
S = S.strip("erase", "")
S = S.strip("eraser", "")
if len(S)==0:
print 'YES'
else:
print 'NO'
|
s348575842 | p03854 | u010110540 | 1487008688 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 221 | l = ['dream', 'dreamer', 'erase', 'eraser']
S = input()
while len(S) > 0:
flag = False
for d in l:
if S.endswith(d):
S = S[:-len(d)]
flag = True
break
if flag = False:
print('NO')
exit()
print('YES') |
s816162644 | p03854 | u012694084 | 1485025444 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3188 | 285 | words = ("dream", "erase", "eraser", "dreamer")
s = input()
while len(s) > 0:
match = False
for w in words:
if s.endwith(w):
s = s[:-len(w)]
match = True
break
if match is False:
print("NO")
exit()
print("YES")
|
s176263284 | p03854 | u386131832 | 1482426274 | Python | Python (3.4.3) | py | Runtime Error | 1838 | 6976 | 254 | import sys
def DFS(list,s,t):
if s==t:
print("YES")
sys.exit()
if not t in s:
return
for i in list:
DFS(list,s,t+i)
list=["maerd","remaerd","esare","resare"]
s=input()
s=s[::-1]
t=""
DFS(list,s,t)
print("NO") |
s209287187 | p03854 | u674122790 | 1482026960 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2692 | 498 | s = raw_input(); i = 0; d = 1
# dreamerase eraser
while i < len(s):
if s.startswith(i,i+len('dreamerase')):
i += len('dreamerase')
elif s.startswith(i,i+len('dreameraser')):
i += len('dreameraser')
elif s.startswith(i,i+len('dream')):
i += len('dream')
elif s.startswith(i,i+len('dreamer')):
i += len('dreame... |
s902923824 | p03854 | u733353761 | 1481849097 | Python | Python (3.4.3) | py | Runtime Error | 235 | 98628 | 299 | #cording : utf-8
strset = ["dream","dreamer","erase","eraser"]
def check(str):
if str is "":
return True
for s in strset:
if str.startswith(s):
if check(str.split(s,1)[1]):
return True
return False
print("YES" if check(input()) else "NO")
|
s259269041 | p03854 | u317493066 | 1481607245 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3316 | 387 | # -*- coding:utf-8 -*-
DREAM = "dream"
DREAMER = "dreamer"
ERASE = "erase"
ERASER = "eraser"
text = input()
while(len(text) > 0):
if text[-5:] == DREAM:
text = text[:-5]
elif text[-6:] == DREAMER:
text = text[:-6]
elif text[-5:] == ERASE:
text = text[:-5]
else:
text = ... |
s949950457 | p03854 | u317493066 | 1481607177 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3068 | 368 | # -*- coding:utf-8 -*-
DREAM = "dream"
DREAMER = "dreamer"
ERASE = "erase"
ERASER = "eraser"
text = input()
while(len(text):
if text[-5:] == DREAM:
text = text[:-5]
elif text[-6:] == DREAMER:
text = text[:-6]
elif text[-5:] == ERASE:
text = text[:-5]
else:
text = text[... |
s848919374 | p03854 | u582243208 | 1481428089 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3192 | 141 | a=["eraser","erase","dreamer","dream"]
s=input()
for i in range(4):
s=s.replace(a[i],"")
if s="":
print("YES")
else:
print("NO") |
s314218079 | p03854 | u096190786 | 1481426981 | Python | Python (2.7.6) | py | Runtime Error | 165 | 98172 | 561 | #!/usr/bin/python
import re
import sys
TOKENS = ["dream", "dreamer", "erase", "eraser"]
def check(s):
if s in TOKENS:
return "YES"
else:
if len(s) > 5 and s[-5:] in [TOKENS[0], TOKENS[2]]:
return check(s[0:-5])
elif len(s) > 6 and s[-6:] == TOKENS[3]:
return ch... |
s579253402 | p03855 | u137226361 | 1600235536 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 33672 | 1007 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
root_x = find(x, par)
root_y = find(y, par)
if root_y > root_x:
par[root_x] = root_y
else:
par[roo... |
s372885073 | p03855 | u137226361 | 1600235307 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 43616 | 572 | from collections import Counter
n,k,l=map(int,input().split())
city1=[i for i in range(n)]
city2=[i for i in range(n)]
def root(c,x):
if x==c[x]:
return x
else:
return root(c,c[x])
def union(c,x,y):
rx=root(c,x)
ry=root(c,y)
c[rx]=ry
for i in range(k):
a,b=map(int,input().split())
union(city1,... |
s131406784 | p03855 | u137226361 | 1600235120 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 26624 | 597 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
root_x = find(x, par)
root_y = find(y, par)
par[root_x] = root_y
par2 = [i for i in range(N)]
def unite2(x, y):
... |
s011500855 | p03855 | u137226361 | 1600232996 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 26700 | 695 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
root_x = find(x, par)
root_y = find(y, par)
if root_x != root_y:
# xとyの属している集合が異なる時
pass
par[... |
s647382219 | p03855 | u137226361 | 1600232761 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 26720 | 665 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
x = find(x, par)
y = find(y, par)
if x != y:
# xとyの属している集合が異なる時
pass
par[x] = y
par2 = [i fo... |
s395015795 | p03855 | u137226361 | 1600232593 | Python | Python (3.8.2) | py | Runtime Error | 231 | 25964 | 629 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
x = find(x, par)
y = find(y, par)
if x != y:
# xとyの属している集合が異なる時
par[x] = y
par2 = [i for i in range(... |
s166579128 | p03855 | u137226361 | 1600232359 | Python | Python (3.8.2) | py | Runtime Error | 2205 | 26696 | 632 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
x = find(x, par)
y = find(y, par)
if x != y:
# xとyの属している集合が異なる時
par[x] = y
par2 = [i for i in range(... |
s784290067 | p03855 | u137226361 | 1600232281 | Python | Python (3.8.2) | py | Runtime Error | 2205 | 26840 | 686 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
x = find(x, par)
y = find(y, par)
if x != y:
# xとyの属している集合が異なる時
par[x] = y
par2 = [i for i in range(... |
s760793849 | p03855 | u137226361 | 1600231918 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 26700 | 979 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
x = find(x, par)
y = find(y, par)
if x != y:
# xとyの属している集合が異なる時
par[x] = y
par2 = [i for i in range... |
s498938889 | p03855 | u137226361 | 1600229267 | Python | Python (3.8.2) | py | Runtime Error | 583 | 26324 | 935 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, par):
if par[x] == x:
return x
else:
par[x] == find(par[x], par)
return par[x]
def unite(x, y):
x = find(x, par)
y = find(y, par)
if x != y:
# xとyの属している集合が異なる時
par[... |
s678929487 | p03855 | u137226361 | 1600188967 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 28448 | 868 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
rank = [1] * N
def find(x, par):
if par[x] == x:
return x
else:
return find(par[x], par)
def unite(x, y):
x = find(x, par)
y = find(y, par)
if x != y:
# xとyの属している集合が異なる時
par[x] = y
pa... |
s004993650 | p03855 | u074220993 | 1599175436 | Python | Python (3.8.2) | py | Runtime Error | 50 | 24496 | 598 | N, K, L = map(int, input().split())
#Parent List(PL)
road = [i for i in range(N)]
rail = [i for i in range(N)]
def fp(x,P): #findParent
if x == P[x]:
return x
else:
P[x] = fp(P[x])
return P[x]
for i in range(K+L):
PL = (lambda x:road if x < K else rail)(i)
p, q = map(lambda x:i... |
s922971733 | p03855 | u682672120 | 1598467890 | Python | PyPy3 (7.3.0) | py | Runtime Error | 553 | 83148 | 851 | n, k, l = map(int, input().split())
roads = list(range(n))
railways = list(range(n))
ans = []
for _ in range(k):
a, b = map(lambda x : int(x) - 1, input().split())
i = min(roads[a], roads[b])
roads[roads[a]], roads[a] = i, i
roads[roads[b]], roads[b] = i, i
for _ in range(l):
a, b = map(lambda x : i... |
s325644903 | p03855 | u682672120 | 1598467075 | Python | PyPy3 (7.3.0) | py | Runtime Error | 510 | 83172 | 843 | n, k, l = map(int, input().split())
roads = list(range(n))
railways = list(range(n))
ans = []
for _ in range(k):
a, b = map(lambda x : int(x) - 1, input().split())
i = min(roads[a], roads[b])
roads[roads[a]] = roads[a] = i
roads[roads[b]] = roads[b] = i
for _ in range(l):
a, b = map(lambda x : int(x... |
s850746534 | p03855 | u682672120 | 1598466897 | Python | PyPy3 (7.3.0) | py | Runtime Error | 533 | 83324 | 1110 | n, k, l = map(int, input().split())
roads = list(range(n))
railways = list(range(n))
ans = []
for _ in range(k):
a, b = map(lambda x : int(x) - 1, input().split())
i = min(roads[a], roads[b])
roads[roads[a]] = roads[a] = i
roads[roads[b]] = roads[b] = i
for _ in range(l):
a, b = map(lambda x : ... |
s046751781 | p03855 | u756464404 | 1597757557 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 52692 | 822 | import sys
import numpy as np
input = sys.stdin.readline
def main():
n, k, l = map(int, input().split())
road_matrix = np.identity(n, dtype='bool')
train_matrix = np.identity(n, dtype='bool')
for _ in range(k):
p, q = map(int, input().split())
p, q = p-1, q-1
road_matrix[p][q] = 1
road_matrix[... |
s915703560 | p03855 | u074220993 | 1597206000 | Python | Python (3.8.2) | py | Runtime Error | 25 | 8948 | 1397 | #include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
long set_index;
void dfs(Graph graph, vector<bool>& seen, vector<int>& set, int v){
seen[v] = true;
set[v] = set_index;
for (auto next_v : graph[v]){
if (seen[next_v]) continue;
dfs(graph, seen, set, next_v);
... |
s129218142 | p03855 | u074220993 | 1597204190 | Python | Python (3.8.2) | py | Runtime Error | 1585 | 176152 | 1003 | N, K, L = map(int, input().split())
road = [{"Connected":[],"seen":False,"set":0} for _ in range(N)]
rail = [{"Connected":[],"seen":False,"set":0} for _ in range(N)]
def dfs(graph, v, index): #深さ優先探索
graph[v]["seen"] = True
graph[v]["set"] = index
for next_v in graph[v]["Connected"]:
if graph[next_... |
s850043782 | p03855 | u074220993 | 1597203330 | Python | Python (3.8.2) | py | Runtime Error | 1569 | 177984 | 984 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"seen":False,"set":0} for _ in range(200000)]
rail = [{"Connected":[],"seen":False,"set":0} for _ in range(200000)]
def dfs(graph, v, index): #深さ優先探索
graph[v]["seen"] = True
graph[v]["set"] = index
for next_v in graph[v]["Connec... |
s740774940 | p03855 | u074220993 | 1597202863 | Python | Python (3.8.2) | py | Runtime Error | 1595 | 176384 | 992 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"seen":False,"set":0} for _ in range(N)]
rail = [{"Connected":[],"seen":False,"set":0} for _ in range(N)]
def dfs(graph, v, index): #深さ優先探索
graph[v]["seen"] = True
graph[v]["set"] = index
for next_v in graph[v]["Connected"]:
... |
s120647723 | p03855 | u074220993 | 1597202375 | Python | Python (3.8.2) | py | Runtime Error | 1599 | 176248 | 976 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"seen":False,"set":-1} for _ in range(N)]
rail = [{"Connected":[],"seen":False,"set":-1} for _ in range(N)]
def dfs(graph, v, index): #深さ優先探索
graph[v]["seen"] = True
graph[v]["set"] = index
for next_v in graph[v]["Connected"]:
... |
s592727687 | p03855 | u074220993 | 1597201715 | Python | Python (3.8.2) | py | Runtime Error | 1547 | 176444 | 958 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"seen":False} for _ in range(N)]
rail = [{"Connected":[],"seen":False} for _ in range(N)]
def dfs(graph, v, index): #深さ優先探索
graph[v]["seen"] = True
graph[v]["set"] = index
for next_v in graph[v]["Connected"]:
if graph[ne... |
s990453435 | p03855 | u074220993 | 1597168974 | Python | Python (3.8.2) | py | Runtime Error | 1684 | 177060 | 978 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"set":0,"seen":False} for _ in range(N)]
rail = [{"Connected":[],"set":0,"seen":False} for _ in range(N)]
def dfs(graph, v, num): #深さ優先探索
graph[v]["seen"] = True
graph[v]["set"] = num
for next_v in set(graph[v]["Connected"]):
... |
s072131589 | p03855 | u074220993 | 1597168533 | Python | Python (3.8.2) | py | Runtime Error | 1659 | 176392 | 977 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"set":0,"seen":False} for _ in range(N+1)]
rail = [{"Connected":[],"set":0,"seen":False} for _ in range(N+1)]
def dfs(graph, v, num): #深さ優先探索
graph[v]["seen"] = True
graph[v]["set"] = num
for next_v in graph[v]["Connected"]:
... |
s712780586 | p03855 | u074220993 | 1597168389 | Python | Python (3.8.2) | py | Runtime Error | 1581 | 176284 | 973 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"set":0,"seen":False} for _ in range(N)]
rail = [{"Connected":[],"set":0,"seen":False} for _ in range(N)]
def dfs(graph, v, num): #深さ優先探索
graph[v]["seen"] = True
graph[v]["set"] = num
for next_v in graph[v]["Connected"]:
... |
s808992891 | p03855 | u074220993 | 1597168012 | Python | Python (3.8.2) | py | Runtime Error | 1540 | 167128 | 942 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"set":0,"seen":False} for _ in range(N)]
rail = [{"Connected":[],"set":0,"seen":False} for _ in range(N)]
def dfs(node, num): #深さ優先探索
node["seen"] = True
node["set"] = num
for next_node in node["Connected"]:
if next_node... |
s334071676 | p03855 | u074220993 | 1597167455 | Python | Python (3.8.2) | py | Runtime Error | 1592 | 167036 | 952 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"set":-1,"seen":False} for i in range(N)]
rail = [{"Connected":[],"set":-1,"seen":False} for i in range(N)]
def dfs(node, num): #深さ優先探索
node["seen"] = True
node["set"] = num
for next_node in node["Connected"]:
if next_no... |
s179746303 | p03855 | u074220993 | 1597167063 | Python | Python (3.8.2) | py | Runtime Error | 1559 | 167092 | 1007 | import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"set":-1,"seen":False} for i in range(N)]
rail = [{"Connected":[],"set":-1,"seen":False} for i in range(N)]
def dfs(node, num): #深さ優先探索
node["seen"] = True
node["set"] = num
for next_node in node["Connected"]:
if next_no... |
s105664243 | p03855 | u074220993 | 1597166072 | Python | Python (3.8.2) | py | Runtime Error | 2211 | 221748 | 1094 | import collections
N, K, L = map(int, input().split())
city = [{"road":{"Connected":[],"set":-1,"seen":False},
"rail":{"Connected":[],"set":-1,"seen":False}} for i in range(N)]
def dfs(graph, v, way, num): #深さ優先探索
graph[v][way]["seen"] = True
graph[v][way]["set"] = num
for next_v in graph[v][way][... |
s949217442 | p03855 | u074220993 | 1597165118 | Python | Python (3.8.2) | py | Runtime Error | 2210 | 236600 | 1040 | import collections
N, K, L = map(int, input().split())
city = [{"road":{"Connected":[i],"set":-1,"seen":False},
"rail":{"Connected":[i],"set":-1,"seen":False}} for i in range(N)]
def dfs(graph, v, way, num):
graph[v][way]["seen"] = True
graph[v][way]["set"] = num
for next_v in graph[v][way]["Connec... |
s357043216 | p03855 | u074220993 | 1597164568 | Python | Python (3.8.2) | py | Runtime Error | 2213 | 236408 | 1066 | import collections
N, K, L = map(int, input().split())
city = [{"road":{"Connected":[i],"group":-1,"seen":False},
"rail":{"Connected":[i],"group":-1,"seen":False}} for i in range(N)]
def dfs(graph, v, way, num):
graph[v][way]["seen"] = True
graph[v][way]["group"] = num
for next_v in graph[v][way]["... |
s928601601 | p03855 | u074220993 | 1597164000 | Python | Python (3.8.2) | py | Runtime Error | 2212 | 236548 | 1055 | import collections
N, K, L = map(int, input().split())
city = [{"road":{"Connected":[i],"seen":-1}, "rail":{"Connected":[i],"seen":-1}} for i in range(N)]
def dfs(graph, v, way, num):
graph[v][way]["seen"] = num
for next_v in graph[v][way]["Connected"]:
if graph[next_v][way]["seen"] >= 0:
co... |
s579035082 | p03855 | u074220993 | 1597161328 | Python | Python (3.8.2) | py | Runtime Error | 2211 | 221600 | 1215 | N, K, L = map(int, input().split())
city = [{"road":{"Connected":[i],"seen":False}, "rail":{"Connected":[i],"seen":False}} for i in range(N)]
Connected_Components = {"road":list(),"rail":list()}
def dfs(graph, v, way, List):
graph[v][way]["seen"] = True
List.append(v)
for next_v in graph[v][way]["Connected"... |
s618323531 | p03855 | u074220993 | 1597127363 | Python | Python (3.8.2) | py | Runtime Error | 33 | 10552 | 554 | N, K, L = map(int, input().split())
city = [1 for i in range(N)]
setA = set()
setB = set()
for i in range(K):
X = set(int(x)-1 for x in input().split())
for A in setA:
if A & X != set():
A = A | X
else:
setA.add(X)
for i in range(L):
Y = set(int(y)-1 for y in input().split())... |
s949264613 | p03855 | u730769327 | 1596376694 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2213 | 224112 | 767 | def dfs(now,vis,e,j,el):
vis+=[now]
e[now]=j
res=set([now])
for to in el[now]:
if to in vis:continue
res=res|dfs(to,vis[:],e,j,el)
e[to]=j
return res
n,k,l=map(int,input().split())
el=[set() for _ in range(n+1)]
et=[set() for _ in range(n+1)]
ela=[set() for _ in range(n+1)]
eta=[set() for _ in ran... |
s456928215 | p03855 | u825955102 | 1595884110 | Python | PyPy3 (7.3.0) | py | Runtime Error | 773 | 179556 | 1193 | import collections
NO_OF_DIMENSIONS = 2
no_of_edges_by_dim = [0] * NO_OF_DIMENSIONS
n, no_of_edges_by_dim[0], no_of_edges_by_dim[1] = (int(x) for x in input().split())
graph_by_dimension = [[[] for _ in range(n + 1)] for _ in range(NO_OF_DIMENSIONS)]
for dimension, no_of_edges in enumerate(no_of_edges_by_dim):
g... |
s038742950 | p03855 | u786020649 | 1594755385 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9076 | 2706 | import sys
from collections import deque
from collections import defaultdict
from collections import Counter
def conn(n,m,e):
d=dict(zip(range(1,n+1),range(-1,(-1)*n-1,-1)))
td=defaultdict(lambda:deque([])) #tdは同値類がキーで中の元が値
c=1
for edge in e:
a=edge[0]
b=edge[1]
da=d[a] #da,dbはa... |
s812404422 | p03855 | u786020649 | 1594755334 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9092 | 2706 | import sys
from collections import deque
from collections import defaultdict
from collections import Counter
def conn(n,m,e):
d=dict(zip(range(1,n+1),range(-1,(-1)*n-1,-1)))
td=defaultdict(lambda:deque([])) #tdは同値類がキーで中の元が値
c=1
for edge in e:
a=edge[0]
b=edge[1]
da=d[a] #da,dbはa... |
s577473156 | p03855 | u072717685 | 1589146288 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 132596 | 2627 | import sys
input = sys.stdin.readline
road = {}
train = {}
node_seen = set()
road_belong_group = {}
train_belong_group = {}
road_group = {}
train_group = {}
def dfs_road(t_node, group_num):
global road_group, road_belong_group, node_seen
road_belong_group[t_node] = group_num
road_group[group_num].add(t_no... |
s817166188 | p03855 | u072717685 | 1589145866 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 132596 | 2628 | import sys
input = sys.stdin.readline
road = {}
train = {}
node_all = set()
node_seen = set()
road_belong_group = []
train_belong_group = []
road_group = {}
train_group = {}
def dfs_road(t_node, group_num):
global road_group, road_belong_group, node_seen
road_belong_group[t_node] = group_num
road_group[gr... |
s852900069 | p03855 | u072717685 | 1589144255 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2113 | 208500 | 2877 |
import sys
input = sys.stdin.readline
road = {}
train = {}
node_all = set()
node_seen = set()
road_belong_group = []
train_belong_group = []
road_group = {}
train_group = {}
def dfs_road(t_node, group_num):
global road_group, road_belong_group, node_seen
road_belong_group[t_node] = group_num
road_group[g... |
s448012078 | p03855 | u072717685 | 1589143857 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2113 | 205160 | 2729 | import sys
input = sys.stdin.readline
road = {}
train = {}
node_all = set()
node_seen = set()
road_belong_group = []
train_belong_group = []
road_group = {}
train_group = {}
def dfs_road(t_node, group_num):
global road_group, road_belong_group, node_seen
road_belong_group[t_node] = group_num
road_group[gr... |
s414672834 | p03855 | u072717685 | 1589141921 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2111 | 169012 | 2872 |
import sys
input = sys.stdin.readline
large_p = 10**9 + 7
road = {}
train = {}
node_all = set()
node_seen = set()
road_belong_group = []
train_belong_group = []
road_group = {}
train_group = {}
def dfs_road(t_node, group_num):
global node_seen, road_group, road_belong_group
node_seen.add(t_node)
road_bel... |
s036232867 | p03855 | u072717685 | 1589141386 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 115128 | 2852 |
import sys
input = sys.stdin.readline
road = {}
train = {}
node_all = set()
node_seen = set()
road_belong_group = []
train_belong_group = []
road_group = {}
train_group = {}
def dfs_road(t_node, group_num):
global node_seen, road_group, road_belong_group
node_seen.add(t_node)
road_belong_group[t_node] = ... |
s714685253 | p03855 | u197457087 | 1588638648 | Python | Python (3.4.3) | py | Runtime Error | 53 | 14288 | 1728 | class UnionFind(object):
def __init__(self, n=1):
self.par = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
self.size = [1 for _ in range(n)]
def find(self, x):
"""
x が属するグループを探索
"""
if self.par[x] == x:
return x
else:
... |
s506473072 | p03855 | u892487306 | 1588344806 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 2006 | import sys
sys.setrecursionlimit(10**12)
class UnionFind:
def __init__(self, n):
self.n = n
# access m-th node by index `m`, not `m - 1`
self.roots = [i for i in range(n + 1)]
self.ranks = [0 for _ in range(n + 1)]
self.group_sizes = [1 for _ in range(n + 1)]
def find... |
s601112638 | p03855 | u892487306 | 1588344691 | Python | Python (3.4.3) | py | Runtime Error | 1426 | 675504 | 2006 | import sys
sys.setrecursionlimit(10**7)
class UnionFind:
def __init__(self, n):
self.n = n
# access m-th node by index `m`, not `m - 1`
self.roots = [i for i in range(n + 1)]
self.ranks = [0 for _ in range(n + 1)]
self.group_sizes = [1 for _ in range(n + 1)]
def find_... |
s506111631 | p03855 | u892487306 | 1588343888 | Python | Python (3.4.3) | py | Runtime Error | 204 | 14928 | 1964 | class UnionFind:
def __init__(self, n):
self.n = n
# access m-th node by index `m`, not `m - 1`
self.roots = [i for i in range(n + 1)]
self.ranks = [0 for _ in range(n + 1)]
self.group_sizes = [1 for _ in range(n + 1)]
def find_root(self, node):
root_node = self... |
s608324154 | p03855 | u346812984 | 1588031293 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 13964 | 1778 | import sys
sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7
def input():
return sys.stdin.readline().strip()
class UnionFind:
def __init__(self, n_nodes):
self.n_nodes = n_nodes
self.parents = [-1] * n_nodes
def find(self, x):
if self.parents[x] < 0:
... |
s362561657 | p03855 | u292978925 | 1586538506 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1112 | """
in1 = '7 4 4'
in2 = ['1 2', '2 3', '2 5', '6 7', '3 5', '4 5', '3 4', '6 7']
N, K, L = map(int, in1.split())
pqrs = []
for idx1 in range(K + L):
temp0, temp1 = map(int, in2[idx1].split())
pqrs.append([temp0, temp1])
"""
N, K, L = map(int, input().split())
pqrs = []
for idx1 in range(K + L):
temp0, temp1... |
s339768878 | p03855 | u292978925 | 1586537973 | Python | Python (3.4.3) | py | Runtime Error | 20 | 4596 | 1068 | """
in1 = '7 4 4'
in2 = ['1 2', '2 3', '2 5', '6 7', '3 5', '4 5', '3 4', '6 7']
N, K, L = [int(_) for _ in in1.split()]
pqrs = [[int(_) for _ in _.split()] for _ in in2]
"""
N, K, L = map(int, input().split())
pqrs = [[0] * 2] * N
for idx1 in range(N):
temp = input().sprit()
pqrs[idx1][0] = temp[0]
pqrs[id... |
s287484340 | p03855 | u292978925 | 1586537636 | Python | Python (3.4.3) | py | Runtime Error | 26 | 10740 | 1024 | """
in1 = '7 4 4'
in2 = ['1 2', '2 3', '2 5', '6 7', '3 5', '4 5', '3 4', '6 7']
N, K, L = [int(_) for _ in in1.split()]
pqrs = [[int(_) for _ in _.split()] for _ in in2]
"""
N, K, L = [int(idx1) for idx1 in input().split()]
pqrs = [[int(idx1) for idx1 in item1.split()] for item1 in input()]
def makeTree(a):
aT = ... |
s877643109 | p03855 | u292978925 | 1586537566 | Python | Python (3.4.3) | py | Runtime Error | 25 | 10864 | 1004 | """
in1 = '7 4 4'
in2 = ['1 2', '2 3', '2 5', '6 7', '3 5', '4 5', '3 4', '6 7']
N, K, L = [int(_) for _ in in1.split()]
pqrs = [[int(_) for _ in _.split()] for _ in in2]
"""
N, K, L = [int(_) for _ in input().split()]
pqrs = [[int(_) for _ in _.split()] for _ in input()]
def makeTree(a):
aT = list(range(N + 1))
... |
s327740183 | p03855 | u353797797 | 1586180517 | Python | Python (3.4.3) | py | Runtime Error | 2517 | 8800 | 1618 | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().spli... |
s625352776 | p03855 | u353797797 | 1586180082 | Python | Python (3.4.3) | py | Runtime Error | 2722 | 8672 | 1541 | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().spli... |
s420798245 | p03855 | u353797797 | 1586179506 | Python | Python (3.4.3) | py | Runtime Error | 2348 | 9440 | 1510 | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().spli... |
s776697203 | p03855 | u691018832 | 1585543175 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1603 | import sys
from collections import defaultdict
input = sys.stdin.readline
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])
... |
s963283972 | p03855 | u361381049 | 1583364815 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1051 | from sys import setrecursionlimit
setrecursionlimit(10 ** 9)
class UnionFind():
def __init__(self, n):
self.n = n
self.d = [-1] * n
def find(self, x):
if self.d[x] < 0:
return x
else:
self.d[x] = self.find(self.d[x])
return self.d[x]
def ... |
s827133956 | p03855 | u185325486 | 1582741919 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 621 | H, W = map(int, input().split())
A = [[int(i) for i in input().split()] for _ in range(H)]
dp = [[0]*W for _ in range(H)]
memo = [[-1]*W for _ in range(H)]
mod = 10**9+7
result = 0
def aaa(x,y):
move_list = [[x+1,y], [x-1, y], [x,y+1],[x,y-1]]
val = A[x][y]
cnt = 1
for new_x, new_y in move_lis... |
s831159996 | p03855 | u541610817 | 1581652122 | Python | Python (3.4.3) | py | Runtime Error | 2114 | 194204 | 859 | N, K, L = [int(x) for x in input().split()]
dict = {}
for i in range(1, N + 1):
dict[i] = [set(), set()]
dict[i][0].add(i)
dict[i][1].add(i)
for i in range(K):
p, q = [int(x) for x in input().split()]
dict[p][0].add(q)
dict[q][0].add(p)
for i in range(L):
r, s = [int(x) for x in input().spli... |
s548384246 | p03855 | u541610817 | 1581583257 | Python | Python (3.4.3) | py | Runtime Error | 2114 | 198300 | 858 | N, K, L = [int(x) for x in input().split()]
dict = {}
for i in range(1, N + 1):
dict[i] = [set(), set()]
dict[i][0].add(i)
dict[i][1].add(i)
for i in range(K):
p, q = [int(x) for x in input().split()]
dict[p][0].add(q)
dict[q][0].add(p)
for i in range(L):
r, s = [int(x) for x in input().spli... |
s107629033 | p03855 | u116348130 | 1581184485 | Python | Python (3.4.3) | py | Runtime Error | 346 | 52016 | 1719 | import sys
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):... |
s834141183 | p03855 | u386170566 | 1580082232 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 1377 | #uniontree
#D - 連結 / Connectivity
#https://atcoder.jp/contests/abc049/tasks/arc065_b
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.p... |
s568468010 | p03855 | u386170566 | 1580082135 | Python | PyPy3 (2.4.0) | py | Runtime Error | 180 | 38740 | 1377 | #uniontree
#D - 連結 / Connectivity
#https://atcoder.jp/contests/abc049/tasks/arc065_b
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.p... |
s877901172 | p03855 | u359619351 | 1579139725 | Python | PyPy3 (2.4.0) | py | Runtime Error | 207 | 44012 | 2265 | import sys
sys.setrecursionlimit(4100000)
import math
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
from unionfind import UnionFind, UnionFindCounter
def resolve():
# S = [x for x in sys.stdin.readline().split()][0] # 文字列 一つ
# N = [int(x) for x in sys.stdin... |
s170312757 | p03855 | u100418016 | 1578293177 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 141008 | 863 | import numpy as np
a,b,c= input().split(" ")
arr_x = np.repeat(0, int(a)**2).reshape(int(a), int(a))
arr_y = np.repeat(0, int(a)**2).reshape(int(a), int(a))
for i in range(int(b)):
inb = input().split(" ")
arr_x[int(inb[0])-1][int(inb[1])-1] = 1
arr_x[int(inb[1])-1][int(inb[0])-1] = 1
for i in range(int(c))... |
s362592322 | p03855 | u386170566 | 1578079788 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1366 | #D - 連結 / Connectivity
#https://atcoder.jp/contests/abc049/tasks/arc065_b
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
... |
s552411485 | p03855 | u724687935 | 1577441694 | Python | PyPy3 (2.4.0) | py | Runtime Error | 206 | 39408 | 483 | N, K, L = map(int, input().split())
uf = UnionFind(2 * N)
for _ in range(K):
p, q = map(int, input().split())
uf.union(p - 1, q - 1)
for _ in range(L):
r, s = map(int, input().split())
uf.union(r - 1 + N, s - 1 + N)
ans = [0] * N
for i in range(N):
cnt = 0
for j in range(N):
if uf.find... |
s120050385 | p03855 | u875600867 | 1576468048 | Python | Python (3.4.3) | py | Runtime Error | 457 | 7396 | 1836 | # union-find木
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)... |
s664976401 | p03855 | u875600867 | 1576467987 | Python | Python (3.4.3) | py | Runtime Error | 24 | 6260 | 1840 | # union-find木
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)... |
s606597988 | p03855 | u875600867 | 1576467846 | Python | Python (3.4.3) | py | Runtime Error | 23 | 6260 | 1899 | # union-find木
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)... |
s123526223 | p03855 | u614875193 | 1574142534 | Python | Python (3.4.3) | py | Runtime Error | 1627 | 91656 | 1107 | N,K,L=map(int,input().split())
PQ=[list(map(int,input().split())) for i in range(K)]
RS=[list(map(int,input().split())) for i in range(L)]
def find_root(root,x):
y = root[x]
if x == y:
return x
z = find_root(root,y)
root[x] = z
return z
def merge(root,size,x,y):
x = find_root(root,x)
... |
s489087108 | p03855 | u190086340 | 1574025713 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1490 | 138396 | 1675 | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
# root検索
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
def un... |
s393660490 | p03855 | u557494880 | 1573800124 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 1380 | UnionFind木
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):
... |
s756563977 | p03855 | u408620326 | 1573693429 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2108 | 114252 | 1282 | import sys
class UnionFind():
def __init__(self, N):
self.N = N
self.par = [n for n in range(N)]
self.rank = [0 for _ in range(N)]
def find(self, x):
if self.par[x] == x:
return x
self.par[x] = self.find(self.par[x])
return self.par[x]
def union... |
s843711102 | p03855 | u408620326 | 1573692329 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2108 | 112716 | 1266 | import sys
class UnionFind():
def __init__(self, N):
self.N = N
self.par = [n for n in range(N)]
self.rank = [0 for _ in range(N)]
def find(self, x):
if self.par[x] == x:
return x
self.par[x] = self.find(self.par[x])
return self.par[x]
def union... |
s081774389 | p03855 | u408620326 | 1573692155 | Python | Python (3.4.3) | py | Runtime Error | 2105 | 22960 | 1266 | import sys
class UnionFind():
def __init__(self, N):
self.N = N
self.par = [n for n in range(N)]
self.rank = [0 for _ in range(N)]
def find(self, x):
if self.par[x] == x:
return x
self.par[x] = self.find(self.par[x])
return self.par[x]
def union... |
s487067468 | p03855 | u099300051 | 1573509366 | Python | Python (3.4.3) | py | Runtime Error | 349 | 15240 | 1292 | from collections import defaultdict
class UnionFind(object):
def __init__(self,n=1):
self.par = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
self.size = [1 for _ in range(n)]
def find(self,x):
if self.par[x] == x:
return x
else:
self.par[x] == self.find(self.par[x])
... |
s055556574 | p03855 | u099300051 | 1573509209 | Python | Python (3.4.3) | py | Runtime Error | 344 | 15236 | 1291 | from collections import defaultdict
class UnionFind(object):
def __init__(self,n=1):
self.par = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
self.size = [1 for _ in range(n)]
def find(self,x):
if self.par[x] == x:
return x
else:
self.par[x] == self.find(self.par[x])
... |
s277917692 | p03855 | u375870553 | 1573330674 | Python | Python (3.4.3) | py | Runtime Error | 119 | 24948 | 1232 | import sys
sys.setrecursionlimit(10**7)
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])
... |
s332714005 | p03855 | u375870553 | 1573330306 | Python | Python (3.4.3) | py | Runtime Error | 2214 | 685992 | 1341 | import sys
sys.setrecursionlimit(10**7)
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])
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.