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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s953178862 | p03722 | u600402037 | 1570979403 | Python | Python (3.4.3) | py | Runtime Error | 162 | 12664 | 1246 | # D - Score Attack
import sys
sys.setrecursionlimit(10 ** 9)
import numpy as np
from heapq import heappush, heappop
N, M, = map(int, input().split())
graph = [[] for _ in range(N+1)] # graph[0]は使わない
for _ in range(M):
a, b, c = map(int, input().split())
graph[a].append((b, -c)) # ヒープ構造を使うため重みはマイナスの値
def dij... |
s919707671 | p03722 | u600402037 | 1570979308 | Python | Python (3.4.3) | py | Runtime Error | 172 | 13048 | 1245 | # D - Score Attack
import sys
sys.setrecursionlimit(10 ** 9)
import numpy as np
from heapq import heappush, heappop
N, M, = map(int, input().split())
graph = [[] for _ in range(N+1)] # graph[0]は使わない
for _ in range(M):
a, b, c = map(int, input().split())
graph[a].append((b, -c)) # ヒープ構造を使うため重みはマイナスの値
def dij... |
s148360835 | p03722 | u600402037 | 1570978803 | Python | Python (3.4.3) | py | Runtime Error | 162 | 12792 | 1245 | # D - Score Attack
import sys
sys.setrecursionlimit(10 ** 9)
import numpy as np
from heapq import heappush, heappop
N, M, = map(int, input().split())
graph = [[] for _ in range(N+1)] # graph[0]は使わない
for _ in range(M):
a, b, c = map(int, input().split())
graph[a].append((b, -c)) # ヒープ構造を使うため重みはマイナスの値
def dij... |
s537097166 | p03722 | u600402037 | 1570978707 | Python | Python (3.4.3) | py | Runtime Error | 285 | 19080 | 1245 | # D - Score Attack
import sys
sys.setrecursionlimit(10 ** 9)
import numpy as np
from heapq import heappush, heappop
N, M, = map(int, input().split())
graph = [[] for _ in range(N+1)] # graph[0]は使わない
for _ in range(M):
a, b, c = map(int, input().split())
graph[a].append((b, -c)) # ヒープ構造を使うため重みはマイナスの値
def dij... |
s619228075 | p03722 | u540799318 | 1569610012 | Python | PyPy3 (2.4.0) | py | Runtime Error | 293 | 41968 | 1234 | import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def ... |
s629572180 | p03722 | u350248178 | 1568163615 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38384 | 537 | #ベルマンフォード法
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford
n,m=map(int,input().split())
edge=np.array([input().split() for _ in range(m)],dtype=np.int64).T
graph=csr_matrix(((-edge[2],edge[:2]-1)),(n,n))
while True:
try:
#False->無向グラフ True->有効グラフ
... |
s757501457 | p03722 | u626337957 | 1567900110 | Python | PyPy3 (2.4.0) | py | Runtime Error | 238 | 42480 | 417 | N, M = map(int, input().split())
INF = 10**12
edges = [tuple(map(int, input().split())) for _ in range(M)]
dp = [-INF] * (N+1)
cnt = 0
dp[1] = 0
while True:
update = False
for a, b, c in edges:
a, b, c = edges[i]
if dp[a] != -1 and dp[b] < dp[a] + c:
dp[b] = dp[a] + c
update = True
cnt += ... |
s859926461 | p03722 | u761529120 | 1567649525 | Python | PyPy3 (2.4.0) | py | Runtime Error | 323 | 47576 | 533 | def main():
N, M = map(int, input().split())
edges = []
for _ in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
edges.append([a,b,c])
d = [float('inf')] * N
d[0] = 0
for i in range(N-1):
for edge in edges:
d[edge[1]] = min(d... |
s877422299 | p03722 | u761529120 | 1567649328 | Python | Python (3.4.3) | py | Runtime Error | 726 | 11260 | 586 | def main():
N, M = map(int, input().split())
d = [[float('inf')] * N for _ in range(N)]
edges = []
for _ in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
edges.append([a,b,c])
d = [float('inf')] * N
d[0] = 0
for i in range(N-1):
fo... |
s341515392 | p03722 | u498620941 | 1567455490 | Python | Python (3.4.3) | py | Runtime Error | 609 | 3308 | 1122 | def solve():
global dp
while True:
flag = False
for i in range(M):
if dp[graph[i].f] + graph[i].cost > dp[graph[i].to] and dp[graph[i].f] != -float("inf"):
dp[graph[i].to] = dp[graph[i].f] + graph[i].cost
flag = True
if not flag :
b... |
s856208567 | p03722 | u498620941 | 1567369999 | Python | Python (3.4.3) | py | Runtime Error | 85 | 4232 | 724 | #入力
N, M = map(int,input().split())
graph = [[] for _ in range(N)]
for i in range(M):
a,b,c = map(int,input().split())
graph[a-1].append([b-1,c])
dp = [-10**9-1 for i in range(N)]
dp[0] = 0
visited = [False]*(N)
def search(now,visited):
if now==(N-1) and len(graph[now]) == 0 :
return
else :
... |
s574227238 | p03722 | u619819312 | 1566708195 | Python | Python (3.4.3) | py | Runtime Error | 434 | 3316 | 264 | n,m=map(int,input().split());a,b=[list(map(int,input().split()))for i in range(n)],[float("INF")]*(n+1);b[1]=0
for i in range(1,n+1):
for s,t,u in a:
if b[t]>b[s]-u:
b[t]=b[s]-u
if i==n and t==n:print("inf");exit()
print(-b[-1]) |
s302709997 | p03722 | u263830634 | 1565553909 | Python | Python (3.4.3) | py | Runtime Error | 835 | 3444 | 2073 | #単一始点最短経路問題
#負の辺があっても動作する
#最短経路を求める
#計算量O(N * M)
INF = 10 ** 15
#入力
N, M = map(int, input().split())
# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
G += [[l-1, r-1, -s]] #有向グラフのときはここだけ
#メイン文
d = [INF] * N #最短距離を記録しておくリスト
prev = [-1]... |
s256886051 | p03722 | u263830634 | 1565553817 | Python | Python (3.4.3) | py | Runtime Error | 863 | 3364 | 2078 | #単一始点最短経路問題
#負の辺があっても動作する
#最短経路を求める
#計算量O(N * M)
INF = 10 ** 15
#入力
N, M = map(int, input().split())
# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
G += [[l-1, r-1, -s]] #有向グラフのときはここだけ
#メイン文
d = [INF] * N #最短距離を記録しておくリスト
prev = [-1]... |
s652917832 | p03722 | u875291233 | 1565501938 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1117 | """
Bellman-Ford
始点と終点が決められているとき、
経由する閉路のみを確認する必要がある。
"""
def Bellman_Ford2(g,start,goal):
n = len(g)
dist = [float("inf")]*n
dist[start] = 0
a0 = float("inf")
for i in range(2*n):
updated = False
for v in range(n):
for to, cost in g[v]:
if dist[to] <=... |
s698496968 | p03722 | u502389123 | 1564929922 | Python | Python (3.4.3) | py | Runtime Error | 1973 | 742764 | 767 | import sys
sys.setrecursionlimit(10**7)
N, M = map(int, input().split())
link = [[] for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
link[a-1].append([b-1, c])
visited = [0] * N
ans = 0
#全ての頂点からループしてないか確かめるといけないかな?
def dfs(v, cnt):
global ans
if v == N-1:
if visited[v]... |
s779817598 | p03722 | u502389123 | 1564929884 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 768 | import sys
sys.setrecursionlimit(10**12)
N, M = map(int, input().split())
link = [[] for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
link[a-1].append([b-1, c])
visited = [0] * N
ans = 0
#全ての頂点からループしてないか確かめるといけないかな?
def dfs(v, cnt):
global ans
if v == N-1:
if visited[v... |
s815697895 | p03722 | u502389123 | 1564929741 | Python | Python (3.4.3) | py | Runtime Error | 1993 | 740852 | 767 | import sys
sys.setrecursionlimit(10**9)
N, M = map(int, input().split())
link = [[] for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
link[a-1].append([b-1, c])
visited = [0] * N
ans = 0
#全ての頂点からループしてないか確かめるといけないかな?
def dfs(v, cnt):
global ans
if v == N-1:
if visited[v]... |
s804213660 | p03722 | u502389123 | 1564929140 | Python | Python (3.4.3) | py | Runtime Error | 1905 | 3192 | 781 | N, M = map(int, input().split())
a = [0] * 1000
b = [0] * 1000
c = [0] * 1000
for i in range(M):
a[i], b[i], c[i] = map(int, input().split())
c[i] = -c[i]
INF = 10 ** 10
dist = [INF] * 1000
dist[0] = 0
for loop in range(N-1):
for i in range(M):
if dist[a[i]-1] == INF:
continue
... |
s710861105 | p03722 | u502389123 | 1564928757 | Python | Python (3.4.3) | py | Runtime Error | 1890 | 3188 | 766 | N, M = map(int, input().split())
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(M):
a[i], b[i], c[i] = map(int, input().split())
c[i] = -c[i]
INF = 10 ** 10
dist = [INF] * N
dist[0] = 0
for loop in range(N-1):
for i in range(M):
if dist[a[i]-1] == INF:
continue
if dist... |
s369874050 | p03722 | u626337957 | 1564925694 | Python | Python (3.4.3) | py | Runtime Error | 88 | 7980 | 521 | import sys
sys.setrecursionlimit(5000)
N, M = map(int, input().split())
graph = [[] for _ in range(N+1)]
for _ in range(M):
_from, _to, _cost = map(int, input().split())
graph[_from].append((_to, _cost))
ans = -2 * 10**12
def search(_from, _total):
_next = graph[_from]
global ans
if len(_next) != 0:
for ... |
s136543229 | p03722 | u502389123 | 1564879844 | Python | Python (3.4.3) | py | Runtime Error | 2007 | 740852 | 684 | import sys
sys.setrecursionlimit(10**9)
N, M = map(int, input().split())
link = [[] for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
link[a-1].append([b-1, c])
visited = [0] * N
ans = 0
def dfs(v, cnt):
global ans
if v == N-1:
if visited[v] == 0:
ans = cnt
... |
s443438384 | p03722 | u502389123 | 1564879686 | Python | Python (3.4.3) | py | Runtime Error | 1986 | 740852 | 684 | import sys
sys.setrecursionlimit(10**6)
N, M = map(int, input().split())
link = [[] for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
link[a-1].append([b-1, c])
visited = [0] * N
ans = 0
def dfs(v, cnt):
global ans
if v == N-1:
if visited[v] == 0:
ans = cnt
... |
s915885680 | p03722 | u391731808 | 1564195460 | Python | Python (3.4.3) | py | Runtime Error | 812 | 4452 | 1401 | def connect_dfs(N,E,start):
connect = {start}
q = [start]
while q:
i = q.pop()
for j in E[i]:
if j in connect:continue
connect.add(j)
q.append(j)
return connect
def remove_Edge(N,Ef,Eb,start,goal):
v = connect_dfs(N,Ef,start) & connect_dfs(N,Eb,go... |
s966930631 | p03722 | u070187104 | 1562875417 | Python | PyPy3 (2.4.0) | py | Runtime Error | 341 | 46184 | 667 | def main():
[N, M] = [int(i) for i in input().split()]
E = []
for i in range(M):
E.append([int(i) for i in input().split()])
dist = [-1*10**100 for i in range(N)]
dist[0] = 0
for i in range(N):
for [a, b, c] in E:
newLen = dist[a-1] + c
if newLen > dis... |
s772523439 | p03722 | u070187104 | 1562875372 | Python | PyPy3 (2.4.0) | py | Runtime Error | 366 | 46184 | 665 | def main():
[N, M] = [int(i) for i in input().split()]
E = []
for i in range(M):
E.append([int(i) for i in input().split()])
dist = [-1*10**100 for i in range(N)]
dist[0] = 0
for i in range(N):
for [a, b, c] in E:
newLen = dist[a-1] + c
if newLen > dis... |
s103245164 | p03722 | u685263709 | 1562874758 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3312 | 2043 | class BellmanFord():
def __init__(self, N):
self.N = N
self.edges = []
def add(self, u, v, d, directed=False):
"""
u = from, v = to, d = cost
directed = Trueのとき、有向グラフである。
"""
if directed is False:
self.edges.append([u, v, d])
self.... |
s417827189 | p03722 | u685263709 | 1562874695 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3312 | 2044 | class BellmanFord():
def __init__(self, N):
self.N = N
self.edges = []
def add(self, u, v, d, directed=False):
"""
u = from, v = to, d = cost
directed = Trueのとき、有向グラフである。
"""
if directed is False:
self.edges.append([u, v, d])
self.... |
s499530835 | p03722 | u875291233 | 1562874676 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3316 | 930 | # coding: utf-8
# Your code here!
def Bellman_Ford(g,start):
n = len(g)
dist = [float("inf")]*n
dist[start] = 0
a0 = float("inf")
for i in range(2):
updated = False
for v in range(n):
for to, cost in g[v]:
if dist[to] <= dist[v] + cost: continue
... |
s893947106 | p03722 | u394271841 | 1562872756 | Python | Python (3.4.3) | py | Runtime Error | 409 | 5216 | 1908 | #!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile
def read(
*shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
def read_word():
w = lambda c: c in whitespaces
nw = lambda c: c not in whitespaces
return ... |
s459254561 | p03722 | u900045983 | 1562812049 | Python | Python (3.4.3) | py | Runtime Error | 224 | 13300 | 1361 | import numpy as np
import copy
def dfs(adj_list, cur_node, visited_nodes):
visited_nodes.append(cur_node)
# next_nodes = np.argwhere(adj_mat[cur_node] != 0).flatten()
next_nodes = adj_list[cur_node]
if len(next_nodes) == 0:
# N
visited_nodes.remove(cur_node)
return 0
for... |
s534576086 | p03722 | u900045983 | 1562811726 | Python | Python (3.4.3) | py | Runtime Error | 219 | 15460 | 1024 | import numpy as np
import copy
def dfs(adj_list, cur_node, visited_nodes):
visited_nodes.append(cur_node)
# next_nodes = np.argwhere(adj_mat[cur_node] != 0).flatten()
next_nodes = adj_list[cur_node]
for tup in next_nodes:
if tup[0] in visited_nodes:
return np.inf
if len(next_... |
s993199860 | p03722 | u900045983 | 1562811357 | Python | Python (3.4.3) | py | Runtime Error | 155 | 12468 | 1026 | import numpy as np
import copy
def dfs(adj_list, cur_node, visited_nodes):
visited_nodes.append(cur_node)
# next_nodes = np.argwhere(adj_mat[cur_node] != 0).flatten()
next_nodes = adj_list[cur_node]
if np.isin([tup[0] for tup in next_nodes], visited_nodes).any():
return np.inf
if len(nex... |
s266130099 | p03722 | u900045983 | 1562811121 | Python | Python (3.4.3) | py | Runtime Error | 158 | 16380 | 929 | import numpy as np
import copy
def dfs(adj_mat, cur_node, visited_nodes):
visited_nodes.append(cur_node)
next_nodes = np.argwhere(adj_mat[cur_node] != 0).flatten()
if np.isin(next_nodes, visited_nodes).any():
return np.inf
if len(next_nodes) == 0:
# N
return 0
score_max... |
s446699715 | p03722 | u731028462 | 1562356757 | Python | PyPy3 (2.4.0) | py | Runtime Error | 257 | 44784 | 2628 | class BellmanFord():
""" ベルマンフォード法
重み付き有向グラフにおける単一始点最短路アルゴリズム
* 使用条件
- DAG(有向グラフで閉路を持たない)であること
- 負のコストがあってもOK
* 負の閉路がある場合、最短路は求まらないが、負の閉路の検出はできる
* 計算量はO(V*E)
"""
class Edge():
""" 重み付き有向辺 """
def __init__(self, _from, _to, _cost):
se... |
s169324005 | p03722 | u731028462 | 1562356541 | Python | Python (3.4.3) | py | Runtime Error | 701 | 3572 | 2628 | class BellmanFord():
""" ベルマンフォード法
重み付き有向グラフにおける単一始点最短路アルゴリズム
* 使用条件
- DAG(有向グラフで閉路を持たない)であること
- 負のコストがあってもOK
* 負の閉路がある場合、最短路は求まらないが、負の閉路の検出はできる
* 計算量はO(V*E)
"""
class Edge():
""" 重み付き有向辺 """
def __init__(self, _from, _to, _cost):
se... |
s698122519 | p03722 | u731028462 | 1562186641 | Python | Python (3.4.3) | py | Runtime Error | 699 | 3572 | 2610 | class BellmanFord():
""" ベルマンフォード法
重み付き有向グラフにおける単一始点最短路アルゴリズム
* 使用条件
- DAG(有向グラフで閉路を持たない)であること
- 負のコストがあってもOK
* 負の閉路がある場合、最短路は求まらないが、負の閉路の検出はできる
* 計算量はO(V*E)
"""
class Edge():
""" 重み付き有向辺 """
def __init__(self, _from, _to, _cost):
se... |
s732605439 | p03722 | u271469978 | 1562041328 | Python | Python (3.4.3) | py | Runtime Error | 2054 | 739956 | 835 | import sys
sys.setrecursionlimit(10 ** 9)
N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]
INF = 10 ** 13
G = [[] for _ in range(N + 1)]
for a, b, c in egdes:
G[a].append((b, c))
# ループをチェックしてコストが正ならinf
def check_loop(a, b, d):
if a == b:
return d > 0
r... |
s150334396 | p03722 | u271469978 | 1562041089 | Python | Python (3.4.3) | py | Runtime Error | 295 | 96440 | 834 | import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]
INF = 10 ** 13
G = [[] for _ in range(N + 1)]
for a, b, c in egdes:
G[a].append((b, c))
# ループをチェックしてコストが正ならinf
def check_loop(a, b, d):
if a == b:
return d > 0
re... |
s281410625 | p03722 | u271469978 | 1562040553 | Python | Python (3.4.3) | py | Runtime Error | 300 | 96436 | 833 | import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]
INF = 10 ** 13
G = [[] for _ in range(N + 1)]
for a, b, c in egdes:
G[a].append((b, c))
# ループをチェックしてコストが正ならinf
def check_loop(a, b, d):
if a == b:
return d > 0
re... |
s701468345 | p03722 | u644778646 | 1561941881 | Python | PyPy3 (2.4.0) | py | Runtime Error | 655 | 48216 | 710 | def BellmanFord(edges,num_v,source):
dist=[float("inf") for i in range(num_v)]
dist[source]=0
for i in range(num_v):
for edge in edges:
if edge[0] != float("inf") and dist[edge[1]] > dist[edge[0]] + edge[2]:
dist[edge[1]] = dist[edge[0]] + edge[2]
if i==num_v-1: return -1
return ... |
s654324536 | p03722 | u057109575 | 1561928091 | Python | PyPy3 (2.4.0) | py | Runtime Error | 369 | 49128 | 623 | N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
def bellman_ford():
d = [None] * (N + 1)
visited = [False] * (N + 1)
d[1] = 0
visited[1] = True
updated = True
cnt = 0
while updated and (cnt < N):
updated = False
cnt += 1
... |
s029905747 | p03722 | u163320134 | 1561491432 | Python | PyPy3 (2.4.0) | py | Runtime Error | 185 | 38384 | 270 | from scipy.sparse.csgraph import bellman_ford
n,m=map(int,input().split())
g=[[float('inf')]*(n+1) for _ in range(n+1)]
for _ in range(m):
a,b,c=map(int,input().split())
g[a][b]=-c
try:
score=int(bellman_ford(g)[1][n])
except:
print('inf')
else:
print(-score) |
s289006076 | p03722 | u497046426 | 1561338225 | Python | Python (3.4.3) | py | Runtime Error | 29 | 3828 | 1267 | from collections import defaultdict
def bellman_ford(V, E, s):
'''
Input:
V = list(range(N))
E = {i: defaultdict(int) for i in range(N)}
s (in V) : start vertex
Output:
dist: the list of the minimum cost from s to arbitrary vertex v in the given graph
'''
INF = float... |
s167921662 | p03722 | u389910364 | 1561078892 | Python | Python (3.4.3) | py | Runtime Error | 1754 | 634752 | 850 | import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "... |
s040674291 | p03722 | u191829404 | 1560522215 | Python | PyPy3 (2.4.0) | py | Runtime Error | 309 | 47464 | 1833 | import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq)... |
s550958892 | p03722 | u796060588 | 1560400857 | Python | Python (3.4.3) | py | Runtime Error | 484 | 4596 | 1329 | #!/usr/bin/python3
# vim: set fileencoding=utf-8:
import collections
stack = collections.deque()
N, M = [int(ele) for ele in input().split()]
edges = []
adj_list = []
for _ in range(N+1):
adj_list.append([])
d = [-1000000000000000000000000000000000000000000000000000000] * (N+1)
for _ in range(M):
src, dst, w... |
s801725112 | p03722 | u788137651 | 1559971312 | Python | PyPy3 (2.4.0) | py | Runtime Error | 190 | 39664 | 2402 | #
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
inf=float('inf')
mod = 10**9+7
def INT_... |
s242389489 | p03722 | u788137651 | 1559967047 | Python | PyPy3 (2.4.0) | py | Runtime Error | 352 | 43612 | 2140 | #
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
inf=float('inf')
mod = 10**9+7
def INT_... |
s219623030 | p03722 | u923712635 | 1559876536 | Python | Python (3.4.3) | py | Runtime Error | 524 | 3188 | 618 | def BellmanFord(edges,num_v,source):
#グラフの初期化
inf=float("inf")
dist=[inf for i in range(num_v)]
dist[source-1]=0
#辺の緩和
for i in range(num_v):
for edge in edges:
if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
if i==n... |
s213204091 | p03722 | u785989355 | 1559465906 | Python | Python (3.4.3) | py | Runtime Error | 496 | 3188 | 635 | N,M=list(map(int,input().split()))
e_list = []
for i in range(N):
a,b,c = list(map(int,input().split()))
e_list.append([a-1,b-1,-c])
vi=0
min_dis_list = [10**27 for i in range(N)]
min_dis_list[vi] = 0
prev_list = [-1 for i in range(N)]
for i in range(N-1):
for e in e_list:
u,v,d = e
if mi... |
s534719644 | p03722 | u380772254 | 1559411790 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 2556 | # ABC 061 D
# 有向グラフ各辺のコストを集めて最大化する問題だが、全部符号を変えれば最短経路問題にできる
from typing import List
from math import isinf
class Edge(object):
def __init__(self, src: int, dst: int, cost: int):
self.src = src
self.dst = dst
self.cost = cost
class BellmanFord(object):
def __init__(self, v_len: int,... |
s342424083 | p03722 | u037430802 | 1558843931 | Python | Python (3.4.3) | py | Runtime Error | 1918 | 740868 | 865 | import sys
sys.setrecursionlimit(10**9)
n,m = map(int, (input().split()))
checked= {}
graph = {}
for i in range(m):
a,b,c = map(int, input().split())
if a in graph:
graph[a].append((b,c))
else:
graph[a] = []
graph[a].append((b,c))
ans = -1*float("inf")
def solve(node, current_s... |
s657328748 | p03722 | u037430802 | 1558843853 | Python | Python (3.4.3) | py | Runtime Error | 87 | 4372 | 823 | n,m = map(int, (input().split()))
checked= {}
graph = {}
for i in range(m):
a,b,c = map(int, input().split())
if a in graph:
graph[a].append((b,c))
else:
graph[a] = []
graph[a].append((b,c))
ans = -1*float("inf")
def solve(node, current_score):
global ans
if node == n:
... |
s157060249 | p03722 | u798129018 | 1558730195 | Python | PyPy3 (2.4.0) | py | Runtime Error | 237 | 42352 | 549 | n,m = map(int,input().split())
edge=[]
for i in range(m):
a, b, c = map(int, input().split())
edge.append([a,b,-c])
def BellmanFord(edges,num_v,source):
#グラフの初期化
dist=[inf for i in range(num_v)]
dist[source-1]=0
#辺の緩和
for i in range(num_v):
for e in edges:
if e[0] != inf and dist[e[1]-1] > ... |
s097462682 | p03722 | u912862653 | 1558453504 | Python | Python (3.4.3) | py | Runtime Error | 1924 | 3188 | 635 | N, M = map(int, input().split())
a = [0]*M
b = [0]*M
c = [0]*M
for i in range(M):
x, y, z = map(int, input().split())
a[i] = x
b[i] = y
c[i] = -z
INF = float('inf')
d = [INF]*N
d[0] = 0
for _ in range(N-1):
for i in range(M):
if d[a[i]-1]==INF:
continue
if d[b[i]-1]>d[a[i]-1]+c[i]:
d[b[i]-1] = d[a[i]-1... |
s886227616 | p03722 | u649373416 | 1557805967 | Python | PyPy3 (2.4.0) | py | Runtime Error | 418 | 48856 | 679 | N,M = [ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(M) ]
li = [ (a-1,b-1,c) for a,b,c in li ]
dw = [ [] for i in range(N) ]
for a,b,c in li:
dw[a].append( (b,c) )
NOT = 1e+10 -1
cost = [NOT]*N
cost[0]=0
cosli = []
for i in range(1000):
chk = [0]*N
now = ... |
s095422849 | p03722 | u794173881 | 1557727452 | Python | Python (3.4.3) | py | Runtime Error | 29 | 3944 | 1006 | from collections import deque
n, m = map(int, input().split())
tree = [[] for i in range(n)]
path = {}
for i in range(m):
tmp1, tmp2, cost = map(int, input().split())
tree[tmp1-1].append([tmp2-1, cost])
q = deque()
q.append([-1, 0])
pos_cost = [-10**10]*n
pos_cost[0] = 0
path = {}
def judge(start):
q2 =... |
s906705525 | p03722 | u487523716 | 1557627297 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1643 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 3
debug = True
debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 ... |
s451554122 | p03722 | u487523716 | 1557627059 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1643 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 3
debug = True
debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 ... |
s312904954 | p03722 | u487523716 | 1557612376 | Python | Python (3.4.3) | py | Runtime Error | 30 | 3692 | 2059 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 2
debug = True
debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 ... |
s847209886 | p03722 | u487523716 | 1557612254 | Python | Python (3.4.3) | py | Runtime Error | 30 | 3700 | 2045 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 2
debug = True
debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 ... |
s575856879 | p03722 | u487523716 | 1557610019 | Python | Python (3.4.3) | py | Runtime Error | 30 | 3700 | 2045 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 1
debug = True
debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 ... |
s008037910 | p03722 | u487523716 | 1557609910 | Python | Python (3.4.3) | py | Runtime Error | 30 | 3700 | 2045 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 2
debug = True
debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 ... |
s392899260 | p03722 | u487523716 | 1557609208 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3192 | 1997 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 2
debug = True
#debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5... |
s785257285 | p03722 | u487523716 | 1557606857 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3700 | 1691 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
import sys
# coding: utf-8
# Your code here!
#input_template
inpPh = 2
debug = True
debug = False
if not debug:
inpPh = 0
inploc = inpPh - 1 #0,1,2
inpX_lst = []
if debug and inpPh > 0:
inpX_lst = inputXs[inploc].splitlines()
if inpPh == 0:
... |
s406114014 | p03722 | u487523716 | 1557606218 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3192 | 1888 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 2
debug = True
debug = False
if not debug:
inpPh = 0
inputXs = [input1, input2, input3, None]
if debug:
try:
inputXs.append(inputA0)
except:
pass
else:
pass
... |
s621498098 | p03722 | u487523716 | 1557605920 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3192 | 2071 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 2
debug = True
debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 ... |
s294732594 | p03722 | u487523716 | 1557605165 | Python | Python (3.4.3) | py | Runtime Error | 30 | 3768 | 2045 | #https://atcoder.jp/contests/abc061/tasks/abc061_d
# coding: utf-8
# Your code here!
#input_template
inpPh = 2
debug = True
debug = False
if not debug:
inpPh = 0
input1 ='''
3 3
1 2 4
2 3 3
1 3 5
'''[1:]
input2 ='''
2 2
1 2 1
2 1 1
'''[1:]
input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 ... |
s026194127 | p03722 | u909643606 | 1557502633 | Python | Python (3.4.3) | py | Runtime Error | 247 | 17284 | 653 | #import sys
#import numpy as np
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra, bellman_ford
#sys.setrecursionlimit(10000)
N, M = [int(i) for i in input().split()]
rows = []
cols = []
weights = []
for _ in range(M):
# u v 間のコスト
u, v, a = [int(i) for i in input().sp... |
s081710339 | p03722 | u367130284 | 1555618194 | Python | Python (3.4.3) | py | Runtime Error | 1108 | 4076 | 1240 | from collections import *
d=defaultdict(list)
n,m=map(int,input().split())
for s in range(m):
a,b,c=map(int,input().split())
d[a].append([b,c])
#print(d)
def BELLMANFORD(point,d):
cost = {node:-float("inf")for node in range(1,n+1)}
preference = {node:None for node in range(1,n+1)} ... |
s541639519 | p03722 | u052499405 | 1555434826 | Python | Python (3.4.3) | py | Runtime Error | 1976 | 749044 | 641 | import sys
sys.setrecursionlimit(10**6)
n, m = [int(item) for item in input().split()]
edge = [[] for _ in range(n+1)]
INF = 2000 * 10**10
for i in range(m):
a, b, c = [int(item) for item in input().split()]
edge[a-1].append([b-1,c])
edge[n-1].append([n, 0])
def dfs(prev, prev_c, v):
if v == n:
r... |
s418580725 | p03722 | u052499405 | 1555434727 | Python | Python (3.4.3) | py | Runtime Error | 85 | 4364 | 599 | n, m = [int(item) for item in input().split()]
edge = [[] for _ in range(n+1)]
INF = 2000 * 10**9
for i in range(m):
a, b, c = [int(item) for item in input().split()]
edge[a-1].append([b-1,c])
edge[n-1].append([n, 0])
def dfs(prev, prev_c, v):
if v == n:
return 0
max_cost = -INF
for e in e... |
s746675911 | p03722 | u603745966 | 1555299692 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3572 | 2276 | from functools import reduce
import math
def main():
# 文字列の2進数を数値にする
# '101' → '5'
# 文字列の頭に'0b'をつけてint()にわたす
# binary = int('0b'+'101',0)
# 2進数で立っているbitを数える
# 101(0x5) → 2
# cnt_bit = bin(5).count('1')
# N! を求める
# f = math.factorial(N)
# 切り捨て
# 4 // 3
# 切り上げ
... |
s039237911 | p03722 | u603745966 | 1555299195 | Python | Python (3.4.3) | py | Runtime Error | 669 | 3812 | 2249 | from functools import reduce
import math
def main():
# 文字列の2進数を数値にする
# '101' → '5'
# 文字列の頭に'0b'をつけてint()にわたす
# binary = int('0b'+'101',0)
# 2進数で立っているbitを数える
# 101(0x5) → 2
# cnt_bit = bin(5).count('1')
# N! を求める
# f = math.factorial(N)
# 切り捨て
# 4 // 3
# 切り上げ
... |
s925660792 | p03722 | u342051078 | 1555040911 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1475 | #include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#def... |
s994955033 | p03722 | u310678820 | 1554583713 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 435 | inf=float('inf')
n, m=map(int, input().split())
abc=[list(map(int, input().split())) for i in range(m)]
abc=[[ai[0]-1, ai[1]-1, -ai[2]] for ai in abc]
d=[inf]*n
d[0]=0
for i in range(n):
flag=False
for abci in abc:
if d[abci[1]]>d[abci[0]]+abci[2]:
flag=True
d[abci[1]]=d[abci[0]]... |
s306882212 | p03722 | u983918956 | 1553924753 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 821 | inf = float('inf')
# distの初期化: dist = [inf for _ in range(N)]; dist[start] = 0
# True - >正常に更新, False -> 負閉路有り
def bellmanford(dist,edges,N):
for i in range(N):
for v ,nv, w in edges:
if dist[nv] > dist[v] + w:
dist[nv] = dist[v] + w
# 頂点数Nなら更新は高々N-1回で済む
... |
s439602552 | p03722 | u533885955 | 1553385934 | Python | Python (3.4.3) | py | Runtime Error | 940 | 3440 | 794 | #D問題
N,M=map(int,input().split())
ABC=[]
for i in range(M):
a,b,c=map(int,input().split())
ABC.append([a,b,-c])
negative=[]
#Bellman-Ford法(最短距離)
def BellmanFord(edges,num_v,source):
#グラフの初期化
inf=float("inf")
dist=[inf for i in range(num_v)]
dist[source-1]=0
#負閉路の検出
global negative
ne... |
s909587050 | p03722 | u171366497 | 1553176599 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 25944 | 576 | N,M=map(int,input().split())
big=10**13
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
a,b,c=map(int,input().split())
branch[a]|={(b,c),}
def dps(now,score,visited,ans):
if now==N:
ans=max(score,ans)
for b,c in branch[now]:
if ans>big:return ans
if... |
s317599340 | p03722 | u171366497 | 1553176179 | Python | Python (3.4.3) | py | Runtime Error | 121 | 25944 | 550 | N,M=map(int,input().split())
big=10**13
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
a,b,c=map(int,input().split())
branch[a]|={(b,c),}
def dps(now,score,visited,ans):
if now==N:
ans=max(score,ans)
if len(branch[now])==0:
return ans
for b,c in branch... |
s939797266 | p03722 | u171366497 | 1553176049 | Python | Python (3.4.3) | py | Runtime Error | 114 | 25944 | 513 | N,M=map(int,input().split())
big=10**13
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
a,b,c=map(int,input().split())
branch[a]|={(b,c),}
def dps(now,score,visited,ans):
if now==N:
ans=max(score,ans)
if len(branch[now])==0:
return ans
for b,c in branch... |
s705701576 | p03722 | u171366497 | 1553175924 | Python | Python (3.4.3) | py | Runtime Error | 118 | 27980 | 466 | N,M=map(int,input().split())
big=10**13
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
a,b,c=map(int,input().split())
branch[a]|={(b,c),}
def dps(now,score,visited,ans):
if now==N:
ans=max(score,ans)
for b,c in branch[now]:
if ans>big:return ans
if... |
s113021000 | p03722 | u171366497 | 1553175659 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 25940 | 418 | N,M=map(int,input().split())
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
a,b,c=map(int,input().split())
branch[a]|={(b,c),}
def dps(now,score,visited,ans):
if now==N:
ans=max(score,ans)
for b,c in branch[now]:
if b in visited:
return 'inf'
... |
s404744885 | p03722 | u190406011 | 1553143892 | Python | Python (3.4.3) | py | Runtime Error | 717 | 12272 | 782 | N, M = [int(i) for i in input().split()]
G = [[None for j in range(N)] for i in range(N)]
G_ls = []
d = [None for i in range(N)]
for i in range(M):
a, b, c = [int(i) for i in input().split()]
a -= 1
b -= 1
G[a][b] = c
G_ls.append([a,b,c])
def update(x, y, is_updated):
if x < y:
is_updat... |
s814859698 | p03722 | u190406011 | 1553143812 | Python | Python (3.4.3) | py | Runtime Error | 694 | 12276 | 736 | N, M = [int(i) for i in input().split()]
G = [[None for j in range(N)] for i in range(N)]
G_ls = []
d = [None for i in range(N)]
for i in range(M):
a, b, c = [int(i) for i in input().split()]
a -= 1
b -= 1
G[a][b] = c
G_ls.append([a,b,c])
def update(x, y, is_updated):
if x < y:
is_updat... |
s295218645 | p03722 | u190406011 | 1553143109 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 11892 | 863 | N, M = [int(i) for i in input().split()]
G = [[None for j in range(N)] for i in range(N)]
d = [None for i in range(N)]
for i in range(M):
a, b, c = [int(i) for i in input().split()]
a -= 1
b -= 1
G[a][b] = c
def update(x, y, is_updated):
if x < y:
is_updated = True
x = y
return ... |
s729774689 | p03722 | u190406011 | 1553142886 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 11892 | 860 | N, M = [int(i) for i in input().split()]
G = [[None for j in range(N)] for i in range(N)]
d = [None for i in range(N)]
for i in range(M):
a, b, c = [int(i) for i in input().split()]
a -= 1
b -= 1
G[a][b] = c
def update(x, y, is_updated):
if x < y:
is_updated = True
x = y
return ... |
s665565128 | p03722 | u923279197 | 1552837110 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38256 | 1348 | using ll = long long;
const ll INF = 1LL << 50;
#include <iostream>
using namespace std;
int main(){
int N, M;
cin >> N >> M ;
const int NMAX = 1000;
const int MMAX = 2000;
int a[MMAX], b[MMAX];
ll c[MMAX];
for (int i = 0; i < M ; ++i){
cin >> a[i] >> b[i] >> c[i];
c[i] = ... |
s641871123 | p03722 | u572144347 | 1551596952 | Python | Python (3.4.3) | py | Runtime Error | 849 | 4304 | 773 | import sys
input = sys.stdin.readline
N,M = map(int, input().split())
abc = [[int(j) for j in input().split()] for _ in range(M)]
con=[[] for _ in range (N+1)]
inf = float("inf")
allcost = [ -inf] * (N+1)
allcost[1] = 0
for i in range(M):
a,b,c = abc[i]
con[a].append(b)
for n in range(1, N):
for edge in... |
s965760907 | p03722 | u572144347 | 1551596787 | Python | Python (3.4.3) | py | Runtime Error | 838 | 4296 | 773 | import sys
input = sys.stdin.readline
N,M = map(int, input().split())
abc = [[int(j) for j in input().split()] for _ in range(M)]
con=[[] for _ in range (N+1)]
inf = float("inf")
allcost = [ -inf] * (N+1)
allcost[1] = 0
for i in range(M):
a,b,c = abc[i]
con[a].append(b)
for n in range(1, N):
for edge in... |
s943153926 | p03722 | u404676457 | 1550552029 | Python | Python (3.4.3) | py | Runtime Error | 2115 | 112632 | 799 | import sys
n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]
rs = {}
for i in abc:
if i[0] in rs:
rs[i[0]][i[1]] = [i[1], i[2]]
else:
rs[i[0]] = {i[1]: i[2]}
maxn = [float('inf') * -1] * (n + 1)
maxn[1] = 0
inf_point = [False] * (n + 1)
nextr = [[1, i... |
s631336647 | p03722 | u404676457 | 1550551987 | Python | Python (3.4.3) | py | Runtime Error | 2110 | 112500 | 803 | import sys
n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]
rs = {}
for i in abc:
if i[0] in rs:
rs[i[0]][i[1]] = [i[1], i[2]]
else:
rs[i[0]] = {i[1]: i[2]}
maxn = [float('inf') * -1] * (n + 1)
maxn[1] = 0
inf_point = [False] * (n + 1)
nextr = [[1, i... |
s823274999 | p03722 | u404676457 | 1550550298 | Python | Python (3.4.3) | py | Runtime Error | 40 | 3956 | 1116 | import sys
n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]
rs = {}
for i in abc:
if i[0] in rs:
rs[i[0]].append([i[1], i[2]])
else:
rs[i[0]] = [[i[1], i[2]]]
inf_point = [False] * (n + 1)
for _ in range(2):
nextr = [[1, i[0], {1}] for i in rs[1]]
... |
s464904212 | p03722 | u404676457 | 1550550111 | Python | Python (3.4.3) | py | Runtime Error | 32 | 3828 | 1116 | import sys
n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]
rs = {}
for i in abc:
if i[0] in rs:
rs[i[0]].append([i[1], i[2]])
else:
rs[i[0]] = [[i[1], i[2]]]
inf_point = [False] * (n + 1)
for _ in range(2):
nextr = [[1, i[0], {1}] for i in rs[1]]
... |
s249914115 | p03722 | u138486156 | 1549242451 | Python | Python (3.4.3) | py | Runtime Error | 201 | 15388 | 511 | from scipy.sparse.csgraph import bellman_ford
from scipy.sparse.csgraph import NegativeCycleError
from scipy.sparse import csr_matrix
n, m = map(int, input().split())
start = []
goal = []
score = []
for i in range(m):
a, b, c = map(int, input().split())
start.append(a-1)
goal.append(b-1)
score.append(-... |
s069489101 | p03722 | u375616706 | 1548100757 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 757 | import sys
def input(): return sys.stdin.redline().strip()
N, M = (list)(map(int, input().split()))
edge = []
for _ in range(M):
edge.append((list)(map(int, input().split())))
inf = 10**15
d = [inf]*(N+1)
d[1] = 0
ans = inf
for i in range(N):
update = False
for a, b, c in edge:
c = -c
... |
s582934906 | p03722 | u375616706 | 1548100483 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3572 | 696 | N, M = (list)(map(int, input().split()))
edge = []
for _ in range(M):
edge.append((list)(map(int, input().split())))
inf = 10**15
d = [inf]*(N+1)
d[1] = 0
ans = inf
for i in range(N):
update = False
for a, b, c in edge:
c = -c
new_d = d[a]+c
if d[a] != inf and d[b] > new_d:
... |
s539530836 | p03722 | u375616706 | 1548099624 | Python | Python (3.4.3) | py | Runtime Error | 580 | 3316 | 513 | N, M = (list)(map(int, input().split()))
edge = []
for _ in range(N):
edge.append((list)(map(int, input().split())))
inf = 10**15
d = [inf]*(N+2)
d[1] = 0
ans = inf
for i in range(N+1):
update = False
for a, b, c in edge:
c = -c
new_d = d[a]+c
if d[a] != inf and d[b] > new_d:
... |
s257513066 | p03722 | u796424048 | 1547170485 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3572 | 1489 | class BellmanFord:
def __init__(self, graph, num_v, start_point):
"""
graph : [[a1,b1,c1],[a2,b2,c2],‥]みたいな3次元配列のリスト,a1からb1までのコストはc1
num_v :頂点の数
start_point :スタート地点(a1)
"""
self.num_v = num_v
self.graph = graph
self.start_point = start_point
de... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.