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
s278947851
p02239
u824204304
1454411939
Python
Python
py
Runtime Error
0
0
555
n = int(raw_input()) G = [0 for i in range(n)] a = [[0 for i in range(n)] for j in range(n)] dis = [1000 for i in range(n)] dis[0] = 0 for i in range(n): G = map(int, raw_input().split()) for j in range(G[1]): a[G[0]-1][G[2+j]-1] = 1 def bfs_visit(s): for k in range(n): if a[s][k] == 1: ...
s275965396
p02239
u824204304
1454412145
Python
Python
py
Runtime Error
0
0
544
n = int(raw_input()) G = [0 for i in range(n)] a = [[0 for i in range(n)] for j in range(n)] dis = [10000 for i in range(n)] dis[0] = 0 for i in range(n): G = map(int, raw_input().split()) for j in range(G[1]): a[G[0]-1][G[2+j]-1] = 1 def bfs_visit(s): for k in range(n): if a[s][k] == 1: ...
s732959015
p02239
u824204304
1454412333
Python
Python
py
Runtime Error
0
0
547
n = int(raw_input()) G = [0 for i in range(n)] a = [[0 for i in range(n)] for j in range(n)] dis = [99999 for i in range(n)] dis[0] = 0 def bfs_visit(s): for k in range(n): if a[s][k] == 1: if dis[k] > dis[s] + 1: dis[k] = dis[s] + 1 bfs_visit(k) for i in range(n): G = ma...
s532606359
p02239
u824204304
1454412362
Python
Python
py
Runtime Error
0
0
545
n = int(raw_input()) G = [0 for i in range(n)] a = [[0 for i in range(n)] for j in range(n)] dis = [99999 for i in range(n)] def bfs_visit(s): for k in range(n): if a[s][k] == 1: if dis[k] > dis[s] + 1: dis[k] = dis[s] + 1 bfs_visit(k) for i in range(n): G = map(int, raw_i...
s084587989
p02239
u824204304
1454412936
Python
Python
py
Runtime Error
0
0
545
n = int(raw_input()) G = [0 for i in range(n)] a = [[0 for i in range(n)] for j in range(n)] dis = [99999 for i in range(n)] def bfs_visit(s): for k in range(n): if a[s][k] == 1: if dis[k] > dis[s] + 1: dis[k] = dis[s] + 1 bfs_visit(k) for i in range(n): G = map(int, raw_i...
s298431098
p02239
u824204304
1454414225
Python
Python
py
Runtime Error
0
0
521
nn = int(raw_input()) dis = [99999 for i in range(n)] G = [0 for i in range(n)] v = [[0 for i in range(n)] for j in range(n)] def BFS(s): for e in range(n): if v[s][e] == 1: if dis[e] > dis[s] + 1: d[e] = d[s]+1 BFS(e) for i in range(n): G = map(int, raw_input().split()) for ...
s358205956
p02239
u824204304
1454414235
Python
Python
py
Runtime Error
0
0
520
n = int(raw_input()) dis = [99999 for i in range(n)] G = [0 for i in range(n)] v = [[0 for i in range(n)] for j in range(n)] def BFS(s): for e in range(n): if v[s][e] == 1: if dis[e] > dis[s] + 1: d[e] = d[s]+1 BFS(e) for i in range(n): G = map(int, raw_input().split()) for j...
s569936696
p02239
u393769849
1454415972
Python
Python
py
Runtime Error
0
0
629
n = int(raw_input()) d = [99999 for i in range(n)] G = [0 for i in range(n)] M = [[0 for i in range(n)] for j in range(n)] def BFS(s): for e in range(n): if M[s][e] == 1: if d[e] > d[s] + 1: d[e] = d[s]+1 BFS(e) for i in range(n): G = map(int, raw_i...
s544894715
p02239
u970436839
1454420249
Python
Python
py
Runtime Error
0
0
434
n = input() d = [1000 for i in range(n)] M = [[0 for i in range(n)] for j in range(n)] def BFS(s): q = [] q.append(s) d[s] = 0 while q.length != 0: u = q.pop() for v in range(n): if M[u][v] == 0 and d[v] != 1000: d[v] = d[u] + 1 q.push(v) for i in range(n): print i+1, d[i] ...
s052193529
p02239
u970436839
1454420296
Python
Python
py
Runtime Error
0
0
434
n = input() d = [1000 for i in range(n)] M = [[0 for i in range(n)] for j in range(n)] def BFS(s): q = [] q.append(s) d[s] = 0 while q.length != 0: u = q.pop() for v in range(n): if M[u][v] == 0 and d[v] != 1000: d[v] = d[u] + 1 q.push(v) for i in range(n): print i+1, d[i] ...
s193285779
p02239
u970436839
1454420461
Python
Python
py
Runtime Error
0
0
435
n = input() d = [1000 for i in range(n)] M = [[0 for i in range(n)] for j in range(n)] def BFS(s): q = [] q.append(s) d[s] = 0 while q.length != 0: u = q.pop() for v in range(n): if M[u][v] == 0 and d[v] != 1000: d[v] = d[u] + 1 q.push(v) for i in range(n): print i+1, d[i] ...
s570758023
p02239
u970436839
1454420518
Python
Python
py
Runtime Error
0
0
438
n = input() d = [1000 for i in range(n)] M = [[0 for i in range(n)] for j in range(n)] def BFS(s): q = [] q.append(s) d[s] = 0 while q.length != 0: u = q.pop(0) for v in range(n): if M[u][v] == 0 and d[v] != 1000: d[v] = d[u] + 1 q.append(v) for i in range(n): print i+1, d[...
s375226920
p02239
u970436839
1454420819
Python
Python
py
Runtime Error
0
0
451
n = input() d = [1000 for i in range(n)] M = [[0 for i in range(n)] for j in range(n)] def BFS(s): q = [] q.append(s) d[s] = 0 while q.length != 0: u = q[0] q.pop(0) for v in range(n): if M[u][v] == 0 and d[v] != 1000: d[v] = d[u] + 1 q.append(v) for i in range(n): pr...
s698681200
p02239
u038243492
1454422831
Python
Python
py
Runtime Error
0
0
1151
n = int(raw_input()) d = [100 for i in range(n)] G = [0 for i in range(n)] v = [[0 for i in range(n)] for j in range(n)] def Bread(s): for e in range(n): if v[s][e] == 1: if d[e] > d[s] + 1: d[e] = d[s]+1 Bread(e) for i in range(n): G = map(int, raw_in...
s035543587
p02239
u072053884
1463648513
Python
Python3
py
Runtime Error
50
7572
355
n = int(input()) adj = [None] for i in range(n): adj_i = list(map(int, input().split()[2:])) adj.append(adj_i) distance = [None] + [-1] * n def bfs(u, d): pd = distance[u] if pd == -1 or d < pd: distance[u] = d for v in adj[u]: bfs(v, d + 1) bfs(1, 0) for i, d in enumerate(dist...
s292481894
p02239
u569960318
1467873996
Python
Python3
py
Runtime Error
30
7688
326
def BFS(G): ans = [0] + [[i+1,-1] for i in range(len(G))] def main(G,i,d): ans[i] = [i, d] for j in G[i-1][2:]: main(G,j,d+1) main(G,1,0) return ans[1:] if __name__=='__main__': n = int(input()) G = [list(map(int,input().split())) for _ in range(n)] for out in BFS(G): print...
s273750465
p02239
u112247126
1488511277
Python
Python3
py
Runtime Error
0
0
718
from collections import deque def bfs(root): Q = deque() distance[root] = 0 Q.append(root) i = root while len(Q) > 0: for v in n: if adjMat[i][v] == 1 and color[v] == 'white': Q.append(v) color[v] = 'gray' distance[v] = distance[i...
s515148989
p02239
u426534722
1499533833
Python
Python3
py
Runtime Error
0
0
429
from sys import stdin from collections import deque n = int(input()) d = [-1] * (n + 1) def bfs(): d[1] = 0 dq = deque([1]) while len(dq) != 0: v = dq.popleft() for c in G[v]: if d[c] != -1 : continue d[c] = d[v] + 1 dq.append(c) for i, x in enumerate(...
s261952728
p02239
u193453446
1504772868
Python
Python3
py
Runtime Error
20
7680
611
def srch(i, l, Lng, Dst): if Lng[i] > l: Lng[i] = l if Dst[i] is not None and len(Dst[i]) > 0: for c in Dst[i]: srch(c,l+1, Lng, Dst) def main(): num = int(input()) Dst = [None for i in range(num + 1)] Lng = [999] * (num + 1) for n in range(1, num+1): ...
s589354271
p02239
u845643816
1512130397
Python
Python3
py
Runtime Error
0
0
563
n = int(input()) a = [[] for i in range(n)] for i in range(n): v = list(map(int, input().split())) u = v[0] - 1 for j in v[2:]: a[u].append(j-1) d = [0] * n isDiscovered = [False] * n def bfs(x): global time_stamp isDiscovered [x] = True time_stamp += 1 for i in a[x]: if n...
s712352296
p02239
u845643816
1512130719
Python
Python3
py
Runtime Error
0
0
572
n = int(input()) a = [[] for i in range(n)] for i in range(n): v = list(map(int, input().split())) u = v[0] - 1 for j in v[2:]: a[u].append(j-1) d = [0] * n isDiscovered = [False] * n def bfs(x): global time_stamp time_stamp += 1 for i in a[x]: if not isDiscovered[i]: ...
s492161298
p02239
u089116225
1528877926
Python
Python3
py
Runtime Error
0
0
547
m = [[0 for _ in range(n+1)] for _ in range(n+1)] mm = [[] for _ in range(n+1)] n = int(input()) for _ in range(n): tmp = [int(x) for x in input().split()] u,k,l = tmp[0],tmp[1],tmp[2:] mm[u] += tmp[2:] for x in l: m[u][x] = 1 dp = [float('inf') for _ in range(n+1)] queue = [1] while queue: t = queue.pop(0)...
s020491537
p02239
u782850731
1380697979
Python
Python
py
Runtime Error
0
0
562
#!/usr/bin/env python from __future__ import division, print_function from sys import stdin from Queue import Queue def main(): num = int(stdin.readline()) L = [] for _ in xrange(num): L.append([int(s) for s in stdin.readline().split()[2:]]) d = [-1] * num d[0] = 0 q = Queue()javascr...
s091980846
p02240
u255317651
1531534343
Python
Python3
py
Runtime Error
40
7060
843
# -*- coding: utf-8 -*- """ Created on Sat Jul 14 10:14:13 2018 ALDS1_11_D @author: maezawa """ n, m = list(map(int, input().split())) v = [-1 for _ in range(n)] stack = [] adj = [[] for _ in range(n)] for i in range(m): s, t = list(map(int, input().split())) adj[s].append(t) adj[t].append(s) #print(*adj, ...
s019464790
p02240
u255317651
1531534460
Python
Python3
py
Runtime Error
50
8596
883
# -*- coding: utf-8 -*- """ Created on Sat Jul 14 10:14:13 2018 ALDS1_11_D @author: maezawa """ import sys sys.setrecursionlimit(10000) n, m = list(map(int, input().split())) v = [-1 for _ in range(n)] stack = [] adj = [[] for _ in range(n)] for i in range(m): s, t = list(map(int, input().split())) adj[s].appe...
s620583474
p02240
u255317651
1531534490
Python
Python3
py
Runtime Error
700
126448
884
# -*- coding: utf-8 -*- """ Created on Sat Jul 14 10:14:13 2018 ALDS1_11_D @author: maezawa """ import sys sys.setrecursionlimit(100000) n, m = list(map(int, input().split())) v = [-1 for _ in range(n)] stack = [] adj = [[] for _ in range(n)] for i in range(m): s, t = list(map(int, input().split())) adj[s].app...
s348020895
p02240
u684241248
1531639165
Python
Python3
py
Runtime Error
30
7052
1063
# -*- coding: utf-8 -*- class LinkedList: def __init__(self, n): self.n = n self.ll = [[] for _ in range(self.n)] def link(self, u, v, direction=False): self.ll[u].append(v) if not direction: self.ll[v].append(u) def dfs(self): self.cc = [None] * self....
s677321391
p02240
u279605379
1534742391
Python
Python3
py
Runtime Error
310
8536
509
def dfs(s): global t if s == t: return True DP[s]=1 for i in F[s]: if not DP[i]: if dfs(i): return True return False n,m = [int(i) for i in input().split()] F = [{} for i in range(n)] for _ in range(m): i,j = [int(i) for i in input().split()] ...
s739408595
p02240
u279605379
1534742463
Python
Python3
py
Runtime Error
1480
10296
549
import sys sys.setrecursionlimit(10000) def dfs(s): global t if s == t: return True DP[s]=1 for i in F[s]: if not DP[i]: if dfs(i): return True return False n,m = [int(i) for i in input().split()] F = [{} for i in range(n)] for _ in range(m): i,j ...
s235129523
p02240
u007270338
1535683533
Python
Python3
py
Runtime Error
360
7000
685
#coding: utf-8 global b n, m = map(int,input().split()) List = [[] for i in range(n)] for i in range(m): s,t = map(int,input().split()) List[s].append(t) List[t].append(s) def search(a,target): if a == target: print("yes") return False for member in List[a]: if color[memb...
s248605770
p02240
u637322311
1540714377
Python
Python3
py
Runtime Error
750
21024
999
from sys import stdin def read_graph(n, k): A = [ [] for _ in range(n) ] for _ in range(k): line = stdin.readline().strip().split() A[int(line[0])].append(int(line[1])) A[int(line[1])].append(int(line[0])) return A def dfs_ctrl(n, A, s, t): color = ["WHITE"] * n d = [0] * n...
s651796788
p02240
u094978706
1540967819
Python
Python3
py
Runtime Error
40
7124
658
n, m = map(int, input().split()) adj = [[] for _ in range(n)] # adjacent list for _ in range(m): u, v = map(int, input().split()) adj[u].append(v) adj[v].append(u) c = ['w']*n # color of each vertex con = [0]*n cnt = 0 def DFS_visit(u): global c global con global cnt c[u] = 'g' ...
s194477615
p02240
u821080069
1559556173
Python
Python3
py
Runtime Error
610
6996
626
n, m = map(int, input().split()) graph = [[] for _ in range(n)] global visited visited = [0 for _ in range(n)] def input_graph(m): for _ in range(m): u, v = map(int, input().split()) graph[u].append(v) graph[v].append(u) def dfs(node_id): for ad_node in graph[node_id]: if visited[ad_node] == ...
s209245233
p02240
u821080069
1559556266
Python
Python3
py
Runtime Error
0
0
655
sys.setrecursionlimit(10000) n, m = map(int, input().split()) graph = [[] for _ in range(n)] global visited visited = [0 for _ in range(n)] def input_graph(m): for _ in range(m): u, v = map(int, input().split()) graph[u].append(v) graph[v].append(u) def dfs(node_id): for ad_node in graph[node_id]...
s062894680
p02240
u821080069
1559556284
Python
Python3
py
Runtime Error
2260
8848
666
import sys sys.setrecursionlimit(10000) n, m = map(int, input().split()) graph = [[] for _ in range(n)] global visited visited = [0 for _ in range(n)] def input_graph(m): for _ in range(m): u, v = map(int, input().split()) graph[u].append(v) graph[v].append(u) def dfs(node_id): for ad_node in gra...
s530722488
p02240
u821080069
1559556639
Python
Python3
py
Runtime Error
0
0
1023
import sys sys.setrecursionlimit(1000000) n, m = map(int, input().split()) graph = [[] for _ in range(n)] global visited visited = [0 for _ in range(n)] global Q, S, T S = [0] #訪れた順 T = [] visited[0] = 1 #開始位置はすでに訪れたことにする def input_graph(m): for _ in range(m): u, v = map(int, input().split()) graph[u].app...
s456597852
p02240
u669284080
1453564250
Python
Python3
py
Runtime Error
30
7716
549
#!/usr/bin/python3 n, m = map(int, input().split()) e = [None] * n for i in range(m): s, t = map(int, input().split()) if e[s] == None and e[t] == None: a = {s, t} e[s] = e[t] = a elif e[s] == None: e[t].add(s) e[s] = e[t] elif e[t] == None: e[s].add(t) ...
s556151101
p02240
u669284080
1453606890
Python
Python3
py
Runtime Error
40
10296
599
#!/usr/bin/python3 def set_color(i, ci, e, color): color[i] = ci for next_i in e[i]: if color[next_i] != ci: set_color(next_i, ci, e, color) n, m = map(int, input().split()) e = [set() for i in range(n)] color = [None] * n for i in range(m): s, t = map(int, input().split()) e[s]....
s988140310
p02240
u885467869
1454080259
Python
Python
py
Runtime Error
70
11244
924
class node: def __init__(self, num): self.number = num self.group = 0 self.link_node = [] self.is_serched = False def DFS(node, group_num): node.is_serched = True node.group = group_num for item in node.link_node: if item.is_serched == False: ...
s021354720
p02240
u885467869
1454080296
Python
Python
py
Runtime Error
30
11240
924
class node: def __init__(self, num): self.number = num self.group = 0 self.link_node = [] self.is_serched = False def DFS(node, group_num): node.is_serched = True node.group = group_num for item in node.link_node: if item.is_serched == False: ...
s662774052
p02240
u920118302
1454089312
Python
Python3
py
Runtime Error
0
0
691
def DFS(s): flag[s] = 1 F[group] += s for i in range(n): if G[s][i] == 1: if flag[i] == 0: DFS(i) n, m = map(int, input().split()) G = [[0 for i in range(n)] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s][t] = 1 G[t][s] = 1 F =...
s116113560
p02240
u920118302
1454089338
Python
Python3
py
Runtime Error
0
0
701
def DFS(s): flag[s] = 1 F[group] = F[group] + s for i in range(n): if G[s][i] == 1: if flag[i] == 0: DFS(i) n, m = map(int, input().split()) G = [[0 for i in range(n)] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s][t] = 1 G[t][s...
s955296528
p02240
u885467869
1454110904
Python
Python
py
Runtime Error
30
11280
924
class node: def __init__(self, num): self.number = num self.group = 0 self.link_node = [] self.is_serched = False def DFS(node, group_num): node.is_serched = True node.group = group_num for item in node.link_node: if item.is_serched == False: ...
s987255488
p02240
u069446126
1454175187
Python
Python
py
Runtime Error
0
0
343
entry = map(int, raw_input()) n = entry[0] m = entry[1] A = [] * n for i in range(m): entry = map(int, raw_input()) A[entry[0]].append(entry[1]) A[entry[1]].append(entry[0]) q = int(raw_input()) for i in range(q): entry = map(int, raw_input()) if entry[1] in A[entry[0]]: print("yes") el...
s089517306
p02240
u069446126
1454180814
Python
Python
py
Runtime Error
0
0
857
entry = map(int, raw_input()) n = entry[0] m = entry[1] color = [0] * n affil = [0] * n def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if ...
s562897440
p02240
u069446126
1454180961
Python
Python
py
Runtime Error
0
0
870
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) return group_num A = range(n) for i in A:...
s404087651
p02240
u069446126
1454181095
Python
Python
py
Runtime Error
0
0
869
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) return group_num entry = map(int, raw_inp...
s623957568
p02240
u069446126
1454181523
Python
Python
py
Runtime Error
0
0
868
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) return group_num entry = map(int, raw_inpu...
s157000091
p02240
u069446126
1454181699
Python
Python
py
Runtime Error
0
0
868
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) return group_num entry = map(int, raw_inpu...
s162047564
p02240
u069446126
1454182087
Python
Python
py
Runtime Error
0
0
875
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) return group_num entry = map(int, raw_inp...
s658795140
p02240
u069446126
1454182657
Python
Python
py
Runtime Error
0
0
867
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry = map(int, raw_input()) n = entry[0] m =...
s495485933
p02240
u069446126
1454182763
Python
Python3
py
Runtime Error
0
0
867
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry = map(int, raw_input()) n = entry[0] m =...
s159888119
p02240
u069446126
1454182883
Python
Python
py
Runtime Error
0
0
875
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry = map(int, raw_input()) n = entry[0] m =...
s104945493
p02240
u069446126
1454183370
Python
Python
py
Runtime Error
0
0
861
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry = map(int, raw_input()) n = entry[0] m =...
s893616899
p02240
u069446126
1454183452
Python
Python
py
Runtime Error
0
0
871
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry1 = map(int, raw_input()) n = entry1[0] ...
s276839215
p02240
u069446126
1454183563
Python
Python
py
Runtime Error
30
8104
886
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry = map(int, raw_input().split()) n = ent...
s474808832
p02240
u069446126
1454183668
Python
Python
py
Runtime Error
40
8300
886
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry = map(int, raw_input().split()) n = ent...
s253304013
p02240
u797673668
1454255068
Python
Python3
py
Runtime Error
310
15224
558
n, m = map(int, input().split()) g = [set() for _ in range(n)] while m: s, t = map(int, input().split()) g[s].add(t) g[t].add(s) m -= 1 def find(s, t): global g visited = [0] * n def dfs(i): visited[i] = 1 if i == t: return True for f in g[i]: ...
s605826810
p02240
u797673668
1454257844
Python
Python3
py
Runtime Error
0
0
877
from collections import deque n, m = map(int, input().split()) g = [set() for _ in range(n)] while m: s, t = map(int, input().split()) g[s].add(t) g[t].add(s) m -= 1 def find(s, t): global g queue = deque() queue.append((0, s)) queue.append((1, t)) visited = (set(), set()) vi...
s804329315
p02240
u069446126
1454276543
Python
Python
py
Runtime Error
90
8296
885
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry = map(int, raw_input().split()) n = entr...
s362635666
p02240
u069446126
1454289524
Python
Python
py
Runtime Error
30
8096
886
def BFS(s = 0, group_num = 0): Q.pop(0) color[s] = 2 for j in range(len(A[s])): if color[A[s][j]] == 0: Q.append(A[s][j]) color[A[s][j]] = 1 affil[A[s][j]] = group_num if len(Q) != 0: BFS(Q[0], group_num) entry = map(int, raw_input().split()) n = ent...
s500529270
p02240
u920118302
1454304549
Python
Python3
py
Runtime Error
0
0
534
def DFS(s, j): group[s] = j for i in range(n): if i in G[s] and group[i] == 0: DFS(i, j) n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s].append(t) G[t].append(s) group = [0 for i in range(n)] j = 1 for i in r...
s751436261
p02240
u967035362
1454419351
Python
Python
py
Runtime Error
0
0
904
using namespace std; int n,m; vector<vector<int> > list(MAX); int grp[MAX]; int group; void dfs(int now){ stack<int> next; grp[now]=group; next.push(now); while(!next.empty()){ now=next.top(); next.pop(); for(int i=0;i<(int)list[now].size();i++){ if(grp[list[now][i]]==-1){ ...
s040768993
p02240
u967035362
1454419378
Python
Python
py
Runtime Error
0
0
906
using namespace std; int n,m; vector<vector<int> > list(MAX); int grp[MAX]; int group; void dfs(int now){ stack<int> next; grp[now]=group; next.push(now); while(!next.empty()){ now=next.top(); next.pop(); for(int i=0;i<(int)list[now].size();i++){ if(grp[list[now][i]]==-1){ ...
s130718128
p02240
u047737909
1454419454
Python
Python
py
Runtime Error
0
0
684
,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c while len(que) > 0: ...
s456892030
p02240
u563876281
1454419584
Python
Python
py
Runtime Error
0
0
690
x,y = map(int,raw_input().strip().split(' ')) follow = [[] for i in range(n)] for i in range(y): h,c = map(int,raw_input().strip().split(' ')) follow[h].append(c) follow[c].append(h) color = {} u = 0 for i in range(n): if not i in color: que = [i] color[i] = u while len(que) >...
s246416929
p02240
u563876281
1454419639
Python
Python
py
Runtime Error
0
0
690
x,y = map(int,raw_input().strip().split(' ')) follow = [[] for i in range(n)] for i in range(y): h,c = map(int,raw_input().strip().split(' ')) follow[h].append(c) follow[c].append(h) color = {} u = 0 for i in range(x): if not i in color: que = [i] color[i] = u while len(que) >...
s739299923
p02240
u233232390
1454423840
Python
Python
py
Runtime Error
0
0
539
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s442677146
p02240
u233232390
1454423857
Python
Python
py
Runtime Error
0
0
539
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s230549522
p02240
u233232390
1454423876
Python
Python
py
Runtime Error
0
0
538
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s987020908
p02240
u233232390
1454424018
Python
Python
py
Runtime Error
0
0
547
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s681726724
p02240
u920118302
1454424293
Python
Python3
py
Runtime Error
0
0
654
def DFS(s): flag[s] = 1 F.append(s) for i in range(n): if G[s][i] == 1 and flag[i] == 0: DFS(i) n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s] += t G[t] += s F = [] flag = [0 for i in range(n)] grou...
s152014729
p02240
u920118302
1454424331
Python
Python3
py
Runtime Error
0
0
651
def DFS(s): flag[s] = 1 F.append(s) for i in range(n): if G[s] == i and flag[i] == 0: DFS(i) n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s] += t G[t] += s F = [] flag = [0 for i in range(n)] group =...
s512255667
p02240
u233232390
1454424406
Python
Python
py
Runtime Error
0
0
580
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: u = que[0] for v in graph[...
s153624119
p02240
u233232390
1454424441
Python
Python
py
Runtime Error
0
0
559
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: u = que[0] for v in graph[...
s904423632
p02240
u920118302
1454424445
Python
Python3
py
Runtime Error
0
0
653
def DFS(s): flag[s] = 1 group[j] += s for i in range(n): if G[s] == i and flag[i] == 0: DFS(i) n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s] += t G[t] += s flag = [0 for i in range(n)] group = [] j...
s203050547
p02240
u920118302
1454424536
Python
Python3
py
Runtime Error
0
0
664
def DFS(s): flag[s] = 1 group[j] += s for i in range(n): if G[s] == i and flag[i] == 0: DFS(i) n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s] += t G[t] += s flag = [0 for i in range(n)] group = [] j...
s411510123
p02240
u233232390
1454424671
Python
Python
py
Runtime Error
0
0
742
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s417613553
p02240
u233232390
1454424682
Python
Python
py
Runtime Error
0
0
745
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s201234789
p02240
u038005340
1454424876
Python
Python
py
Runtime Error
0
0
681
def UF() int parent; UF uf[100000] def initialize(num) for i in num-1: uf[i].parent = i; def find(a) if a == uf[a].parent: return a return uf[a].parent = find(uf[a].parent) def isSame( a , b ) if find(a) == find(b): return 1 else: return 0; def unite( a , b ) a = find(a) b = ...
s652273256
p02240
u233232390
1454425046
Python
Python
py
Runtime Error
0
0
764
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s318526187
p02240
u233232390
1454425061
Python
Python
py
Runtime Error
0
0
766
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s968897370
p02240
u233232390
1454425088
Python
Python
py
Runtime Error
0
0
773
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c if len(que) > 0: ...
s150008896
p02240
u920118302
1454425162
Python
Python3
py
Runtime Error
0
0
604
n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s].append(t) G[t].append(s) group = {} c = 0 for i in range(n): if not i in group: que = [i] group[i] = c while len(que) > 0: u = que[0] for ...
s678675001
p02240
u920118302
1454425201
Python
Python3
py
Runtime Error
0
0
603
n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s].append(t) G[t].append(s) group = {} c = 0 for i in range(n): if not i in group: que = [i] group[i] = c while len(que) > 0: u = que[0] for ...
s761441866
p02240
u920118302
1454425380
Python
Python3
py
Runtime Error
0
0
623
n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s].append(t) G[t].append(s) group = [] c = 0 for i in range(n): group.append([]) if not i in group: que = [i] group[i] = c while len(que) > 0: u = qu...
s024928419
p02240
u920118302
1454425438
Python
Python3
py
Runtime Error
0
0
625
n, m = map(int, input().split()) G = [[] for j in range(n)] for i in range(m): s, t = map(int, input().split()) G[s].append(t) G[t].append(s) group = [[]] c = 0 for i in range(n): if not i in group: que = [i] group[i] = c while len(que) > 0: u = que[0] fo...
s098812779
p02240
u233232390
1454425865
Python
Python
py
Runtime Error
0
0
676
n,m = map(int,raw_input().strip().split(' ')) graph = [[] for i in range(n)] for i in range(m): s,t = map(int,raw_input().strip().split(' ')) graph[s].append(t) graph[t].append(s) color = {} c = 0 for i in range(n): if not i in color: que = [i] color[i] = c do len(que) > 0: ...
s230271004
p02240
u408260374
1455859135
Python
Python3
py
Runtime Error
620
72004
538
import sys sys.setrecursionlimit(200000) def dfs(v, cnt): group[v] = cnt for c in edge[v]: if group[c] == -1: dfs(c, cnt) V, E = map(int, input().split()) edge = [[] for _ in range(V)] for _ in range(E): s, t = map(int, input().split()) edge[s].append(t) edge[t].append(s) grou...
s620626207
p02240
u408260374
1455859187
Python
Python3
py
Runtime Error
590
72020
537
import sys sys.setrecursionlimit(10**6) def dfs(v, cnt): group[v] = cnt for c in edge[v]: if group[c] == -1: dfs(c, cnt) V, E = map(int, input().split()) edge = [[] for _ in range(V)] for _ in range(E): s, t = map(int, input().split()) edge[s].append(t) edge[t].append(s) group...
s056865318
p02240
u894114233
1459348468
Python
Python
py
Runtime Error
60
7656
534
def dfs(u): global ct if color[u]!=-1: return color[u]=ct for v in fr[u]: if v!=-1 and color[v]==-1: dfs(v) color[u]=ct n,m=map(int,raw_input().split()) fr=[[] for i in xrange(n)] for i in xrange(m): s,t=map(int,raw_input().split()) fr[s].append(t) fr[t]....
s417284225
p02240
u894114233
1459349591
Python
Python
py
Runtime Error
30
7532
524
def dfs(u): global ct if color[u]!=-1: return color[u]=ct for v in fr[u]: if color[v]==-1: dfs(v) color[u]=ct n,m=map(int,raw_input().split()) fr=[[] for i in xrange(n)] for i in xrange(m): s,t=map(int,raw_input().split()) fr[s].append(t) fr[t].append(s) ...
s248929049
p02240
u567281053
1463072418
Python
Python
py
Runtime Error
140
8080
594
import sys def dfs(s, t): global V, d d[s] = 1 if t in V[s]: return True for v in V[s]: if d[v] == 0: if dfs(v, t): return True return False lines = sys.stdin.readlines() n, m = map(int, lines[0].split()) V = [[] for _ in range(n)] for i in range(1, m...
s362355878
p02240
u567281053
1463072574
Python
Python
py
Runtime Error
150
8188
594
import sys def dfs(s, t): global V, d d[s] = 1 if t in V[s]: return True for v in V[s]: if d[v] == 0: if dfs(v, t): return True return False lines = sys.stdin.readlines() n, m = map(int, lines[0].split()) V = [[] for _ in range(n)] for i in range(1, m...
s703109913
p02240
u567281053
1463072828
Python
Python
py
Runtime Error
160
8104
657
import sys def dfs(s, t): global V, d if t in V[s]: return True d[s] = 1 for v in V[s]: if d[v] == 0: if dfs(v, t): return True return False lines = sys.stdin.readlines() if lines[0] == "In preparation.": print "In preparation." n, m = map(int, l...
s664430323
p02240
u567281053
1463074037
Python
Python
py
Runtime Error
140
8188
582
import sys def dfs(s, t): global V, d if t in V[s]: return True d[s] = 1 for v in V[s]: if d[v] == 0: if dfs(v, t): return True return False lines = sys.stdin.readlines() n, m = map(int, lines[0].split()) V = [[] for _ in range(n)] for i in range(1, m...
s167290030
p02240
u567281053
1463074269
Python
Python
py
Runtime Error
140
7960
526
def dfs(s, t): global V, d if t in V[s]: return True d[s] = 1 for v in V[s]: if d[v] == 0: if dfs(v, t): return True return False n, m = map(int, raw_input().split()) V = [[] for _ in range(n)] for _ in range(m): s, t = map(int, raw_input().split()...
s667440797
p02240
u567281053
1463574516
Python
Python
py
Runtime Error
30
7792
536
def dfs(i, c): global V, C if C[i] == -1: C[i] = c else: return for v in V[i]: dfs(v, c) n, m = map(int, raw_input().split()) V = [[] for _ in range(n)] C = [-1] * n for _ in range(m): l, r = map(int, raw_input().split()) V[l].append(r) V[r].append(l) c = 0 for i ...
s507747297
p02240
u072053884
1464250761
Python
Python3
py
Runtime Error
40
9204
675
n, m = map(int, input().split()) adj = [[] for i in range(n)] for i in range(m): s, t = map(int, input().split()) adj[s].append(t) adj[t].append(s) isVisited = [False] * n CC = [None] * n def dfs(u, group): isVisited[u] = True CC[u] = group for v in adj[u]: if not isVisited[v]: ...
s874918631
p02240
u072053884
1464250884
Python
Python3
py
Runtime Error
40
9284
675
n, m = map(int, input().split()) adj = [[] for i in range(n)] for i in range(m): s, t = map(int, input().split()) adj[s].append(t) adj[t].append(s) isVisited = [False] * n CC = [None] * n def dfs(u, group): isVisited[u] = True CC[u] = group for v in adj[u]: if not isVisited[v]: ...