s_id
string
p_id
string
u_id
string
date
string
language
string
original_language
string
filename_ext
string
status
string
cpu_time
string
memory
string
code_size
string
code
string
error
string
stdout
string
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 adj[u]: if not isVisited[v]: dfs(v, group) def makeCC(group): for i in range(n): if not isVisited[i]: dfs(i, group) group += 1 def isConnected(v1, v2): if CC[v1] == CC[v2]: print('yes') else: print('no') makeCC(0) q = int(input()) for i in range(q): s, t = map(int, input().split()) isConnected(s, t)
Traceback (most recent call last): File "/tmp/tmp0fvwagpa/tmpfzlvbylg.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 adj[u]: if not isVisited[v]: dfs(v, group) def makeCC(group): for i in range(n): if not isVisited[i]: dfs(i, group) group += 1 def isConnected(v1, v2): if CC[v1] == CC[v2]: print('yes') else: print('no') makeCC(0) q = int(input()) for i in range(q): s, t = map(int, input().split()) isConnected(s, t)
Traceback (most recent call last): File "/tmp/tmpvbabvlge/tmpu82pna19.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 adj[u]: if not isVisited[v]: dfs(v, group) def makeCC(group): for i in range(n): if not isVisited[i]: dfs(i, group) group += 1 def isConnected(v1, v2): if CC[v1] == CC[v2]: print('yes') else: print('no') makeCC(0) q = int(input()) for i in range(q): s, t = map(int, input().split()) isConnected(s, t)
Traceback (most recent call last): File "/tmp/tmpdk71puoh/tmp7n9d8jux.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 in adj[u]: if not isVisited[v]: dfs(v, group) def makeCC(group): for i in range(n): if not isVisited[i]: dfs(i, group) group += 1 def isConnected(v1, v2): if CC[v1] == CC[v2]: print('yes') else: print('no') makeCC(0) q = int(input()) for i in range(q): s, t = map(int, input().split()) isConnected(s, t)
Traceback (most recent call last): File "/tmp/tmpbvncs1hm/tmpysfl68n2.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 in adj[u]: if not isVisited[v]: dfs(v, group) def makeCC(group): for i in range(n): if not isVisited[i]: dfs(i, group) group += 1 def isConnected(v1, v2): if CC[v1] == CC[v2]: print('yes') else: print('no') makeCC(0) q = int(input()) for i in range(q): s, t = map(int, input().split()) isConnected(s, t)
Traceback (most recent call last): File "/tmp/tmpjidxwtxr/tmp04tvgyt4.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 in adj[u]: if not isVisited[v]: dfs(v, group) def makeCC(group): for i in range(n): if not isVisited[i]: dfs(i, group) group += 1 def isConnected(v1, v2): if CC[v1] == CC[v2]: print('yes') else: print('no') makeCC(0) q = int(input()) for i in range(q): s, t = map(int, input().split()) isConnected(s, t)
Traceback (most recent call last): File "/tmp/tmpcoq4_1mz/tmp5f_3494o.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 for v in adj[u]: if not isVisited[v]: dfs(v, group) def makeCC(group): for i in range(n): if not isVisited[i]: dfs(i, group) group += 1 def isConnected(v1, v2): if CC[v1] == CC[v2]: print('yes') else: print('no') makeCC(0) q = int(input()) for i in range(q): s, t = map(int, input().split()) isConnected(s, t)
Traceback (most recent call last): File "/tmp/tmpe35swze_/tmpv1za1p21.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 v in adj[u]: if not isVisited[v]: dfs(v, group) def makeCC(group): for i in range(n): if not isVisited[i]: dfs(i, group) group += 1 def isConnected(v1, v2): if CC[v1] == CC[v2]: print('yes') else: print('no') makeCC(0) q = int(input()) for i in range(q): s, t = map(int, input().split()) isConnected(s, t)
Traceback (most recent call last): File "/tmp/tmp9kspk9w7/tmp2a663u08.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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(int,input().split())) G = [[] for _ in range(n)] for _ in range(m): s,t = list(map(int,input().split())) G[s].append(t) G[t].append(s) q = int(input()) for _ in range(q): s,t = list(map(int,input().split())) print('yes' if connected(G,s,t) else 'no')
Traceback (most recent call last): File "/tmp/tmpmdz944b9/tmprbv_0vvv.py", line 14, in <module> n,m = list(map(int,input().split())) ^^^^^^^ EOFError: EOF when reading a line
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) if __name__=='__main__': n,m = list(map(int,input().split())) G = [[] for _ in range(n)] for _ in range(m): s,t = list(map(int,input().split())) G[s].append(t) G[t].append(s) q = int(input()) for _ in range(q): s,t = list(map(int,input().split())) print('yes' if connected(G,s,t) else 'no')
Traceback (most recent call last): File "/tmp/tmp90fo94gy/tmp_cmwulk4.py", line 17, in <module> n,m = list(map(int,input().split())) ^^^^^^^ EOFError: EOF when reading a line
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 return C if __name__=='__main__': n,m = list(map(int,input().split())) G = [[] for _ in range(n)] for i,line in enumerate(sys.stdin): if not i < m: q = int(line) break s,t = list(map(int,line.split())) G[s].append(t) G[t].append(s) cn = make_connected_group(G) for j,line in enumerate(sys.stdin): if not j < q: break s,t = list(map(int,line.split())) print('yes' if cn[s] == cn[t] else 'no')
Traceback (most recent call last): File "/tmp/tmpl6r5obkp/tmpaqp7qgzi.py", line 19, in <module> n,m = list(map(int,input().split())) ^^^^^^^ EOFError: EOF when reading a line
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(stack) debug(graph) if len(stack) == 0: debug(stack) return False v = stack.pop() status[v] = FOUND if v == end: return True edges = graph[v] if len(edges) != 0: stack.append(v) e = edges.pop(0) if e == end: return True if status[e] == NOT_FOUND: stack.append(e) status[e] = ENQUEUED return loop(stack, status, graph, start, end) return loop(stack, status, copy.deepcopy(graph), start, end) def bfs(graph, start, target): debug(graph) if start == target: return True queue = [] status = [NOT_FOUND] * len(graph) queue.append(start) while len(queue) != 0: node = queue.pop(0) status[node] = FOUND edges = graph[node] for e in edges: if e == target: return True if status[e] == NOT_FOUND: status[e] = ENQUEUED queue.append(e) return False if __name__ == "__main__": n, m = [int(x) for x in input().split()] g = [[] for i in range(n)] for i in range(m): u, e = [int(x) for x in input().split()] g[u].append(e) g[e].append(u) n = int(input()) for i in range(n): s, d = [int(x) for x in input().split()] if dfs(g, s, d): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmp8hh6e25r/tmpxa0hwrg8.py", line 67, in <module> n, m = [int(x) for x in input().split()] ^^^^^^^ EOFError: EOF when reading a line
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(int, input().split())) g = [[[], 0] for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) g[s][0].append(t) g[t][0].append(s) q = int(input()) for i in range(q): s, t = list(map(int, input().split())) result = search(s, t) if result: print("yes") else: print("no") for node in g: node[1] = 0
Traceback (most recent call last): File "/tmp/tmpe6_u3oq5/tmpbsaqk837.py", line 16, in <module> n, m = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
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 = [[] for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) g[s].append(t) g[t].append(s) q = int(input()) for i in range(q): s, t = list(map(int, input().split())) a = set() result = search(s, t, a) if result: print("yes") else: print("no") a.clear()
Traceback (most recent call last): File "/tmp/tmpau81si4n/tmpot48i488.py", line 14, in <module> n, m = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
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(vertex) vertices_status_list[vertex] = color while vertices_stack: current_vertex = vertices_stack[-1] vertices_stack.pop() for v in adj_list[current_vertex]: if vertices_status_list[v] == -1: vertices_status_list[v] = color vertices_stack.append(v) return None if __name__ == '__main__': _input = sys.stdin.readlines() vertices_num, relation_num = map(int, _input[0].split()) relation_info = _input[1:relation_num + 1] question_num = int(_input[relation_num + 1]) question_list = _input[relation_num + 2:] adj_list = [[] for _ in range(vertices_num)] vertices_status_list = [-1] * vertices_num for relation in relation_info: key, value = int(relation[0]), int(relation[2]) adj_list[key].append(value) adj_list[value].append(key) assign_color() # print(adj_list) for question in question_list: start, target = int(question[0]), int(question[2]) if vertices_status_list[start] == vertices_status_list[target]: print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmpsgu8vgdo/tmpk607mzha.py", line 32, in <module> vertices_num, relation_num = map(int, _input[0].split()) ~~~~~~^^^ IndexError: list index out of range
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 def graph_dfs(vertex, _color): vertices_stack = list() vertices_stack.append(vertex) _color[vertex] = _color while vertices_stack: current_vertex = vertices_stack.pop() for v in adj_table[current_vertex]: if _color[v] == -1: _color[v] = _color vertices_stack.append(v) return None def solve(): for relation in relation_info: key, value = map(int, relation) adj_table[key].append(value) adj_table[value].append(key) assign_color() # print(adj_list) for question in questions: start, target = map(int, question) if color[start] == color[target]: print("yes") else: print("no") return color if __name__ == '__main__': _input = sys.stdin.readlines() vertices, relations = map(int, _input[0].split()) relation_info = map(lambda x: x.split(), _input[1:relations + 1]) q_num = int(_input[relations + 1]) questions = map(lambda x: x.split(), _input[relations + 2:]) adj_table = tuple([] for _ in range(vertices)) color = [-1] * vertices ans = solve()
Traceback (most recent call last): File "/tmp/tmp17b8341v/tmpmynowibh.py", line 74, in <module> vertices, relations = map(int, _input[0].split()) ~~~~~~^^^ IndexError: list index out of range
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 __name__ == '__main__': # ??????????????\??? num_of_users, num_of_links = [int(x) for x in input().split(' ')] links = [] for _ in range(num_of_links): links.append(list(map(int, input().split(' ')))) num_of_queries = int(input()) queries = [] for _ in range(num_of_queries): queries.append(list(map(int, input().split(' ')))) # ??????????????? G = [[] for _ in range(11)] C = [-1] * 11 for f, t in links: G[f].append(t) G[t].append(f) color = 1 for id in range(num_of_users): if C[id] == -1: dfs(G, C, id, color) color += 1 # ??????????????? for x, y in queries: if C[x] == C[y]: print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmpr1jmb8n2/tmprh9ewrjl.py", line 18, in <module> num_of_users, num_of_links = [int(x) for x in input().split(' ')] ^^^^^^^ EOFError: EOF when reading a line
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[child] == 0: paint_col(adj, cols, child, col) def solve(): n, m = map(int, input().split()) adj = [[] for i in range(n)] for i in range(m): s, t = map(int, sys.stdin.readline().split()) adj[s].append(t) adj[t].append(s) cols = [0] * n col = 1 for i in range(n): if cols[i] == 0: paint_col(adj, cols, i, col) col += 1 # debug(cols, locals()) q = int(input()) for i in range(q): s, t = map(int, sys.stdin.readline().split()) if cols[s] == cols[t]: print('yes') else: print('no') pass if __name__ == '__main__': solve()
Traceback (most recent call last): File "/tmp/tmpijlihs_q/tmp8fzy419p.py", line 50, in <module> solve() File "/tmp/tmpijlihs_q/tmp8fzy419p.py", line 19, in solve n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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] == 0: paint_col(adj, cols, child, col) def solve(): n, m = map(int, input().split()) adj = [[] for i in range(n)] for i in range(m): s, t = map(int, sys.stdin.readline().split()) adj[s].append(t) adj[t].append(s) cols = [0] * n col = 1 for i in range(n): if cols[i] == 0: paint_col(adj, cols, i, col) col += 1 # debug(cols, locals()) q = int(input()) for i in range(q): s, t = map(int, sys.stdin.readline().split()) if cols[s] == cols[t]: print('yes') else: print('no') pass if __name__ == '__main__': solve()
Traceback (most recent call last): File "/tmp/tmp65y48eab/tmpuo2ztiti.py", line 50, in <module> solve() File "/tmp/tmp65y48eab/tmpuo2ztiti.py", line 19, in solve n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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] == 0: paint_col(adj, cols, child, col) def solve(): n, m = map(int, input().split()) adj = [[] for i in range(n)] for i in range(m): s, t = map(int, sys.stdin.readline().split()) adj[s].append(t) adj[t].append(s) cols = [0] * n col = 1 for i in range(n): if cols[i] == 0: paint_col(adj, cols, i, col) col += 1 # debug(cols, locals()) q = int(input()) for i in range(q): s, t = map(int, sys.stdin.readline().split()) if cols[s] == cols[t]: print('yes') else: print('no') pass if __name__ == '__main__': solve()
Traceback (most recent call last): File "/tmp/tmpsx285yrx/tmped96it2s.py", line 50, in <module> solve() File "/tmp/tmpsx285yrx/tmped96it2s.py", line 19, in solve n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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]) if cols[v] == 0: cols[v] = col nxt.append(v) except StopIteration: nxt.pop() cols[u] = col def solve(): n, m = map(int, sys.stdin.readline().split()) adj = [[] for i in range(n)] for i in range(m): s, t = map(int, sys.stdin.readline().split()) adj[s].append(t) adj[t].append(s) cols = [0] * n col = 1 adj = list(map(iter, adj)) for i in range(n): if cols[i] == 0: paint_col(adj, cols, i, col) col += 1 debug(cols, locals()) q = int(sys.stdin.readline()) for i in range(q): s, t = map(int, sys.stdin.readline().split()) if cols[s] == cols[t]: ans = 'yes' else: ans = 'no' print(ans) if __name__ == '__main__': solve()
Traceback (most recent call last): File "/tmp/tmpgwsfsev_/tmp_ek6uuzv.py", line 56, in <module> solve() File "/tmp/tmpgwsfsev_/tmp_ek6uuzv.py", line 24, in solve n, m = map(int, sys.stdin.readline().split()) ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
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) { if (p[i][k] > 0) return p[i][k]; if (k == 0) return p[i][k] = 1.0; /** * ?????????????????¢????????°??§????????????????§£?????¨???????????????????????? */ int index = i / (int)pow(2.0, k-1); int player; if (index % 2 == 0) { player = (index+1)*pow(2, k-1); } else { player = (index-1)*pow(2, k-1); } for (int j = 0; j < pow(2, k-1); j++){ p[i][k] += wp(i,k-1)*win(i, player + j)*wp(player+j, k-1); } return p[i][k]; } void solve_by_loop() { for (int i = 0; i < (int)pow(2.0, n); i++) { p[i][0] = 1.0; } for (int k = 1; k <= n; k++) { for (int i = 0; i < (int)pow(2.0, n); i++) { int index = i / (int)pow(2.0, k-1); int player; if (index % 2 == 0) { player = (index+1)*pow(2,k-1); } else { player = (index-1)*pow(2,k-1); } for (int j = 0; j < pow(2, k-1); j++) { p[i][k] += p[i][k-1]*win(i, player+j)*p[player+j][k-1]; } } } for (int i = 0; i < pow(2, n); i++) { printf("%.10lf\n", p[i][n]); } } void solve() { for (int i = 0; i < (int)pow(2.0, n); i++) { printf("%.10lf\n", wp(i, n)); } } int main() { cin >> n; for (int i = 0; i < (int)pow(2.0, n); i++) { cin >> ratings[i]; } solve(); //solve_by_loop(); return 0; }
File "/tmp/tmpcmjtdiot/tmpuin_1wba.py", line 20 * ?????????????????¢????????°??§????????????????§£?????¨???????????????????????? ^ SyntaxError: invalid character '¢' (U+00A2)
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) { if (p[i][k] > 0) return p[i][k]; if (k == 0) return p[i][k] = 1.0; /** * ?????????????????¢????????°??§????????????????§£?????¨???????????????????????? */ int index = i / (int)pow(2.0, k-1); int player; if (index % 2 == 0) { player = (index+1)*pow(2, k-1); } else { player = (index-1)*pow(2, k-1); } for (int j = 0; j < pow(2, k-1); j++){ p[i][k] += wp(i,k-1)*win(i, player + j)*wp(player+j, k-1); } return p[i][k]; } void solve_by_loop() { for (int i = 0; i < (int)pow(2.0, n); i++) { p[i][0] = 1.0; } for (int k = 1; k <= n; k++) { for (int i = 0; i < (int)pow(2.0, n); i++) { int index = i / (int)pow(2.0, k-1); int player; if (index % 2 == 0) { player = (index+1)*pow(2,k-1); } else { player = (index-1)*pow(2,k-1); } for (int j = 0; j < pow(2, k-1); j++) { p[i][k] += p[i][k-1]*win(i, player+j)*p[player+j][k-1]; } } } for (int i = 0; i < pow(2, n); i++) { printf("%.10lf\n", p[i][n]); } } void solve() { for (int i = 0; i < (int)pow(2.0, n); i++) { printf("%.10lf\n", wp(i, n)); } } int main() { cin >> n; for (int i = 0; i < (int)pow(2.0, n); i++) { cin >> ratings[i]; } solve(); //solve_by_loop(); return 0; }
File "/tmp/tmpei1tx4p6/tmp09wy5d7y.py", line 20 * ?????????????????¢????????°??§????????????????§£?????¨???????????????????????? ^ SyntaxError: invalid character '¢' (U+00A2)
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, done) return done q = int(input()) n = set(g.keys()) cc = [] while n != set([]): t = n.pop() d = dfs(g, t, []) cc.append(d) n = n - set(d) for j in range(q): s,t = map(int,input().split()) k = True for c in cc: if s in c and t in c: print('yes') k = False break if k: print('no')
Traceback (most recent call last): File "/tmp/tmpkguo49ag/tmpegtycj4n.py", line 1, in <module> n, m = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
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(s) for c in g[s]: dfs(g, c, done) return done q = int(input()) n = set(g.keys()) cc = [] from sys import setrecursionlimit setrecursionlimit(1500) while n != set([]): t = n.pop() d = dfs(g, t, []) cc.append(d) n = n - set(d) for j in range(q): s,t = map(int,input().split()) k = True for c in cc: if s in c and t in c: print('yes') k = False break if k: print('no')
Traceback (most recent call last): File "/tmp/tmpt93hkzkb/tmpfze92tm7.py", line 1, in <module> n, m = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 != []: t = stack.pop() for c in g[t]: if done[c] == -1: done[c] = color stack.append(c) return q = int(input()) n = set(g.keys()) for v in range(m): if done[v] == -1: dfs(g,v) color += 1 for j in range(q): s,t = map(int,input().split()) if done[s] == done[t]: print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmpy_zbh35r/tmpvndfgrie.py", line 1, in <module> n, m = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 in istr.splitlines(): ilist.append(list(map(int,i.split()))) #print(ilist) unum, fnum = ilist[0] Dst = [[] for i in range(unum)] fnum += 1 for n in range(1, fnum): uid, fid = ilist[n] Dst[uid].append(fid) Dst[fid].append(uid) qnum = ilist[fnum][0] fnum += 1 #print("fnum={} qnum={}".format(fnum,qnum)) for q in range(fnum, (fnum + qnum)): id1, id2 = ilist[q] Lng = [-1] * (fnum) #print("[{}] id1={:2} id2={:2} Dst:{} Lng:{}".format(q,id1, id2, Dst, Lng)) srch(id1, id2, 0, Dst, Lng) if Lng[id2] != -1: print("yes") else: print("no") if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmp0rxxam41/tmp_408zbkv.py", line 42, in <module> main() File "/tmp/tmp0rxxam41/tmp_408zbkv.py", line 19, in main unum, fnum = ilist[0] ~~~~~^^^ IndexError: list index out of range
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 dfs(s,t,c,A) if c[t] == -1: a[i] = 'no' else: a[i] = 'yes' for i in a: print i def dfs(u,t,color,A): color[u] = 0 for i in A[u]: if i == t: color[t] = 1 break elif (color[i] == -1): dfs(i,t,color,A) color[u] = 1 if __name__ == '__main__': main()
File "/tmp/tmplkazvv0i/tmpa6jt898c.py", line 21 print i ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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:] for next in graph[now][1:]: if not (next in visited): unvisited.append(next) visited[next] = now return "no" n, m = map(int, input().split()) g = [[i] for i in range(n)] c = {} for i in range(m): inp = list(map(int, input().split())) g[inp[0]].append(inp[1]) g[inp[1]].append(inp[0]) q = int(input()) for i in range(q): s, t = map(int, input().split()) print(bfs(g, s, t, c))
Traceback (most recent call last): File "/tmp/tmpzcn0upn7/tmpx6nsq1g9.py", line 16, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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:] for next in graph[now]: if not (next in visited): unvisited.append(next) visited[next] = now return "no" n, m = map(int, input().split()) g = [None]*n c = {} for i in range(m): inp = list(map(int, input().split())) g[inp[0]].append(inp[1]) g[inp[1]].append(inp[0]) q = int(input()) for i in range(q): s, t = map(int, input().split()) print(bfs(g, s, t, c))
Traceback (most recent call last): File "/tmp/tmp5rjzbio5/tmpaxkbh3wq.py", line 16, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 "yes" unvisited = unvisited[1:] for next in graph[now]: if not (next in visited): unvisited.append(next) visited[next] = now return "no" n, m = map(int, input().split()) g = [[] for i in range(n)] c = {} for i in range(m): inp = list(map(int, input().split())) g[inp[0]].append(inp[1]) g[inp[1]].append(inp[0]) connection[1000000*inp[0] + inp[1]] = 1 connection[1000000*inp[1] + inp[0]] = 1 q = int(input()) for i in range(q): s, t = map(int, input().split()) print(bfs(g, s, t, c))
Traceback (most recent call last): File "/tmp/tmp2zdu4xrh/tmpbcmy5rr3.py", line 17, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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[1000000*goal + start] = 1 return "yes" for next in graph[now]: if not (next in visited): unvisited.append(next) visited[next] = now return "no" n, m = map(int, input().split()) g = [[] for i in range(n)] c = {} for i in range(m): inp = list(map(int, input().split())) g[inp[0]].append(inp[1]) g[inp[1]].append(inp[0]) c[1000000*inp[0] + inp[1]] = 1 c[1000000*inp[1] + inp[0]] = 1 q = int(input()) for i in range(q): s, t = map(int, input().split()) print(bfs(g, s, t, c))
Traceback (most recent call last): File "/tmp/tmp_cwltu47/tmpci63aqcz.py", line 18, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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[goal].add(start) return "yes" for next in graph[now]: if not (next in visited): unvisited.append(next) visited[next] = now return "no" n, m = map(int, input().split()) g = [set() for i in range(n)] c = [set() for i in range(n)] for i in range(m): a, b = map(int, input().split()) g[a].add(b) g[b].add(a) c[a].add(b) c[b].add(inp[a]) q = int(input()) for i in range(q): s, t = map(int, input().split()) print(bfs(g, s, t, c))
Traceback (most recent call last): File "/tmp/tmpsmmhmdrj/tmpl54s5fl8.py", line 19, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 hasSameRoot(x, y-1) for i in range(m): s, t = map(int, input().split()) if rootList[s] < 0: rootList[s] = s if rootList[t] < 0: rootList[t] = t if rootList[s] != rootList[t]: rootList[s] = min(rootList[s], rootList[t]) rootList[t] = min(rootList[s], rootList[t]) q = int(input()) for i in range(q): s, t = map(int, input().split()): if hasSameRoot(s, t): print("yes") else: print("no")
File "/tmp/tmpm8ocw_2j/tmpxk02kqe_.py", line 27 s, t = map(int, input().split()): ^ SyntaxError: invalid syntax
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, t = map(int, input().split()) setSameRoot(s, t) q = int(input()) for i in range(0, q): s, t = map(int, input().split()) print("yes" if getRoot(s) == getRoot(t) else "no")
Traceback (most recent call last): File "/tmp/tmp7t2ybhm5/tmpwdc7xs3i.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 = map(int, input().split()) setSameRoot(s, t) q = int(input()) for i in range(q): s, t = map(int, input().split()) print("yes" if getRoot(s) == getRoot(t) != -1 else "no")
Traceback (most recent call last): File "/tmp/tmp5opbc_7v/tmpgjja64wb.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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()) setSameRoot(s, t) q = int(input()) for i in range(q): s, t = map(int, input().split()) print("yes" if getRoot(s) == getRoot(t) else "no")
Traceback (most recent call last): File "/tmp/tmpznaaoszf/tmpjydzsq1y.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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(m): s, t = map(int, input().split()) setSameRoot(s, t) q = int(input()) for i in range(q): s, t = map(int, input().split()) print("yes" if getRoot(s) == getRoot(t) else "no")
Traceback (most recent call last): File "/tmp/tmpdmdijkdm/tmpc74qn33v.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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(m): s, t = map(int, input().split()) setSameRoot(s, t) q = int(input()) for i in range(q): s, t = map(int, input().split()) print("yes" if getRoot(s) == getRoot(t) != -1 else "no")
Traceback (most recent call last): File "/tmp/tmp0lfui1vf/tmp_4wbqpgn.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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) for i in range(m): s, t = map(int, input().split()) setSameRoot(s, t) q = int(input()) for i in range(q): s, t = map(int, input().split()) print("yes" if getRoot(s) == getRoot(t) != -1 else "no")
Traceback (most recent call last): File "/tmp/tmpaidnt2it/tmpgbnl281d.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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] = rootList[y] = min(x, y) for i in range(m): s, t = map(int, input().split()) setSameRoot(s, t) q = int(input()) for i in range(q): s, t = map(int, input().split()) print("yes" if getRoot(s) == getRoot(t) else "no")
Traceback (most recent call last): File "/tmp/tmp_cn9zuin/tmpjsp_ll8e.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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): if (color[i] == False): dfs(i, c) c += 1 n, m = list(map(int, input().split())) G = [False for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) G[s].append(t) G[t].append(s) color = [False for i in range(n)] assignColor() q = int(input()) for i in range(q): s, t = list(map(int, input().split())) if (color[s] == color[t]): print("yes") else: print("no")
File "/tmp/tmp2zg0dgkm/tmpj5lgpek3.py", line 2 global c, color ^^^^^^^^^^^^^^^ SyntaxError: name 'c' is parameter and global
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 range(n): if (color[i] == False): dfs(i, c) c += 1 n, m = list(map(int, input().split())) G = [False for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) G[s].append(t) G[t].append(s) color = [False for i in range(n)] assignColor() q = int(input()) for i in range(q): s, t = list(map(int, input().split())) if (color[s] == color[t]): print("yes") else: print("no")
File "/tmp/tmp_a9li5wo/tmpop7_nscp.py", line 2 global c, color, G ^^^^^^^^^^^^^^^^^^ SyntaxError: name 'c' is parameter and global
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(n): if (color[i] == None): dfs(i, c) c += 1 n, m = list(map(int, input().split())) G = [None for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) G[s].append(t) G[t].append(s) color = [False for i in range(n)] assignColor() q = int(input()) for i in range(q): s, t = list(map(int, input().split())) if (color[s] == color[t]): print("yes") else: print("no")
File "/tmp/tmp9y15x1ff/tmpi0sv80uu.py", line 2 global c, color, G ^^^^^^^^^^^^^^^^^^ SyntaxError: name 'c' is parameter and global
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): if (color[i] == None): dfs(i, c) c += 1 n, m = list(map(int, input().split())) G = [None for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) G[s].append(t) G[t].append(s) color = [False for i in range(n)] assignColor() q = int(input()) for i in range(q): s, t = list(map(int, input().split())) if (color[s] == color[t]): print("yes") else: print("no")
File "/tmp/tmpud6ppnh0/tmp_6gcythy.py", line 2 global c, color, G ^^^^^^^^^^^^^^^^^^ SyntaxError: name 'c' is parameter and global
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): if (color[i] == None): dfs(i, c) c += 1 n, m = list(map(int, input().split())) G = [None for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) G[s].append(t) G[t].append(s) color = [False for i in range(n)] assignColor() q = int(input()) for i in range(q): s, t = list(map(int, input().split())) if (color[s] == color[t]): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmphbey4h_p/tmpazmv4tex.py", line 21, in <module> n, m = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
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 dfs(u, c): # depth-first search color[u] = c for v in M[u]: if color[v] == 0: dfs(v, c) c = 1 for u in range(n): if color[u] == 0: dfs(u, c) c += 1 l = int(input()) for _ in range(l): p, q = [int(s) for s in input().split(" ")] if color[p] == color[q]: print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmp5g49_qya/tmpnoa_rfzi.py", line 7, in <module> n, m = [int(s) for s in input().split(" ")] ^^^^^^^ EOFError: EOF when reading a line
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 dfs(u, c): # depth-first search color[u] = c for v in M[u]: if color[v] == 0: dfs(v, c) c = 1 for u in range(n): if color[u] == 0: dfs(u, c) c += 1 l = int(input()) for _ in range(l): p, q = [int(s) for s in input().split(" ")] if color[p] == color[q]: print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmpmu1d42t6/tmpqjd33yx9.py", line 7, in <module> n, m = [int(s) for s in input().split(" ")] ^^^^^^^ EOFError: EOF when reading a line
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) color = [0] * n def dfs(u, c): # depth-first search color[u] = c for v in M[u]: if color[v] == 0: dfs(v, c) c = 1 for u in range(n): if color[u] == 0: dfs(u, c) c += 1 l = int(input()) for _ in range(l): p, q = [int(s) for s in input().split(" ")] if color[p] == color[q]: print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmphdp2vhqq/tmp8tij0d4k.py", line 9, in <module> n, m = [int(s) for s in input().split(" ")] ^^^^^^^ EOFError: EOF when reading a line
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[a], b) li[a] = b for _ in range(m): x, y = map(int, readline().split()) if f(x) > f(y): f2(x, li[y]) elif f(x) < f(y): f2(y, li[x]) for _ in range(int(input())): x, y = map(int, readline().split()) print("yes" if f(a) == f(b) else "no") MAIN()
File "/tmp/tmp1jqixwm5/tmpyo8jwbth.py", line 25 print("yes" if f(a) == f(b) else "no") TabError: inconsistent use of tabs and spaces in indentation
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[a], b) li[a] = b for _ in range(m): x, y = map(int, readline().split()) if f(x) > f(y): f2(x, li[y]) elif f(x) < f(y): f2(y, li[x]) for _ in range(int(input())): x, y = map(int, readline().split()) print("yes" if f(a) == f(b) else "no") MAIN()
Traceback (most recent call last): File "/tmp/tmpfair9kx6/tmpphjp97or.py", line 26, in <module> MAIN() File "/tmp/tmpfair9kx6/tmpphjp97or.py", line 4, in MAIN n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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(int,e().split()) print(['no','yes'][C[a]==C[b]]) if'__main__'==__name__:s()
Traceback (most recent call last): File "/tmp/tmpsarfdr2r/tmpuykznw8z.py", line 20, in <module> if'__main__'==__name__:s() ^^^ File "/tmp/tmpsarfdr2r/tmpuykznw8z.py", line 2, in s e=sys.stdin.readline ^^^ NameError: name 'sys' is not defined
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())) memo[data[0]] = 1 queue = deque(data[0]) try: while len(queue): b = queue.popleft() for k in a[b]: if k == data[1]: print("yes") raise Exception if memo[k] == 0: memo[k] = 1 queue.append(k) print("no") except Exception: pass
Traceback (most recent call last): File "/tmp/tmpfqzaowyu/tmpl1ssude1.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
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].append(u) # 幅優先 def adj_bfs(s, e): queue = deque([]) colors = [Color.WHITE for i in range(n)] queue.append(s) colors[s] = Color.GRAY while len(queue) > 0: u = queue.popleft() for v in adj_list[u]: if colors[v] == Color.WHITE: colors[v] = Color.GRAY queue.append(v) if v == e: return True colors[u] = Color.BLACK return False # 深さ優先 colors = [Color.WHITE for i in range(n)] def adj_dfs(u, e): colors[u] = Color.GRAY for v in adj_list[u]: if colors[v] == Color.WHITE: if v == e: return True if adj_dfs(v, e): return True colors[u] = Color.BLACK return False q = int(input()) for i in range(q): s, e = list(map(int, input().split(' '))) colors = [Color.WHITE for i in range(n)] if adj_dfs(s, e): print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmpv0mhuqk8/tmpw7li8up0.py", line 9, in <module> n, m = list(map(int, input().split(' '))) ^^^^^^^ EOFError: EOF when reading a line
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)] def dfs(id, color): if color_list[id] == -1: color_list[id] = color for a_id in adja_list[id]: dfs(a_id, color) for rel in rel_list: adja_list[rel[0]].add(rel[1]) adja_list[rel[1]].add(rel[0]) color = 0 for id in range(user_num): dfs(id, color) color += 1 for ques in ques_list: if color_list[ques[0]] == color_list[ques[1]]: print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmpy3dirc2o/tmp2hitjmbf.py", line 3, in <module> [user_num, rel_num] = input_lines[0] ~~~~~~~~~~~^^^ IndexError: list index out of range
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)] node_chk = [0 for i in range(n)] connect = [0 for i in range(n)] value = 0 for i in range(m): A = list(map(int,input().split())) B[A[0]].append(A[1]) B[A[1]].append(A[0]) edge_chk[A[0]].append(0) edge_chk[A[1]].append(0) for i in range(n): if(node_chk[i] == 1): continue dfs(i) value += 1 q = int(input()) for i in range(q): start,target = map(int,input().split()) if(connect[start] == connect[target]): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmpzq7hxyi0/tmpxauwe7l0.py", line 16, in <module> n,m = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
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)] # 隣接リスト edge_chk = [[]for i in range(n)] node_chk = [0 for i in range(n)] connect = [0 for i in range(n)] value = 0 for i in range(m): A = list(map(int,input().split())) B[A[0]].append(A[1]) B[A[1]].append(A[0]) edge_chk[A[0]].append(0) edge_chk[A[1]].append(0) for i in range(n): if(node_chk[i] == 1): continue dfs(i) value += 1 q = int(input()) for i in range(q): start,target = map(int,input().split()) if(connect[start] == connect[target]): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmpqoz4wyja/tmpkgbomd3y.py", line 19, in <module> n,m = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
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)] # 隣接リスト edge_chk = [[]for i in range(n)] node_chk = [0 for i in range(n)] connect = [0 for i in range(n)] value = 0 for i in range(m): A = list(map(int,input().split())) B[A[0]].append(A[1]) B[A[1]].append(A[0]) edge_chk[A[0]].append(0) edge_chk[A[1]].append(0) for i in range(n): if(node_chk[i] == 1): continue dfs(i) value += 1 q = int(input()) for i in range(q): start,target = map(int,input().split()) if(connect[start] == connect[target]): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmptug2zqex/tmpolk0l46s.py", line 19, in <module> n,m = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
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]][S[1]] = 1 G[S[1]][S[0]] = 1 q = int(input()) ans = [] for i in range(q): Q = list(map(int, input().split())) if Q[0]<Q[1]: st = Q[0] fi = Q[1] else: st = Q[1] fi = Q[0] flag = 0 tan(G,st,fi) if flag==1: ans.append("yes") else: ans.append("no") for i in range(q): print(ans[i])
Traceback (most recent call last): File "/tmp/tmpeaztg249/tmpx1v46xsd.py", line 9, in <module> n,m = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
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 return if color[per] == "white": color[per] = "gray" search(per, target) color[person] = "black" num = int(input()) for i in range(num): yes = 0 color = ["white" for j in range(n)] person, target = map(int,input().split()) search(person, target) if yes == 0: print("no") else: print("yes")
Traceback (most recent call last): File "/tmp/tmp3wgk1e99/tmpbqlnrz8b.py", line 2, in <module> n, r = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
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: global yes yes = 1 return if color[per] == "white": color[per] = "gray" search(per, target) color[person] = "black" num = int(input()) for i in range(num): yes = 0 color = ["white" for j in range(n)] person, target = map(int,input().split()) search(person, target) if yes == 0: print("no") else: print("yes")
Traceback (most recent call last): File "/tmp/tmpzwchn4fn/tmp0fwfzzt6.py", line 4, in <module> n, r = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
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 DP: heapq.heappush(h,(j,i)) print(c)
Traceback (most recent call last): File "/tmp/tmpij1ajz66/tmpwj9j5v5a.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
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()) vertex_flag=[0]*graph_n searched_vertex_num=0 cost=0 for edges in sorted_edge: for edge in edges[1]: if(vertex_flag[edge[0]]==0 and vertex_flag[edge[1]]==0): vertex_flag[edge[0]]=1 vertex_flag[edge[1]]=1 seached_vertex_num+=2 cost+=edges[0] if(graph_n <=searched_vertex_num): break elif(vertex_flag[edge[0]]==0 and vertex_flag[edge[1]]==1): vertex_flag[edge[0]]=1 vertex_flag[edge[1]]=1 seached_vertex_num+=1 cost+=edges[0] if(graph_n <=searched_vertex_num): break elif(vertex_flag[edge[0]]==1 and vertex_flag[edge[1]]==0): vertex_flag[edge[0]]=1 vertex_flag[edge[1]]=1 seached_vertex_num+=1 cost+=edges[0] if(graph_n <=searched_vertex_num): break if(graph_n <=searched_vertex_num): break print(cost)
Traceback (most recent call last): File "/tmp/tmp3vtd5ghk/tmp2fsaisa1.py", line 1, in <module> graph_n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
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(x) == self.find(y) def unite(self, x, y): x, y = self.find(x), self.find(y) if x == y: return self.g_num -= 1 if (self.rank[x] > self.rank[y]): self.par[y] = x else: self.par[x] = y if (self.rank[x] == self.rank[y]): self.rank[y] += 1 def group_num(self): return self.g_num V, E = map(int, raw_input().split()) es = [map(int, raw_input().split()) for i in xrange(E)] es.sort(key = lambda x: x[2]) uf = UnionFind(V) ans = 0 for e in es: if not uf.same(e[0], e[1]): uf.unite(e[0], e[1]) ans += e[2] print ans
File "/tmp/tmp9e52yvmt/tmpazs8ecrf.py", line 41 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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 used[j] = True sumcost = sumcost + mincost[j] for i in range(V): if cost[i][j] == -1: continue mincost[i] = min(mincost[i], cost[j][i]) return sumcost n = int(raw_input()) A = [0] * n for i in range(n) A[i] = map(int, raw_input().split()) result = prim(A) print(result)
File "/tmp/tmp89dtq3tb/tmpy4falvc6.py", line 10 if not used[i] and (j = -1 or mincost[i] < mincost[j]): ^^^^^^ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
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 = j A.append(addA) NY.remove(addA) long += amin print long
File "/tmp/tmpjhvmbreq/tmp7q97_c2_.py", line 5 a = [[0 for i in xrange(n)] for j in xrange(n) ^ SyntaxError: '[' was never closed
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] addA = j A.append(addA) NY.remove(addA) long =long + amin print long
File "/tmp/tmp8i1wc2fz/tmpjpja7f5c.py", line 20 print long ^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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] u = i if cost == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and M[u][v] != INFTY: if M[u][v] < d[v]: d[v] = M[u][v] p[v] = u color[v] = 1: sum = 0 for i in range(n): if p[i] != -1: sum += M[i][p[i]] return sum for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] == -1: M[i][j] = INFTY else: M[i][j] = G[n]: print MST()
File "/tmp/tmpx4kggg0a/tmpt3vsu1wj.py", line 27 if M[u][v] < d[v]: ^ IndentationError: expected an indented block after 'if' statement on line 26
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] u = i if cost == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and M[u][v] != INFTY: if M[u][v] < d[v]: d[v] = M[u][v] p[v] = u color[v] = 1: sum = 0 for i in range(n): if p[i] != -1: sum += M[i][p[i]] return sum for i in range(n): G = map(int, raw_input().split()) for j in range(n): if G[j] == -1: M[i][j] = INFTY else: M[i][j] = G[n]: print MST()
File "/tmp/tmpn1_8q6u3/tmp47poae5a.py", line 27 if M[u][v] < d[v]: ^ IndentationError: expected an indented block after 'if' statement on line 26
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] u = i if cost == INFTY: break color[u] = 2 for v in xrange(n): if color[v] != 2 and M[u][v] != INFTY: if M[u][v] < d[v]: d[v] = M[u][v] p[v] = u color[v] = 1: sum = 0 for i in xrange(n): if p[i] != -1: sum += M[i][p[i]] return sum for i in xrange(n): G = map(int, raw_input().split()) for j in range(n): if G[j] == -1: M[i][j] = INFTY else: M[i][j] = G[n]: print sum
File "/tmp/tmp36kad26d/tmpbdljtuw_.py", line 27 if M[u][v] < d[v]: ^ IndentationError: expected an indented block after 'if' statement on line 26
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] u = i if cost == INFTY: break color[u] = 2 for v in xrange(n): if color[v] != 2 and M[u][v] != INFTY: if M[u][v] < d[v]: d[v] = M[u][v] p[v] = u color[v] = 1: sum = 0 for i in xrange(n): if p[i] != -1: sum += M[i][p[i]] return sum for i in xrange(n): G = map(int, raw_input().split()) for j in range(n): if G[j] == -1: M[i][j] = INFTY else: M[i][j] = G[n]: print MST()
File "/tmp/tmp4xm6tyia/tmpjsm2p76b.py", line 17 if color[i] != 1 and d[i] < cost ^ SyntaxError: expected ':'
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] u = i if cost == INFTY: break color[u] = 2 for v in xrange(n): if color[v] != 2 and M[u][v] != INFTY: if M[u][v] < d[v]: d[v] = M[u][v] p[v] = u color[v] = 1: sum = 0 for i in xrange(n): if p[i] != -1: sum += M[i][p[i]] return sum for i in xrange(n): G = map(int, raw_input().split()) for j in range(n): if G[j] == -1: M[i][j] = INFTY else: M[i][j] = G[n] print MST()
File "/tmp/tmphb7354hc/tmpj0qcuxz5.py", line 27 if M[u][v] < d[v]: ^ IndentationError: expected an indented block after 'if' statement on line 26
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 = i if cost == INFTY: break color[u] = 2 for v in xrange(n): if color[v] != 2 and M[u][v] != INFTY: if M[u][v] < d[v]: d[v] = M[u][v] p[v] = u color[v] = 1: sum = 0 for i in xrange(n): if p[i] != -1: sum += M[i][p[i]] return sum for i in xrange(n): G = map(int, raw_input().split()) for j in range(n): if G[j] == -1: M[i][j] = INFTY else: M[i][j] = G[n] print MST()
File "/tmp/tmp2a0ayagc/tmpeaeu5zd8.py", line 29 color[v] = 1: ^ SyntaxError: invalid syntax
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 = i if cost == INFTY: break color[u] = 2 for v in xrange(n): if color[v] != 2 and M[u][v] != INFTY: if M[u][v] < d[v]: d[v] = M[u][v] p[v] = u color[v] = 1 sum = 0 for i in xrange(n): if p[i] != -1: sum += M[i][p[i]] return sum for i in xrange(n): G = map(int, raw_input().split()) for j in range(n): if G[j] == -1: M[i][j] = INFTY else: M[i][j] = G[n] print MST()
File "/tmp/tmphp5o0kpj/tmp75379m4m.py", line 45 print MST() ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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] add_A = j A.append( add_A ) NY.remove( add_A ) l += a_min print l
File "/tmp/tmpm0lj7p9n/tmpi2aymggf.py", line 18 print l ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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: minimum = maxint for j in h: mj = M[j-1] for i in g: if 0 <= mj[i-1] < minimum: index = i minimum = mj[i-1] h.add(index) g.remove(index) weight += minimum main()
Traceback (most recent call last): File "/tmp/tmpw1vjmg2t/tmpizwiotca.py", line 2, in <module> from sys import stdin, maxint ImportError: cannot import name 'maxint' from 'sys' (unknown location)
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: minimum = maxint for j in h: mj = M[j-1] for i in g: if 0 <= mj[i-1] < minimum: index = i minimum = mj[i-1] h.add(index) g.remove(index) weight += minimum main()
Traceback (most recent call last): File "/tmp/tmp6ql78bar/tmpqxhhjt22.py", line 2, in <module> from sys import stdin, maxint ImportError: cannot import name 'maxint' from 'sys' (unknown location)
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] * num weight[0] = 0 t = set(xrange(1, num)) index = 0 while t: for v, cost in y[index]: if v not in t: continue weight[v] = min(weight[v], cost + weight[index]) index = min(t, key=lambda i: weight[i]) t.remove(index) for i, d in enumerate(weight): print(i, d) main()
Traceback (most recent call last): File "/tmp/tmpc7zjwnnx/tmplsv0knxu.py", line 2, in <module> from sys import stdin, maxint ImportError: cannot import name 'maxint' from 'sys' (unknown location)
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] * num weight[0] = 0 t = set(xrange(1, num)) index = 0 while t: for v, cost in y[index]: if v not in t: continue weight[v] = min(weight[v], cost + weight[index]) index = min(t, key=lambda i: weight[i]) t.remove(index) for i, d in enumerate(weight): print(i, d) main()
Traceback (most recent call last): File "/tmp/tmpu_qjs50t/tmp3q12vvy3.py", line 2, in <module> from sys import stdin, maxint ImportError: cannot import name 'maxint' from 'sys' (unknown location)
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] * num weight[0] = 0 t = set(xrange(1, num)) index = 0 while t: for v, cost in y[index]: if v not in t: continue weight[v] = min(weight[v], cost + weight[index]) index = min(t, key=lambda i: weight[i]) t.remove(index) for i, d in enumerate(weight): print(i, d) main()
File "/tmp/tmpx9f4ycbu/tmptqh62tig.py", line 23 index = min(t, key=lambda i: weight[i]) ^ IndentationError: unindent does not match any outer indentation level
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] * num weight[0] = 0 t = set(xrange(1, num)) index = 0 while t: for v, cost in y[index]: if v not in t: continue weight[v] = min(weight[v], cost + weight[index]) index = min(t, key=lambda i: weight[i]) t.remove(index) for i, d in enumerate(weight): print(i, d) main()
Traceback (most recent call last): File "/tmp/tmp7wtm9yix/tmpbo0cxxie.py", line 2, in <module> from sys import stdin, maxint ImportError: cannot import name 'maxint' from 'sys' (unknown location)
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] * num weight[0] = 0 t = set(xrange(1, num)) index = 0 while t: for v, cost in y[index]: if v not in t: continue weight[v] = min(weight[v], cost + weight[index]) index = min(t, key=lambda i: weight[i]) t.remove(index) for i, d in enumerate(weight): print(i, d) main()
Traceback (most recent call last): File "/tmp/tmpymzx9njx/tmpr91gegto.py", line 2, in <module> from sys import stdin, maxint ImportError: cannot import name 'maxint' from 'sys' (unknown location)
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 omomi = omomi + c print omomi
File "/tmp/tmpmb91sxkz/tmpl40dbu4w.py", line 9 while B! = []: ^ SyntaxError: invalid syntax
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 omomi
File "/tmp/tmpb431p6gh/tmpjxgd5dvf.py", line 9 while B! = []: ^ SyntaxError: invalid syntax
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 color[i] != 2: u = i minv = d[i] if u == -1: break color[u] = 2 for v in xrange(n): if color[v] != 2 and data[u][v] != float('inf'): if (d[v] > data[u][v]): d[v] = data[u][v] p[v] = u color[v] = 1 sum_val = 0 for i in xrange(n): if p[i] != -1: sum_val += data[i][p[i]] return sum_val n = input() data = [None] * n for i in xrange(n): data[i] = [None] * n line = map(int, raw_input().split()) for j in xrange(n): if line[j] == -1: data[i][j] = float('inf') else: data[i][j] = line[j]; print prim(n)
File "/tmp/tmpoy6ha48c/tmpv7_3fnww.py", line 50 print prim(n) ^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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 == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]: d[v] = m[u][v] k[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += m[i][k[i]] return sum 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]
File "/tmp/tmpxacbrij_/tmpwfm8hln9.py", line 38 if G[j] != -1: ^ IndentationError: expected an indented block after 'for' statement on line 37
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: cost = INFTY for i in range(n): if color[i] != 2 and d[i] < cost: cost = d[i] u = i if cost == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]: d[v] = m[u][v] k[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += m[i][k[i]] print sum
File "/tmp/tmpknrkdh05/tmpzjp2afoe.py", line 13 if G[j] != -1: ^ IndentationError: expected an indented block after 'for' statement on line 12
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 while 1: cost = INFTY for i in range(n): if color[i] != 2 and d[i] < cost: cost = d[i] u = i if cost == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]: d[v] = m[u][v] k[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += m[i][k[i]] print sum
File "/tmp/tmpmha9yejd/tmp04ylmw6v.py", line 39 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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] = 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 == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]: d[v] = m[u][v] k[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += m[i][k[i]] print sum
File "/tmp/tmpz8jjos_g/tmpj3kky3bg.py", line 39 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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] = 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 == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]: d[v] = m[u][v] k[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += m[i][k[i]] print sum
File "/tmp/tmp4itbssaa/tmpf8y7iw3l.py", line 40 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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] = 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 == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]: d[v] = m[u][v] k[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += m[i][k[i]] print sum
File "/tmp/tmp594o0774/tmp4nncgad6.py", line 40 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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 while 1: cost = INFTY for i in range(n): if color[i] != 2 and d[i] < cost: cost = d[i] u = i if cost == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]: d[v] = m[u][v] k[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += m[i][k[i]] print sum
File "/tmp/tmpbo0jf3md/tmpltyw9vjq.py", line 40 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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 while 1: cost = INFTY for i in range(n): if color[i] != 2 and d[i] < cost: cost = d[i] u = i if cost == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]: d[v] = m[u][v] k[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += m[i][k[i]] print sum
File "/tmp/tmpsyh9isz4/tmpv3cw_2w_.py", line 40 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
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: cost = d[i] u = i if cost == INFTY: break color[u] = 2 for v in range(n): if color[v] != 2 and M[u][v] != INFTY and M[u][v] < d[v]: d[v] = M[u][v] p[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i] != -1: sum += M[i][p[i]] return sum 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] print MST()
File "/tmp/tmps9brwjh3/tmpfeaa8xth.py", line 20 if cost == INFTY: ^ IndentationError: unindent does not match any outer indentation level
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] = True sumcost = sumcost + mincost[v] for u in range(V): if cost[u][v] == -1: continue mincost[u] = min(mincost[u], cost[v][u]) return sumcost
File "/tmp/tmp3ahvlag6/tmpxly_wit4.py", line 10 if not used[u] and (v == -1 or mincost[u] < mincost[ju): ^ SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
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 range(n): if minv>d[i] and color[i]!=2 u = i minv = d[i] if u = -1: break color[u] = 2 for v in range(n): if color[v]!=2 and M[u][v]!=1000000000: if d[v]>M[u][v]: d[v] = M[u][v] p[v] = u color[v] = 1 sum = 0 for i in range(n): if p[i]!=-1: sum += M[i][p[1]] print sum
File "/tmp/tmp3t5byopu/tmp1pmi7zqz.py", line 9 d = [1000000000 for i range(n)] ^^^^^^^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma?
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().
File "/tmp/tmpj7isidgu/tmp5_7y15xe.py", line 6 a[i] = map( int,raw_input(). ^ SyntaxError: '(' was never closed
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.readline().split()]) g = set(xrange(1, num+1)) index = g.pop() h = {index} weight = 0 while g: minimum = maxint for j in h: mj = M[j-1] for i in g: if 0 <= mj[i-1] < minimum: index = i minimum = mj[i-1] h.add(index) g.remove(index) weight += minimum print(weight)
File "/tmp/tmp7c4t8_2c/tmp5le3xrn4.py", line 36 from __future__ import division, print_function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: from __future__ imports must occur at the beginning of the file
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.readline().split()]) g = set(xrange(1, num+1)) index = g.pop() h = {index} weight = 0 while g: minimum = maxint for j in h: mj = M[j-1] for i in g: if 0 <= mj[i-1] < minimum: index = i minimum = mj[i-1] h.add(index) g.remove(index) weight += minimum print(weight)
File "/tmp/tmp81dt2d2q/tmpb7gxm4o6.py", line 36 from __future__ import division, print_function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: from __future__ imports must occur at the beginning of the file
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(n) if minv > d[i] && color[i] != BLACK: u = i minv = d[i]
File "/tmp/tmpz8mlvtr_/tmp3ra4wizx.py", line 19 for i in range(n) ^ SyntaxError: expected ':'