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
s718218329
p02240
u072053884
1464251731
Python
Python3
py
Runtime Error
50
10308
715
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 import sys sys.setrecursionlimit(10000) def dfs(u, group): isVisited[u] = True CC[u] = group for v in ...
s689608508
p02240
u072053884
1464251834
Python
Python3
py
Runtime Error
510
37880
715
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 import sys sys.setrecursionlimit(20000) def dfs(u, group): isVisited[u] = True CC[u] = group for v in ...
s365635614
p02240
u072053884
1464251881
Python
Python3
py
Runtime Error
580
72728
716
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 import sys sys.setrecursionlimit(100000) def dfs(u, group): isVisited[u] = True CC[u] = group for v in...
s000132350
p02240
u072053884
1464251983
Python
Python3
py
Runtime Error
630
72756
717
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 import sys sys.setrecursionlimit(1000000) def dfs(u, group): isVisited[u] = True CC[u] = group for v i...
s107087699
p02240
u072053884
1464252123
Python
Python3
py
Runtime Error
590
72756
718
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 import sys sys.setrecursionlimit(10000000) def dfs(u, group): isVisited[u] = True CC[u] = group for v ...
s899391989
p02240
u072053884
1464252163
Python
Python3
py
Runtime Error
580
72816
719
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 import sys sys.setrecursionlimit(100000000) def dfs(u, group): isVisited[u] = True CC[u] = group for v...
s446082899
p02240
u072053884
1464252187
Python
Python3
py
Runtime Error
0
0
724
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 import sys sys.setrecursionlimit(10000000000000) def dfs(u, group): isVisited[u] = True CC[u] = group ...
s226069208
p02240
u072053884
1464252257
Python
Python3
py
Runtime Error
620
72748
720
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 import sys sys.setrecursionlimit(1000000000) def dfs(u, group): isVisited[u] = True CC[u] = group for ...
s780774360
p02240
u569960318
1468373994
Python
Python3
py
Runtime Error
200
14084
627
def connected(G,s,t): checked = [False]*len(G) def main(G,s,t): if t in G[s]: return True checked[s] = True for f in G[s]: if checked[f]: continue if main(G,f,t): return True return False return main(G,s,t) if __name__=='__main__': n,m = list(map...
s011576128
p02240
u569960318
1468380787
Python
Python3
py
Runtime Error
1570
14140
676
import sys sys.setrecursionlimit(10000) def connected(G,s,t): checked = [False]*len(G) def main(G,s,t): if t in G[s]: return True checked[s] = True for f in G[s]: if checked[f]: continue if main(G,f,t): return True return False return main(G,s,t) ...
s555168941
p02240
u569960318
1468473072
Python
Python3
py
Runtime Error
520
66196
813
import sys sys.setrecursionlimit(100000) def make_connected_group(G): C = [-1]*len(G) def main(G,i,grp): if C[i] > -1: return C[i] = grp for j in G[i]: main(G,j,grp) group = 0 for p,cp in enumerate(C): if cp == -1: main(G,p,group) group += 1 ...
s232642631
p02240
u027872723
1477309962
Python
Python3
py
Runtime Error
140
8572
1814
# -*- coding: utf_8 -*- import copy level = False def debug(v): if level: print(v) NOT_FOUND = 0 ENQUEUED = 1 FOUND = 2 def dfs(graph, start, end): stack = [start] status = [NOT_FOUND] * len(graph) def loop(stack, status, graph, start, end): debug("-------------------") debug...
s209980279
p02240
u890722286
1478361771
Python
Python3
py
Runtime Error
540
10020
692
def search(s, t): global g node = g[s] node[1] = 1 if s == t: return True else: for i in node[0]: ch = g[i] if ch[1] == 0: result = search(i, t) if result: return result return False n, m = list(map(...
s507479889
p02240
u890722286
1478363177
Python
Python3
py
Runtime Error
380
9052
640
def search(s, t, a): global g a.add(s) if s == t: return True else: for ch in g[s]: if not (ch in a): result = search(ch, t, a) if result: return result return False n, m = list(map(int, input().split())) g = [[] f...
s716733567
p02240
u022407960
1479666176
Python
Python3
py
Runtime Error
60
7704
1464
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def assign_color(): _id = 1 for m in range(vertices_num): if vertices_status_list[m] == -1: graph_dfs(m, _id) _id += 1 return None def graph_dfs(vertex, color): vertices_stack = list() vertices_stack.append...
s968428317
p02240
u022407960
1480383672
Python
Python3
py
Runtime Error
0
0
1475
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 10 9 0 1 0 2 3 4 5 7 5 6 6 7 6 8 7 8 8 9 3 0 1 5 9 1 3 output: yes yes no """ import sys def assign_color(): _color = 1 for v in range(vertices): if color[v] == -1: graph_dfs(v, _color) _color += 1 return None d...
s401143943
p02240
u811733736
1481156891
Python
Python3
py
Runtime Error
20
7616
1098
def dfs(G, C, id, color): S = [] S.append(id) C[id] = color while S: u = S[-1] # ?????¨?¨????????????????????????°?????? S = S[:-1] # pop for i in range(len(G[u])): v = G[u][i] if C[v] == -1: C[v] = color S.append(v) if...
s214495297
p02240
u923668099
1486260782
Python
Python3
py
Runtime Error
370
71940
1002
import sys sys.setrecursionlimit(10 ** 5 * 2) def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def paint_col(adj, cols, i, col): cols[i] = col for child in adj[i]: if cols[chil...
s951318020
p02240
u923668099
1486260835
Python
Python3
py
Runtime Error
370
72024
998
import sys sys.setrecursionlimit(10 ** 6) def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def paint_col(adj, cols, i, col): cols[i] = col for child in adj[i]: if cols[child] =...
s827779259
p02240
u923668099
1486260860
Python
Python3
py
Runtime Error
350
72012
998
import sys sys.setrecursionlimit(10 ** 7) def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def paint_col(adj, cols, i, col): cols[i] = col for child in adj[i]: if cols[child] =...
s144938700
p02240
u923668099
1486264649
Python
Python3
py
Runtime Error
0
0
1170
import sys def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def paint_col(adj, cols, i, col): nxt = [i] while nxt: u = nxt[-1] try: v = next(adj[u]) ...
s451730281
p02240
u067677727
1499408050
Python
Python3
py
Runtime Error
0
0
1550
#include <iostream> #include <cstdio> #include <cmath> using namespace std; static const int PLAYERS = 1025; static const int ROUND = 11; double ratings[PLAYERS]; double p[PLAYERS][ROUND]; int n; double win(int p1, int p2) { return 1.0 / (1.0 + pow(10, (ratings[p2] - ratings[p1])/400.0)); } double wp(int i, int k) ...
s266212333
p02240
u067677727
1499408088
Python
Python3
py
Runtime Error
0
0
1550
#include <iostream> #include <cstdio> #include <cmath> using namespace std; static const int PLAYERS = 1025; static const int ROUND = 11; double ratings[PLAYERS]; double p[PLAYERS][ROUND]; int n; double win(int p1, int p2) { return 1.0 / (1.0 + pow(10, (ratings[p2] - ratings[p1])/400.0)); } double wp(int i, int k) ...
s911339354
p02240
u519227872
1504704323
Python
Python3
py
Runtime Error
150
10096
680
n, m = map(int,input().split()) g = {} for i in range(m): s,t = map(int,input().split()) val = g.get(s,[]) val.append(t) g[s] = val val = g.get(t,[]) val.append(s) g[t] = val def dfs(g, s, done=[]): if s in done: return done.append(s) for c in g[s]: dfs(g, c, do...
s345256549
p02240
u519227872
1504705125
Python
Python3
py
Runtime Error
1420
11624
780
n, m = map(int,input().split()) g = {} for i in range(m): s,t = map(int,input().split()) val = g.get(s,[]) val.append(t) g[s] = val val = g.get(t,[]) val.append(s) g[t] = val count = 0 def dfs(g, s, done=[]): global count count += 1 if s in done: return done.append(...
s124539847
p02240
u519227872
1504881181
Python
Python3
py
Runtime Error
20
7664
704
n, m = map(int,input().split()) g = {} for i in range(m): s,t = map(int,input().split()) val = g.get(s,[]) val.append(t) g[s] = val val = g.get(t,[]) val.append(s) g[t] = val color = 1 done = [-1] + [-1] * m def dfs(g, s): done[s] = color stack = [s] while stack != []: ...
s085659536
p02240
u193453446
1505107368
Python
Python3
py
Runtime Error
20
7752
1036
import sys def srch(i, end, l, Dst, Lng): if Lng[i] != -1 and Lng[i] < l: return Lng[i] = l if i == end: return if Dst[i] is not None and len(Dst[i]) > 0: for c in Dst[i]: srch(c, end, l+1, Dst, Lng) def main(): istr = sys.stdin.read() ilist = [] for i i...
s640250129
p02240
u796784914
1505549809
Python
Python
py
Runtime Error
720
7748
699
def main(): n, m = map(int,raw_input().split()) A = [[] for i in xrange(n)] for i in xrange(m): s, t = map(int,raw_input().split()) A[s].append(t) A[t].append(s) q = input() a =[0]*q for i in xrange(q): s, t = map(int,raw_input().split()) c = [-1]*n ...
s587501141
p02240
u024715419
1510911797
Python
Python3
py
Runtime Error
0
0
767
def bfs(graph, start, goal, connection): visited = {start: None} unvisited = [start] while unvisited: now = unvisited[0] if now == goal or connection[1000000*now + goal] == 1: connection[1000000*start + goal] = 1 return "yes" unvisited = unvisited[1:] ...
s194742667
p02240
u024715419
1510912825
Python
Python3
py
Runtime Error
0
0
747
def bfs(graph, start, goal, connection): visited = {start: None} unvisited = [start] while unvisited: now = unvisited[0] if now == goal or (1000000*now + goal) in connection: connection[1000000*start + goal] = 1 return "yes" unvisited = unvisited[1:] f...
s154964942
p02240
u024715419
1510914026
Python
Python3
py
Runtime Error
0
0
898
def bfs(graph, start, goal, connection): visited = {start: None} unvisited = [start] while unvisited: now = unvisited[0] if now == goal or (1000000*now + goal) in connection: connection[1000000*start + goal] = 1 connection[1000000*goal + start] = 1 return ...
s702764180
p02240
u024715419
1510914259
Python
Python3
py
Runtime Error
0
0
889
from collections import deque def bfs(graph, start, goal, connection): visited = {start: None} unvisited = deque(start) while unvisited: now = unvisited.popleft() if now == goal or (1000000*now + goal) in connection: connection[1000000*start + goal] = 1 connection[10...
s124531715
p02240
u024715419
1510915689
Python
Python3
py
Runtime Error
0
0
845
from collections import deque def bfs(graph, start, goal, connection): visited = {start: None} unvisited = deque() unvisited.append(start) while unvisited: now = unvisited.popleft() if now == goal or goal in connection[now]: connection[start].add(goal) connection...
s788513410
p02240
u845643816
1511923578
Python
Python3
py
Runtime Error
0
0
780
n, m = map(int, input().split()) a = [[False]*n for i in range(n)] rootList = [-1] * n def hasSameRoot(x, y): if rootList[x] == rootList[y] != -1: return True elif rootList[x] == x and rootList[y] == y: return False elif x > 1: return hasSameRoot(y, x-1) else: return has...
s146986224
p02240
u845643816
1511923817
Python
Python3
py
Runtime Error
0
0
504
n, m = map(int, input().split()) rootList = [-1] * n def getRoot(x): if rootList[x] < 0: return x rootList[x] = getRoot(rootList[x]) return rootList[x] def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: G[x], G[y] = min(x, y), min(x, y) for i in range(0, m): s...
s190883380
p02240
u845643816
1511923849
Python
Python3
py
Runtime Error
0
0
504
n, m = map(int, input().split()) rootList = [-1] * n def getRoot(x): if rootList[x] < 0: return x rootList[x] = getRoot(rootList[x]) return rootList[x] def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: G[x], G[y] = min(x, y), min(x, y) for i in range(m): s, t...
s726165331
p02240
u845643816
1511923992
Python
Python3
py
Runtime Error
0
0
469
n, m = map(int, input().split()) rootList = [-1] * n def getRoot(x): if rootList[x] < 0: return x return getRoot(rootList[x]) def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: G[x], G[y] = min(x, y), min(x, y) for i in range(m): s, t = map(int, input().split()) ...
s842876680
p02240
u845643816
1511956441
Python
Python3
py
Runtime Error
0
0
511
n, m = map(int, input().split()) rootList = [-1] * n def getRoot(x): if rootList[x] < 0: rootList[x] = x return x return getRoot(rootList[x]) def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: rootList[x], rootList[y] = min(x, y), min(x, y) for i in range...
s027169896
p02240
u845643816
1511956696
Python
Python3
py
Runtime Error
0
0
517
n, m = map(int, input().split()) rootList = [-1] * n def getRoot(x): if rootList[x] < 0: rootList[x] = x return x return getRoot(rootList[x]) def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: rootList[x], rootList[y] = min(x, y), min(x, y) for i in range...
s633037213
p02240
u845643816
1511956811
Python
Python3
py
Runtime Error
0
0
531
n, m = map(int, input().split()) rootList = [-1 for i in range(n)] def getRoot(x): if rootList[x] < 0: rootList[x] = x return x return getRoot(rootList[x]) def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: rootList[x], rootList[y] = min(x, y), min(x, y) ...
s324710339
p02240
u845643816
1511966781
Python
Python
py
Runtime Error
0
0
549
n, m = map(int, input().split()) rootList = [-1 for i in range(n)] def getRoot(x): r = rootList[x] if r < 0: rootList[x] = x elif r != x: rootList[x] = getRoot(r) return rootList[x] def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: rootList[x] = ro...
s736079528
p02240
u626266743
1511969122
Python
Python3
py
Runtime Error
0
0
778
def dfs(r, c): global c, color S = [r] color[r] = c while (0 < len(S)): u = S.pop() for u in G[u]: v = color[ch] if (v == False): color[u] = c S.append(u) def assignColor(): global c, color c = 1 for i in range(n): ...
s189958201
p02240
u626266743
1511969153
Python
Python3
py
Runtime Error
0
0
787
def dfs(r, c): global c, color, G S = [r] color[r] = c while (0 < len(S)): u = S.pop() for u in G[u]: v = color[ch] if (v == False): color[u] = c S.append(u) def assignColor(): global c, color, G, n c = 1 for i in rang...
s914009692
p02240
u626266743
1511969311
Python
Python3
py
Runtime Error
0
0
783
def dfs(r, c): global c, color, G S = [r] color[r] = c while (0 < len(S)): u = S.pop() for u in G[u]: v = color[u] if (v == None): color[u] = c S.append(u) def assignColor(): global c, color, G, n c = 1 for i in range(...
s164090362
p02240
u626266743
1511969334
Python
Python3
py
Runtime Error
0
0
780
def dfs(r, c): global c, color, G S = [r] color[r] = c while (0 < len(S)): u = S.pop() for u in G[u]: v = color[u] if (v == None): color[u] = c S.append(u) def assignColor(): global color, G, n c = 1 for i in range(n):...
s362527176
p02240
u626266743
1511969369
Python
Python3
py
Runtime Error
0
0
777
def dfs(r, c): global color, G S = [r] color[r] = c while (0 < len(S)): u = S.pop() for u in G[u]: v = color[u] if (v == None): color[u] = c S.append(u) def assignColor(): global color, G, n c = 1 for i in range(n): ...
s885704114
p02240
u662418022
1518337487
Python
Python3
py
Runtime Error
40
8708
754
# -*- coding: utf-8 -*- from collections import deque if __name__ == '__main__': n, m = [int(s) for s in input().split(" ")] M = [set() for j in range(n)] for _ in range(m): u, v = [int(s) for s in input().split(" ")] M[u].add(v) M[v].add(u) color = [0] * n def df...
s373254029
p02240
u662418022
1518337546
Python
Python3
py
Runtime Error
40
8704
754
# -*- coding: utf-8 -*- from collections import deque if __name__ == '__main__': n, m = [int(s) for s in input().split(" ")] M = [set() for j in range(n)] for _ in range(m): u, v = [int(s) for s in input().split(" ")] M[u].add(v) M[v].add(u) color = [0] * n def df...
s386767923
p02240
u662418022
1518337607
Python
Python3
py
Runtime Error
740
141208
795
# -*- coding: utf-8 -*- from collections import deque import sys sys.setrecursionlimit(100000) if __name__ == '__main__': n, m = [int(s) for s in input().split(" ")] M = [set() for j in range(n)] for _ in range(m): u, v = [int(s) for s in input().split(" ")] M[u].add(v) M[v].add(u...
s296907932
p02240
u426534722
1519231744
Python
Python3
py
Runtime Error
0
0
640
import sys readline = sys.stdin.readline def MAIN(): n, m = map(int, input().split()) li = [i for i in range(n)] def f(a): if li[a] == a: return a li[a] = f(li[a]) return li[a] def f2(a, b): if li[a] == a: li[a] = b return f2(li...
s136755543
p02240
u426534722
1519231769
Python
Python3
py
Runtime Error
0
0
646
import sys readline = sys.stdin.readline def MAIN(): n, m = map(int, input().split()) li = [i for i in range(n)] def f(a): if li[a] == a: return a li[a] = f(li[a]) return li[a] def f2(a, b): if li[a] == a: li[a] = b return f2(li...
s282490385
p02240
u150984829
1520299553
Python
Python3
py
Runtime Error
0
0
396
def s(): e=sys.stdin.readline n,m=map(int,e().split()) P=[[]for _ in[0]*n] C=[0]*n k=0 for _ in[0]*m: s,t=map(int,e().split());P[s]+=[t];P[t]+=[s] for i in range(n): k+=1 if C[i]<1: s=[i];C[i]=k while s: u=s.pop() for v in P[u]: if C[v]<1:C[v]=k;s+=[v] for _ in[0]*int(e()): a,b=map(in...
s842621999
p02240
u912143677
1522300831
Python
Python3
py
Runtime Error
0
0
727
n, m = map(int, input().split()) a = [[] for i in range(n)] for i in range(m): com = list(map(int, input().split())) a[com[0]].append(com[1]) a[com[1]].append(com[0]) q = int(input()) from collections import deque for j in range(q): memo = [0 for i in range(n)] data = list(map(int, input().split...
s219086534
p02240
u126478680
1525511388
Python
Python3
py
Runtime Error
840
7688
1269
from collections import deque from enum import Enum, auto class Color(Enum): WHITE = auto() GRAY = auto() BLACK = auto() n, m = list(map(int, input().split(' '))) adj_list = [[] for i in range(n)] for i in range(m): u, v = list(map(int, input().split(' '))) adj_list[u].append(v) adj_list[v].ap...
s966345253
p02240
u404682284
1528723276
Python
Python3
py
Runtime Error
30
8884
756
import sys input_lines = [[int(i) for i in line.split()] for line in sys.stdin.read().splitlines()] [user_num, rel_num] = input_lines[0] rel_list = input_lines[1:rel_num+1] ques_num = input_lines[rel_num+1][0] ques_list = input_lines[rel_num+2:] color_list = [-1] * user_num adja_list = [set() for i in range(user_num)] ...
s607513001
p02240
u826549974
1529837610
Python
Python3
py
Runtime Error
40
7984
835
def dfs(v): global node_chk global edge_chk global B global connect global value node_chk[v] = 1 connect[v] = value for x in B[v]: if(node_chk[x] == 0): dfs(x) n,m = map(int,input().split()) B = [[]for i in range(n)] # 隣接リスト edge_chk = [[]for i in range(n)] no...
s204522394
p02240
u826549974
1529837967
Python
Python3
py
Runtime Error
60
9568
876
import sys sys.setrecursionlimit(10000) def dfs(v): global node_chk global edge_chk global B global connect global value node_chk[v] = 1 connect[v] = value for x in B[v]: if(node_chk[x] == 0): dfs(x) n,m = map(int,input().split()) B = [[]for i in range(n)] # ...
s694062707
p02240
u826549974
1529837994
Python
Python3
py
Runtime Error
790
132016
877
import sys sys.setrecursionlimit(100000) def dfs(v): global node_chk global edge_chk global B global connect global value node_chk[v] = 1 connect[v] = value for x in B[v]: if(node_chk[x] == 0): dfs(x) n,m = map(int,input().split()) B = [[]for i in range(n)] #...
s809203839
p02240
u408444038
1530068886
Python
Python3
py
Runtime Error
0
0
694
def tan(G,st,fi): global flag for i in range(len(G)): if G[st][i] == 1: if i == fi: flag = 1 tan(G,i,fi) n,m = list(map(int, input().split())) G = [[0 for i in range(n)] for j in range(n)] for i in range(m): S = list(map(int, input().split())) G[S[0]...
s069981766
p02240
u007270338
1530204518
Python
Python3
py
Runtime Error
870
7004
693
#coding:utf-8 n, r = map(int,input().split()) Q = [] M = [[] for j in range(n)] for i in range(r): i,j = map(int,input().split()) M[i].append(j) M[j].append(i) def search(person, target): data = M[person] for per in data: if per == target: global yes yes = 1 ...
s537810950
p02240
u007270338
1530204653
Python
Python3
py
Runtime Error
2710
8856
733
#coding:utf-8 import sys sys.setrecursionlimit(10000) n, r = map(int,input().split()) Q = [] M = [[] for j in range(n)] for i in range(r): i,j = map(int,input().split()) M[i].append(j) M[j].append(i) def search(person, target): data = M[person] for per in data: if per == target: ...
s591342843
p02241
u279605379
1534777987
Python
Python3
py
Runtime Error
0
0
369
import heapq n = int(input()) #A = [[int(i) for i in input().split()] for i in range(n)] h = [] DP = {} heapq.heappush(h,(0,0)) c = 0 while(len(DP)<n): tmp = heapq.heappop(h) if tmp[1] in DP: continue c += tmp[0] DP[tmp[1]] = 1 for i,j in enumerate(A[tmp[1]]): if j > 0 and not i in ...
s970216693
p02241
u726330006
1540445291
Python
Python3
py
Runtime Error
0
0
1300
graph_n=int(input()) edge_dict={} for i in range(graph_n): tmp_row=list(map(int,input())) for j in range(graph_n): if(tmp_row[j]!=-1): try: edge_dict[tmp_row].append([i,j]) except: edge_dict[tmp_row]=[[i,j]] sorted_edge=sorted(edge_dict.items...
s281140415
p02241
u633068244
1433021301
Python
Python
py
Runtime Error
0
0
946
class UnionFind: def __init__(self, size): self.rank = [0] * size self.par = range(size) self.g_num = size def find(self, x): if x == self.par[x]: return x self.par[x] = self.find(self.par[x]) return self.par[x] def same(self, x, y): return self.find...
s223621273
p02241
u069446126
1454602877
Python
Python
py
Runtime Error
0
0
654
def prim(cost): sumcost = 0 V = len(cost) mincost = [float('inf')] * V used = [False] * V mincost[0] = 0 while True: j = -1 for i in range(V): if not used[i] and (j = -1 or mincost[i] < mincost[j]): j = i if j == -1: break u...
s905818759
p02241
u047737909
1454686819
Python
Python
py
Runtime Error
0
0
388
n = int(raw_input()) A = [0] i = 0 NY = range(1, n) a = [[0 for i in xrange(n)] for j in xrange(n) While i < n; a[i] = map(int,raw_input().split()) long = 0 while NY != []: amin = 2001 for i in A: for j in NY: if 0 <= a[i][j] < amin: amin = a[i][j] addA = ...
s330226746
p02241
u047737909
1454687219
Python
Python
py
Runtime Error
0
0
407
n = int(raw_input()) A = [0] i = 0 long = 0 NY = range(1, n) a = [[0 for i in xrange(n)] for j in xrange(n)] while i <= n: a[i] = map(int,raw_input().split()) i = i+1 while NY != []: amin = 2001 for i in A: for j in NY: if 0 <= a[i][j] < amin: amin = a[i][j] ...
s958193491
p02241
u970436839
1454752702
Python
Python
py
Runtime Error
0
0
783
n = input() INFTY = 10000000 color = [0 for i in range(n)] M = [[0 for i in range(n)] for i in range(n)] d = [INFTY for i in range(n)] p = [-1 for i in range(n)] def MST(): d[0] = 0 p[0] = -1 while True: cost = INFTY for i in range(n): if color[i] != 1 and d[i] < cost: cost = d[i] ...
s974377758
p02241
u970436839
1454752765
Python
Python
py
Runtime Error
0
0
786
n = input() INFTY = 10000000 color = [0 for i in range(n)] M = [[0 for i in range(n)] for i in range(n)] d = [10000000 for i in range(n)] p = [-1 for i in range(n)] def MST(): d[0] = 0 p[0] = -1 while True: cost = INFTY for i in range(n): if color[i] != 1 and d[i] < cost: cost = d[i] ...
s483080004
p02241
u970436839
1454753068
Python
Python
py
Runtime Error
0
0
790
n = input() INFTY = 10000000 color = [0 for i in xrange(n)] M = [[0 for i in xrange(n)] for i in xrange(n)] d = [INFTY for i in xrange(n)] p = [-1 for i in xrange(n)] def MST(): d[0] = 0 p[0] = -1 while True: cost = INFTY for i in xrange(n): if color[i] != 1 and d[i] < cost: cost = d[i] ...
s909661957
p02241
u970436839
1454754195
Python
Python
py
Runtime Error
0
0
791
n = input() INFTY = 10000000 color = [0 for i in xrange(n)] M = [[0 for i in xrange(n)] for i in xrange(n)] d = [INFTY for i in xrange(n)] p = [-1 for i in xrange(n)] def MST(): d[0] = 0 p[0] = -1 while True: cost = INFTY for i in xrange(n): if color[i] != 1 and d[i] < cost cost = d[i] ...
s048335185
p02241
u970436839
1454754319
Python
Python
py
Runtime Error
0
0
791
n = input() INFTY = 10000000 color = [0 for i in xrange(n)] M = [[0 for i in xrange(n)] for i in xrange(n)] d = [INFTY for i in xrange(n)] p = [-1 for i in xrange(n)] def MST(): d[0] = 0 p[0] = -1 while True: cost = INFTY for i in xrange(n): if color[i] != 1 and d[i] < cost: cost = d[i] ...
s293945874
p02241
u970436839
1454755165
Python
Python
py
Runtime Error
0
0
787
n = input() INFTY = 10000000 color = [0 for i in xrange(n)] M = [[0 for i in xrange(n)] for i in xrange(n)] d = [INFTY for i in xrange(n)] p = [-1 for i in xrange(n)] def MST(): d[0] = 0 while True: cost = INFTY for i in xrange(n): if color[i] != 1 and d[i] < cost: cost = d[i] u = ...
s287298933
p02241
u970436839
1454755194
Python
Python
py
Runtime Error
0
0
786
n = input() INFTY = 10000000 color = [0 for i in xrange(n)] M = [[0 for i in xrange(n)] for i in xrange(n)] d = [INFTY for i in xrange(n)] p = [-1 for i in xrange(n)] def MST(): d[0] = 0 while True: cost = INFTY for i in xrange(n): if color[i] != 1 and d[i] < cost: cost = d[i] u = ...
s084065146
p02241
u038005340
1454868038
Python
Python
py
Runtime Error
0
0
397
n = int( raw_input() ) A = [0] p = range(1, n) a = [ [ 0 for i in xrange(n) ] for j in xrange(n) ] for i in xrange(n): a[i] = map( int,raw_input().split() ) l = 0 while p != []: a_min = 2001 for i in A: for j in p: if 0 <= a[i][j] < a_min: a_min = a[i][j] ...
s255396546
p02241
u967035362
1454941111
Python
Python
py
Runtime Error
0
0
610
from __future__ import division, print_function from sys import stdin, maxint def main(): n = int(stdin.readline()) M = [] for _ in xrange(n): M.append([int(s) for s in stdin.readline().split()]) g = set(xrange(1, num+1)) index = g.pop() h = {index} weight = 0 while g: ...
s041762370
p02241
u967035362
1454941120
Python
Python
py
Runtime Error
0
0
610
from __future__ import division, print_function from sys import stdin, maxint def main(): n = int(stdin.readline()) M = [] for _ in xrange(n): M.append([int(s) for s in stdin.readline().split()]) g = set(xrange(1, num+1)) index = g.pop() h = {index} weight = 0 while g: ...
s019029215
p02241
u563876281
1455002936
Python
Python
py
Runtime Error
0
0
682
from __future__ import division, print_function from sys import stdin, maxint def main(): num = int(stdin.readline()) y = [] for _ in xrange(num): it = iter(int(s) for s in stdin.readline().split()[1:]) y.append([(next(it), next(it)) for _ in xrange(next(it))]) weight = [maxint] * ...
s084966376
p02241
u563876281
1455002952
Python
Python
py
Runtime Error
0
0
684
from __future__ import division, print_function from sys import stdin, maxint def main(): num = int(stdin.readline()) y = [] for _ in xrange(num): it = iter(int(s) for s in stdin.readline().split()[1:]) y.append([(next(it), next(it)) for _ in xrange(next(it))]) weight = [maxint] * ...
s542445848
p02241
u563876281
1455002958
Python
Python
py
Runtime Error
0
0
685
from __future__ import division, print_function from sys import stdin, maxint def main(): num = int(stdin.readline()) y = [] for _ in xrange(num): it = iter(int(s) for s in stdin.readline().split()[1:]) y.append([(next(it), next(it)) for _ in xrange(next(it))]) weight = [maxint] * ...
s242876518
p02241
u563876281
1455002971
Python
Python
py
Runtime Error
0
0
687
from __future__ import division, print_function from sys import stdin, maxint def main(): num = int(stdin.readline()) y = [] for _ in xrange(num): it = iter(int(s) for s in stdin.readline().split()[1:]) y.append([(next(it), next(it)) for _ in xrange(next(it))]) weight = [maxint] ...
s023759673
p02241
u563876281
1455003028
Python
Python
py
Runtime Error
0
0
688
from __future__ import division, print_function from sys import stdin, maxint def main(): num = int(stdin.readline()) y = [] for _ in xrange(num): it = iter(int(s) for s in stdin.readline().split()[1:]) y.append([(next(it), next(it)) for _ in xrange(next(it))]) weight = [maxint] ...
s127459754
p02241
u233232390
1455006545
Python
Python
py
Runtime Error
0
0
348
n = int(raw_input()) a = [[0 for i in xrange(0,n)] for j in xrange(0,n)] for i in xrange(n): a[i] = map(int,raw_input().split()) omomi = 0 A = [0] B = range(1, n) while B! = []: c=2000 for i in A: for j in B: if 0 <= a[i][j]<=c: c = a[i][j] AA = j o...
s452857131
p02241
u233232390
1455006554
Python
Python
py
Runtime Error
0
0
325
n = int(raw_input()) a = [[0 for i in xrange(0,n)] for j in xrange(0,n)] for i in xrange(n): a[i] = map(int,raw_input().split()) omomi = 0 A = [0] B = range(1, n) while B! = []: c=2000 for i in A: for j in B: if 0 <= a[i][j]<=c: c = a[i][j] omomi = omomi + c print ...
s036592007
p02241
u885467869
1455007418
Python
Python
py
Runtime Error
0
0
1103
def prim(n): d = [None] * 100 p = [None] * 100 color = [None] * 100 for i in xrange(n): d[i] = float('inf') p[i] = -1 color[i] = 0 d[0] = 0 while(true): minv = float('inf') u = -1 for i in xrange(n): if minv > d[i] and co...
s143843566
p02241
u119456964
1455007599
Python
Python
py
Runtime Error
0
0
701
n = input() INFTY = float('inf') color = [0 for i in range(n)] m = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] k = [-1 for i in range(n)] d[0] = 0 while 1: cost = INFTY for i in range(n): if color[i] != 2 and d[i] < cost: cost = d[i] u = i if cost == INFT...
s500617288
p02241
u119456964
1455007911
Python
Python
py
Runtime Error
0
0
698
n = input() INFTY = float('inf') color = [0 for i in range(n)] m = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] k = [-1 for i in range(n)] for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] != -1: m[i][j] = G[j] d[0] = 0 while 1: ...
s937078025
p02241
u119456964
1455007985
Python
Python
py
Runtime Error
0
0
706
n = input() INFTY = float('inf') color = [0 for i in range(n)] m = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] k = [-1 for i in range(n)] for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] != -1: m[i][j] = G[j] d[0] = 0 whi...
s164031052
p02241
u119456964
1455008288
Python
Python
py
Runtime Error
0
0
715
n = int(raw_input()) INFTY = float('inf') color = [0 for i in range(n)] m = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] k = [-1 for i in range(n)] for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] != -1: m[i][j] = G[j] d[0] ...
s534846577
p02241
u119456964
1455008455
Python
Python
py
Runtime Error
0
0
764
n = int(raw_input()) INFTY = float('inf') color = [0 for i in range(n)] m = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] k = [-1 for i in range(n)] for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] != -1: m[i][j] = G[j] d[0] ...
s038779574
p02241
u119456964
1455008512
Python
Python
py
Runtime Error
0
0
764
n = int(raw_input()) INFTY = float('inf') color = [0 for i in range(n)] m = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] k = [-1 for i in range(n)] for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] != -1: m[i][j] = G[j] d[0] ...
s820160901
p02241
u119456964
1455008595
Python
Python
py
Runtime Error
0
0
754
n = int(raw_input()) INFTY = 99999999 color = [0 for i in range(n)] m = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] k = [-1 for i in range(n)] for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] != -1: m[i][j] = G[j] d[0] = 0 ...
s070827261
p02241
u119456964
1455008613
Python
Python3
py
Runtime Error
0
0
754
n = int(raw_input()) INFTY = 99999999 color = [0 for i in range(n)] m = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] k = [-1 for i in range(n)] for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] != -1: m[i][j] = G[j] d[0] = 0 ...
s707085611
p02241
u119456964
1455008929
Python
Python
py
Runtime Error
0
0
855
n = int(raw_input()) INFTY = float('inf') color = [0 for i in range(n)] M = [[INFTY for i in range(n)] for j in range(n)] d = [INFTY for i in range(n)] p = [-1 for i in range(n)] def MST(): d[0] = 0 while 1: cost = INFTY for i in range(n): if color[i] != 2 and d[i] < cost: ...
s784547155
p02241
u974554153
1455018796
Python
Python
py
Runtime Error
0
0
518
def prim(cost): sumcost = 0 V = len(cost) mincost = [float('inf')] * V used = [False] * V mincost[0] = 0 while True: v = -1 for u in range(V): if not used[u] and (v == -1 or mincost[u] < mincost[ju): v = u if v == -1: break used[v] = Tr...
s020300574
p02241
u619765879
1455026444
Python
Python
py
Runtime Error
0
0
650
n = input() a = [] for i in range(n): M.append(map(int, raw_input().split())) for i in range(n): for j in range(n): if M[i][j]==-1: M[i][j] = 1000000000 d = [1000000000 for i range(n)] p = [-1 for i in range(n)] color = [0 for i in range(n)] d[0] = 0 while 1: minv = 1000000000 u = -1 for i in rang...
s643003877
p02241
u532962080
1455028022
Python
Python
py
Runtime Error
0
0
151
n = int( raw_input() ) A = [0] p = range(1, n) a = [ [ 0 for i in xrange(n) ] for j in xrange(n) ] for i in xrange(n): a[i] = map( int,raw_input().
s860357649
p02241
u536494052
1455029534
Python
Python
py
Runtime Error
0
0
736
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #!/usr/bin/env python from __future__ import division, print_function from sys import stdin, maxint def main(): num = int(stdin.readline()) M = [] for _ in xrange(num): M.append([int(s) for s in stdin.r...
s134245737
p02241
u536494052
1455029558
Python
Python
py
Runtime Error
0
0
736
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #!/usr/bin/env python from __future__ import division, print_function from sys import stdin, maxint def main(): num = int(stdin.readline()) M = [] for _ in xrange(num): M.append([int(s) for s in stdin.r...
s230452416
p02241
u233232390
1455029640
Python
Python
py
Runtime Error
0
0
402
n = raw_input() INFTY = 1000000 color = [0 for i in range(n)] M = [[INFTY for i in range(n)] for i in range(n)] d = [INFTY for i in range(n)] p = [-1 for i in range(n)] def prim(): for i in range(len(n)): d[i] = INFTY p[i] = -1 color[i] = WHITE while 1: minv = INFTY u = -1 for i in range...