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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s892339723 | p03608 | u280978334 | 1560050989 | Python | Python (3.4.3) | py | Runtime Error | 252 | 12648 | 753 | n,m,r = map(int,input().split())
R = tuple(map(int,input().split()))
ABC = [list(map(int,input().split())) for _ in range(m)]
inf = 1000000000
edge = [[inf]*(n+1) for _ in range(n+1)]
for a,b,c in ABC:
edge[a][b] = c
edge[b][a] = c
def dijkstra(start,e,N):
for v in range(1,N+1):#中間
for g in r... |
s301163544 | p03608 | u497596438 | 1559162228 | Python | PyPy3 (2.4.0) | py | Runtime Error | 313 | 45800 | 1043 | from itertools import permutations
N,M,R=map(int,input().split())
r=list(map(int,input().split()))
INF=float("inf")
G=[[INF]*N for i in range(N)]
for i in range(M):
A,B,C=map(int,input().split())
A,B=A-1,B-1
G[A][B]=C
G[B][A]=C
def distance(a,b):
stack=[(G[a][i],i) for i in range(N) if G[a][i]!=INF]... |
s432820116 | p03608 | u187205913 | 1558572086 | Python | PyPy3 (2.4.0) | py | Runtime Error | 703 | 51160 | 818 | n,m,r = map(int,input().split())
r = list(map(int,input().split()))
node = [list(map(int,input().split())) for _ in range(m)]
dic = {}
for i in range(1,n+1):
dic[i] = {}
for j in range(1,n+1):
dic[i][j]=10**6
for a,b,c in node:
dic[a][b] = c
dic[b][a] = c
dp = [[10**8]*(n+1) for _ in range(n+1)]... |
s608411202 | p03608 | u187205913 | 1558571367 | Python | PyPy3 (2.4.0) | py | Runtime Error | 705 | 50776 | 818 | n,m,r = map(int,input().split())
r = list(map(int,input().split()))
node = [list(map(int,input().split())) for _ in range(m)]
dic = {}
for i in range(1,n+1):
dic[i] = {}
for j in range(1,n+1):
dic[i][j]=10**6
for a,b,c in node:
dic[a][b] = c
dic[b][a] = c
dp = [[10**8]*(n+1) for _ in range(n+1)]... |
s330248532 | p03608 | u067729694 | 1558401167 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1227 |
edges = ABC[:]
def warshall_floyd(d, n):
# d: グラフ二次元リスト
# n: 頂点数 (0始まり)
#d[i][j]: iからjへの最短距離
for k in range(n):
for i in range(n):
for j in range(n):
d[i][j] = min(d[i][j],d[i][k] + d[k][j])
return d
# グラフ無効グラフ化
graph = [[float("inf") for i in range(N+1)]... |
s909260164 | p03608 | u067729694 | 1558313487 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 7800 | 1598 | N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
a,b,c = map(int, input().split())
ABC.append((a,b,c))
edges = ABC[:]
def warshall_floyd(d, n):
# d: グラフ二次元リスト
# n: 頂点数 (0始まり)
#d[i][j]: iからjへの最短距離
for k in range(n):
for i in range... |
s788607907 | p03608 | u067729694 | 1558309871 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 7784 | 1459 | N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
a,b,c = map(int, input().split())
ABC.append((a,b,c))
edges = ABC[:]
def warshall_floyd(d, n):
# d: グラフ二次元リスト
# n: 頂点数 (0始まり)
#d[i][j]: iからjへの最短距離
for k in range(n):
for i in range... |
s617865831 | p03608 | u067729694 | 1558309664 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 7784 | 1428 | N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
a,b,c = map(int, input().split())
ABC.append((a,b,c))
edges = ABC[:]
def warshall_floyd(d, n):
# d: グラフ二次元リスト
# n: 頂点数 (0始まり)
#d[i][j]: iからjへの最短距離
for k in range(n):
for i in ra... |
s548506004 | p03608 | u067729694 | 1558309580 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 7784 | 1372 | N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
a,b,c = map(int, input().split())
ABC.append((a,b,c))
edges = ABC[:]
def warshall_floyd(d, n):
# d: グラフ二次元リスト
# n: 頂点数 (0始まり)
#d[i][j]: iからjへの最短距離
for k in range(n):
for i in range... |
s276764398 | p03608 | u758799884 | 1556230581 | Python | Python (3.4.3) | py | Runtime Error | 271 | 8400 | 9174 | import math
import itertools
"""
The MIT License (MIT)
Copyright (c) 2017 Daniel Borowski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the ri... |
s900649608 | p03608 | u442581202 | 1554926658 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 1926 | #include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdlib>
#include <climits>
using namespace std;
int minDis[201][201];
int edge[201][201];
int mark[201];
int city[8];
bool cityMark[8];
int n,m;
int r;
int a,b,c;
int cnt;
/*
int dfs(int x)
{
int tmp;
if(x==r){
tmp = 0;
for
... |
s020366845 | p03608 | u310678820 | 1554588787 | Python | Python (3.4.3) | py | Runtime Error | 1418 | 13088 | 628 | from itertools import permutations
inf=10**9
n, m, r1 = map(int, input().split())
r=list(map(int, input().split()))
abc=[list(map(int, input().split())) for _ in range(m)]
d=[[inf]*n for i in range(n)]
for ai, bi, ci in abc:
d[ai-1][bi-1]=ci
d[bi-1][ai-1]=ci
for k in range(n):
for i in range(n-1):
... |
s496734050 | p03608 | u310678820 | 1554588675 | Python | Python (3.4.3) | py | Runtime Error | 1371 | 8236 | 618 | from itertools import permutations
inf=10**9
n, m, r1 = map(int, input().split())
r=list(map(int, input().split()))
abc=[list(map(int, input().split())) for _ in range(m)]
d=[[inf]*n for i in range(n)]
for ai, bi, ci in abc:
d[ai-1][bi-1]=ci
d[bi-1][ai-1]=ci
for k in range(n):
for i in range(n-1):
... |
s981954787 | p03608 | u310678820 | 1554588241 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 8196 | 578 | from itertools import permutations
inf=10**9
n, m, r1 = map(int, input().split())
r=list(map(int, input().split()))
abc=[list(map(int, input().split())) for _ in range(m)]
d=[[inf]*n for i in range(n)]
for ai, bi, ci in abc:
d[ai-1][bi-1]=ci
d[bi-1][ai-1]=ci
for k in range(n):
for i in range(n-1):
... |
s775137847 | p03608 | u310678820 | 1554588098 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 8136 | 600 | from itertools import permutations
inf=10**10
n, m, r1 = map(int, input().split())
r=list(map(int, input().split()))
abc=[list(map(int, input().split())) for _ in range(m)]
d=[[inf]*n for i in range(n)]
for i in range(n):
d[i][i]=0
for ai, bi, ci in abc:
d[ai-1][bi-1]=ci
d[bi-1][ai-1]=ci
for k in range(n):... |
s831147698 | p03608 | u310678820 | 1554588066 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 599 | from itertools import permutations
inf=10**10
n, m, r1 = map(int, input().split())
r=list(map(int, input().split()))
abc=[list(map(int, input().split())) for _ in range(m)]
d=[[inf]*n for i in range(n)]
for i in range(n):
d[i][i]=0
for ai, bi, ci in abc:
d[ai-1][bi-1]=ci
d[bi-1][ai-1]=ci
for k in range(n):... |
s168827324 | p03608 | u310678820 | 1554586500 | Python | Python (3.4.3) | py | Runtime Error | 82 | 7252 | 509 | from itertools import permutations
n, m, r = map(int, input().split())
r=list(map(int, input().split()))
abc=[list(map(int, input().split())) for _ in range(m)]
d=[[inf]*n for i in range(n)]
for i in range(n):
d[i][i]=0
for ai, bi, ci in abc:
d[ai-1][bi-1]=ci
d[bi-1][ai-1]=ci
for k in range(n):
for i i... |
s054453131 | p03608 | u619819312 | 1554047548 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 10032 | 606 | from itertools import permutations as pe
n,m,r=map(int,input().split())
s=[[(0 if i==j else float("inf"))for j in range(n+1)]for i in range(n+1)]
g=list(pe(list(map(int,input().split()))))
for i in range(n):
a,b,c=map(int,input().split())
s[a][b]=c
s[b][a]=c
for h in range(n):
for i in range(n):
... |
s342548169 | p03608 | u543954314 | 1553281090 | Python | Python (3.4.3) | py | Runtime Error | 1350 | 3588 | 552 | from itertools import permutations as per
n,m,r = map(int,input().split())
rlist = list(map(int,input().split()))
ans = 10**9
A = [[10**8]*n for _ in range(n)]
for _ in range(n):
a,b,c = map(int,input().split())
A[a-1][b-1] = c
A[b-1][a-1] = c
for i in range(n-1):
for j in range(i+1,n):
for k in range(n):... |
s849393995 | p03608 | u543954314 | 1553280931 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 551 | from itertools import permutation as per
n,m,r = map(int,input().split())
rlist = list(map(int,input().split()))
ans = 10**9
A = [[10**8]*n for _ in range(n)]
for _ in range(n):
a,b,c = map(int,input().split())
A[a-1][b-1] = c
A[b-1][a-1] = c
for i in range(n-1):
for j in range(i+1,n):
for k in range(n):
... |
s977201946 | p03608 | u393512980 | 1552545888 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 593 | N, M, R = map(int, input().split())
rs = permutations(map(lambda x: int(x) - 1, input().split()))
dist = [[10**9 for _ in range(N)] for _ in range(N)]
for _ in range(M):
v1, v2, d = map(int, input().split())
dist[v1-1][v2-1] = dist[v2-1][v1-1] = d
for i in range(N):
dist[i][i] = 0
for k in range(N):
for... |
s057859188 | p03608 | u099566485 | 1550950246 | Python | Python (3.4.3) | py | Runtime Error | 28 | 4340 | 612 | #074-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
from itertools import permutations
n,m,r=IL()
rl=IL()
cost=[[float("INF") for i in range(n)] for j in range(n)]
for i in range(m):
f,t,c=IL()
cost[f][t]=c
cost[t][f]=c... |
s691074436 | p03608 | u375616706 | 1548131741 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 4616 | 675 | from itertools import permutations
import sys
input = sys.stdin.readline
N, M, R = map(int, input().split())
dest = [x-1 for x in map(int, input().split())]
inf = float('inf')
mat = [[inf]*N for _ in range(N)]
for _ in range(M):
a, b, c = map(int, input().split())
mat[a-1][b-1] = mat[b-1][a-1] = c
def wa... |
s218653183 | p03608 | u375616706 | 1548128167 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 655 | from itertools import permutations
import sys
input = sys.stdin.readline
N, M, R = (list)(map(int, input().split()))
#dest = (list)(map(lambda x: (int)(x)-1, input().split()))
dest = [x-1 for x in input().split()]
inf = float('inf')
mat = [[inf]*N for _ in range(N)]
for _ in range(M):
a, b, c = (list)(map(in... |
s028395475 | p03608 | u064408584 | 1544073534 | Python | Python (3.4.3) | py | Runtime Error | 404 | 22616 | 426 | import scipy as sp
from itertools import permutations
n,m,r=map(int, input().split())
s=[[10**9]*n for i in range(n)]
t=list(map(int, input().split()))
for i in range(m):
a,b,c=map(int, input().split())
s[a-1][b-1]=c
s[b-1][a-1]=c
s=sp.sparse.csgraph.floyd_warshall(s)
ans=float('inf')
for i in permuta... |
s399940426 | p03608 | u657913472 | 1543669219 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2568 | 237 | import sys,itertools as o,scipy.sparse as s;_,r,*t=[map(int,i.split())for i in sys.stdin];a,b,c=zip(*t);l=s.csgraph.dijkstra(s.csr_matrix((c,(a,b)),[201]*2),0);print min(sum(int(l[i][j])for i,j in zip(a,a[1:]))for a in o.permutations(r)) |
s539413316 | p03608 | u200030766 | 1542600245 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 6000 | 905 | #dojkstra
import itertools
import queue
G=[]
#infの値に注意
inf=3*10**15
V, E, R=map(int,input().strip().split(' '))
rlis=list(map(int,input().strip().split(' ')))
cost=[[inf]*V for i in range(V)]
for i in range(E):
fr, to, co=map(int,input().strip().split(' '))
cost[fr-1][to-1]=co
cost[to-1][fr-1]=co
def dijks... |
s368930446 | p03608 | u200030766 | 1542598809 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 10184 | 1161 | #dojkstra (prioroty queue ver.)
import itertools
import queue
G=[]
#infの値に注意
inf=3*10**15
V, E, R=map(int,input().strip().split(' '))
rlis=list(map(int,input().strip().split(' ')))
for i in range(V):
G.append([])
for i in range(E):
at,bt,ct=map(int,input().strip().split(' '))
G[at-1].append([ct,bt-1])
... |
s865243694 | p03608 | u368780724 | 1540731397 | Python | Python (3.4.3) | py | Runtime Error | 508 | 5364 | 982 | def inpl(): return [int(i) for i in input().split()]
import heapq
from itertools import permutations
N, M, R = inpl()
r = inpl()
inf = 10**11
Q = [[inf] * N for _ in range(N)]
path = [[0] * N for _ in range(N)]
for i in range(M):
A,B,C = inpl()
path[A-1][B-1] = path[B-1][A-1] = C
for i in r:
decided = [F... |
s725473344 | p03608 | u658993896 | 1540673653 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 967 | import numpy as np
def search(now,r,dist,ans):
if len(r)==0:
return ans
min_=float('inf')
for i,x in enumerate(r):
if i < len(r)-1:
min_=min(min_,search(x,r[:i]+r[i+1:],dist,ans+dist[now][x]))
else:
min_=min(min_, search(x,r[:i],dist,ans+dist[now][x]))
re... |
s761995585 | p03608 | u658993896 | 1540673400 | Python | Python (3.4.3) | py | Runtime Error | 1662 | 14224 | 923 | import numpy as np
def search(now,r,dist,ans):
if len(r)==0:
return ans
min_=float('inf')
for i,x in enumerate(r):
if i < len(r)-1:
min_=min(min_,search(x,r[:i]+r[i+1:],dist,ans+dist[now][x]))
else:
min_=min(min_, search(x,r[:i],dist,ans+dist[now][x]))
re... |
s475656484 | p03608 | u658993896 | 1540673254 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 15364 | 951 | import numpy as np
def search(now,r,dist,ans):
print(r,ans)
if len(r)==0:
return ans
min_=float('inf')
for i,x in enumerate(r):
if i < len(r)-1:
min_=min(min_,search(x,r[:i]+r[i+1:],dist,ans+dist[now][x]))
else:
min_=min(min_, search(x,r[:i],dist,ans+dist... |
s805875081 | p03608 | u102126195 | 1539137521 | Python | Python (3.4.3) | py | Runtime Error | 80 | 7376 | 860 | def ABC073D():
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for i in range(M)]
#root = [[1000000000 for i in range(N)] for i in range(N)]
#for i, j, k in ABC:
# root[i - 1][j - 1] = k
# root[j - 1][i - 1] = k
import... |
s323619567 | p03608 | u102126195 | 1539137342 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 551 | import itertools
def kumiawase(list_name): # list_name(リスト)のすべての並び替えのタプル
return itertools.permutations(list_name, len(list_name))
for i in range(N):
for j in range(N):
for k in range(N):
root[i][j] = min(root[i][j], root[i][k] + root[k][j])
#a = kumiawase(r... |
s654066792 | p03608 | u826263061 | 1539002826 | Python | Python (3.4.3) | py | Runtime Error | 59 | 4084 | 1070 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 7 22:06:12 2018
ABC073D
@author: maezawa
"""
import itertools as itr
import sys
input = sys.stdin.readline
n, m, r = list(map(int, input().split()))
rarray = list(map(int, input().split()))
adjmatrix = [[10**10]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
adjma... |
s366346710 | p03608 | u826263061 | 1539002741 | Python | Python (3.4.3) | py | Runtime Error | 92 | 4084 | 1064 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 7 22:06:12 2018
ABC073D
@author: maezawa
"""
import itertools as itr
import sys
#input = sys.stdin.readline
n, m, r = list(map(int, input().split()))
rarray = list(map(int, input().split()))
adjmatrix = [[10**10]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
adjm... |
s213137550 | p03608 | u826263061 | 1539002007 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1055 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 7 22:06:12 2018
ABC073D
@author: maezawa
"""
import itertools as itr
import sys
#input = sys.stdin.readline
n, m, r = list(map(int, input().split()))
rarray = list(map(int, input().split()))
adjmatrix = [[10**10]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
adjm... |
s664369382 | p03608 | u232852711 | 1535941810 | Python | Python (3.4.3) | py | Runtime Error | 182 | 4084 | 616 | from itertools import permutations
INF = float('inf')
n, m, R = list(map(int, input().split()))
r = list(map(int, input().split()))
dist = [[INF]*(n+1) for _ in range(n+1)]
for i in range(1, n+1):
dist[i][i] = 0
for i in range(m):
a, b, c = map(int, input().split())
dist[a][b] = c
dist[b][a] = c
for k... |
s517410557 | p03608 | u232852711 | 1535941712 | Python | Python (3.4.3) | py | Runtime Error | 190 | 4084 | 611 | from itertools import permutations
INF = float('inf')
n, m, R = list(map(int, input().split()))
r = list(map(int, input().split()))
dist = [[INF]*(n+1) for _ in range(n+1)]
for i in range(1, n+1):
dist[i][i] = 0
for i in range(m):
a, b, c = map(int, input().split())
dist[a][b] = c
dist[b][a] = c
for k... |
s136491375 | p03608 | u828847847 | 1534357979 | Python | Python (2.7.6) | py | Runtime Error | 2104 | 3204 | 525 | from itertools import permutations
inf = float("inf")
n,m,r = map(int,raw_input().split())
arr = map(int,raw_input().split())
x = range(n)
d = [[inf for i in x] for j in x]
for i in range(n):
d[i][i] = 0
for i in x:
f,t,c = map(int,raw_input().split())
d[f-1][t-1] = c
d[t-1][f-1] = c
for i in x:
for j in x:
... |
s310371983 | p03608 | u846150137 | 1533041288 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 16544 | 352 | from scipy.sparse import*
from itertools import permutations as pm
n,m,h = map(int,input().split())
r = [int(i) for i in input().split()]
A = lil_matrix((n+1,n+1))
for i in range(m):
u,v,l = map(int,input().split())
A[u,v] = l
A=csgraph.shortest_path(A,method='D')
s=min(sum([A[i][j] for i,j in zip(a[:-1],a[1:])... |
s949239601 | p03608 | u585704797 | 1530658392 | Python | Python (3.4.3) | py | Runtime Error | 2179 | 1102832 | 666 | N,M,C=[int(x) for x in str(input()).split()]
r=[int(x) for x in str(input()).split()]
ABC=[[0 for i in range(4)]]
dis=[[100001 for i in range(N+1)]]
for i in range(N):
dis.append([100001 for i in range(N+1)])
for i in range(M):
x=[0]+[int(x) for x in str(input()).split()]
ABC.append(x)
dis[x[1]][x[2]]=x[3]
... |
s612517817 | p03608 | u585704797 | 1530658127 | Python | Python (3.4.3) | py | Runtime Error | 2176 | 1088368 | 666 | N,M,C=[int(x) for x in str(input()).split()]
r=[int(x) for x in str(input()).split()]
ABC=[[0 for i in range(4)]]
dis=[[100001 for i in range(N+1)]]
for i in range(N):
dis.append([100001 for i in range(N+1)])
for i in range(M):
x=[0]+[int(x) for x in str(input()).split()]
ABC.append(x)
dis[x[1]][x[2]]=x[3]
... |
s178737740 | p03608 | u503283842 | 1530656829 | Python | Python (3.4.3) | py | Runtime Error | 2197 | 1526004 | 1133 | def permutation(a, i):
if i==len(a):
tmp=0
check=[]
for k in range(len(a)-1):
boo=False
tmp+=dis[a[k]-1][a[k+1]-1]
check.append(int(a[k]))
check.append(int(a[k+1]))
check.sort()
global town
ind=0
... |
s709070682 | p03608 | u910341281 | 1529864287 | Python | Python (3.4.3) | py | Runtime Error | 1702 | 4664 | 1638 | import math
from itertools import permutations
#グラフの作成
def make_list(V,E):
edges = []
path=[[0]*E for i in range(V) ] #ルート作成に必要になる
for i in range(V):
a=[int(x) for x in str(input()).split()]
for j in range(len(a)):
#print("j",j)
path[i][j]=i
# i... |
s468689623 | p03608 | u910341281 | 1529863944 | Python | Python (3.4.3) | py | Runtime Error | 1700 | 4664 | 1644 | import math
from itertools import permutations
#グラフの作成
def make_list(V,E):
edges = []
path=[[0]*E for i in range(V) ] #ルート作成に必要になる
for i in range(V):
a=[int(x) for x in str(input()).split()]
for j in range(len(a)):
#print("j",j)
path[i][j]=i
# i... |
s961633176 | p03608 | u988832865 | 1527136382 | Python | Python (3.4.3) | py | Runtime Error | 1670 | 4620 | 802 | from itertools import permutations
def hoge():
N, M, R = map(int, input().split())
r = map(int, input().split())
r = [x - 1 for x in r]
inf = float('inf')
d = [[inf] * N for i in range(N)]
for i in range(N):
d[i][i] = 0
for i in range(M):
a, b, c = map(int, input().split())
d[a-1][b-1... |
s872064642 | p03608 | u276192130 | 1527082947 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 4456 | 674 | import itertools
N, M, R = map(int, input().split())
r = map(int, input().split())
inf = float('inf')
d = [[inf for j in range(N)] for i in range(N)]
for i in range(N):
d[i][i] = 0
for i in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
t = min(c, d[a][b])
if d[a][b] > c:
... |
s776429839 | p03608 | u276192130 | 1527082658 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 4456 | 633 | import itertools
N, M, R = map(int, input().split())
r = map(int, input().split())
inf = float('inf')
d = [[inf for j in range(N)] for i in range(N)]
for i in range(N):
d[i][i] = 0
for i in range(M):
a, b, c = map(int, input().split())
a -= 1
b -= 1
t = min(c, d[a][b])
if d[a][b] > c:
... |
s069590036 | p03608 | u480847874 | 1526330949 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 1424 | def someone_ans():
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
graph = [[MAX for _ in range(N+1)] for _ in range(N+1)]
for i in range(M):
a, b, c = map(int, input().split())
graph[a][b] = c
graph[b][a] = c
def dijkstra(d, index):
q = queue... |
s448306074 | p03608 | u480847874 | 1525836913 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3700 | 794 | import itertools
MAX = 999999999
def m():
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
graph = [[MAX for _ in range(N+1)] for _ in range(N+1)]
for i in range(N):
a, b, c = map(int, input().split())
graph[a][b] = c
graph[b][a] = c
def dfs(start, e... |
s653145237 | p03608 | u668726177 | 1520463901 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1014 | #!/usr/bin/env python
# ワーシャルフロイド+全探索
import numpy as np
import itertools
def main():
N, M, R = map(int, input().split())
rs = [int(a)-1 for a in input().split())]
inf = float('inf')
cost = [[inf]*N for _ in range(N)]
# グラフ作る
for i in range(N):
cost[i][i] = 0
for _ in range(M):
... |
s405656231 | p03608 | u813098295 | 1520284913 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2568 | 606 | from itertools import permutations
N, M, R = map(int, raw_input().split())
r = [i - 1 for i in map(int, raw_input().split())]
G = [[float('inf')] * N for _ in range(N)]
for i in range(N):
G[i][i] = 0
for i in range(M):
A, B, C = map(int, raw_input().split())
G[A-1][B-1] = G[B-1][A-1] = C
# Warshall–Fl... |
s150558986 | p03608 | u497285470 | 1506725938 | Python | Python (3.4.3) | py | Runtime Error | 2133 | 428600 | 726 | def permutations(L):
if L == []:
return [[]]
else:
return [[h]+t for i,h in enumerate(L)
for t in permutations(L[:i]+L[i+1:])]
inputs = input().split()
N = int(inputs[0])
M = int(inputs[1])
R = int(inputs[2])
inputs = input()
cities = [ x+1 for x in range(N)]
dist = [[... |
s115880006 | p03608 | u497285470 | 1506725396 | Python | Python (3.4.3) | py | Runtime Error | 2141 | 406720 | 756 | def permutations(L):
if L == []:
return [[]]
else:
return [[h]+t for i,h in enumerate(L)
for t in permutations(L[:i]+L[i+1:])]
inputs = input().split()
N = int(inputs[0])
M = int(inputs[1])
R = int(inputs[2])
cities = []
inputs = input().split()
for i in inputs:
ci... |
s762886053 | p03608 | u863370423 | 1506725307 | Python | Python (3.4.3) | py | Runtime Error | 2132 | 429108 | 756 | def permutations(L):
if L == []:
return [[]]
else:
return [[h]+t for i,h in enumerate(L)
for t in permutations(L[:i]+L[i+1:])]
inputs = input().split()
N = int(inputs[0])
M = int(inputs[1])
R = int(inputs[2])
cities = []
inputs = input().split()
for i in inputs:
ci... |
s297231717 | p03608 | u893209854 | 1505265331 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 618 | from itertools import permutations
import sys
N, M, R = map(int, sys.stdin.readline().split())
r = [int(i) - 1 for i in sys.stdin.readline().split()]
d = [[float('inf')] * N for j in range(N)]
for i in range(M):
A, B, C = map(int, sys.stdin.readline().split())
d[A-1][B-1] = min(d[A-1][B-1], C)
d[B-1][A-1] ... |
s329552664 | p03608 | u157461801 | 1505196792 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 892 | import math
def nextPermutation(order):
if len(order) == 1:
yield order
elif len(order) == 2:
yield order
yield [order[1],order[0]]
else:
for i in range(len(order)):
for _order in nextPermutation(order[:i]+order[(i+1):]):
yield [order[i]]+_order
def solution():
n,m,r = [int(x) for x in input().spli... |
s459372425 | p03608 | u410996052 | 1505192921 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 8900 | 787 | n,m,r = map(int,input().split())
r_l = [int(i)-1 for i in input().split()]
dist=dict()
for i in range(m):
a,b,c=map(int,input().split())
a-=1
b-=1
dist[(a,b)]=c
dist[(b,a)]=c
res=[]
for s in r_l:
F=[[s]]
while True:
c=0
i=F.pop(0)
now=i[-1]
for k in range(... |
s638174691 | p03608 | u791838908 | 1505189966 | Python | Python (3.4.3) | py | Runtime Error | 465 | 13740 | 617 | N, M, R = map(int, input().split())
r = list(map(lambda x: int(x) - 1, input().split()))
import numpy as np
array = np.full((N, N), np.inf)
for _ in range(M):
a, b, c = map(int, input().split())
array[a - 1, b - 1] = c
# this is destructive
def warshal_floyd(d, n, inf):
d[d == 0] = inf
for k in range(n)... |
s383299534 | p03608 | u791838908 | 1505189853 | Python | Python (3.4.3) | py | Runtime Error | 589 | 19712 | 617 | N, M, R = map(int, input().split())
r = list(map(lambda x: int(x) - 1, input().split()))
import numpy as np
array = np.full((N, N), np.inf)
for _ in range(M):
a, b, c = map(int, input().split())
array[a - 1, b - 1] = c
# this is destructive
def warshal_floyd(d, n, inf):
d[d == 0] = inf
for k in range(n)... |
s199968618 | p03608 | u791838908 | 1505189116 | Python | Python (3.4.3) | py | Runtime Error | 637 | 21788 | 579 | N, M, R = map(int, input().split())
r = list(map(lambda x: int(x) - 1, input().split()))
import numpy as np
array = np.full((N, N), np.inf)
for _ in range(M):
a, b, c = map(int, input().split())
array[a - 1, b - 1] = c
# this is destructive
def warshal_floyd(d, n, inf):
d[d == 0] = inf
for k in range(n)... |
s915313897 | p03608 | u817328209 | 1505119282 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 687 | from itertools import permutations
def input_list() :
return list(map(int, input().split()))
n, m ,r = input_list()
road = input_list()
road = [x-1 for x in road]
d = [[float('inf')] * n for i in range(n)]
for i in range(n) :
d[i][i] = 0
for i in range(m) :
a, b, c = input_list()
a -= 1
b -= 1
... |
s922962033 | p03608 | u817328209 | 1505119192 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 685 | from itertools import permutations
def input_list() :
return list(map(int, input().split()))
n, m ,r = input_list()
road = input_list()
road = [x-1 for x in road]
d = [[float('inf')] * n for i in range(n)]
for i in range(n) :
d[i][i] = 0
for i in range(m) :
a, b, c = input_list()
a -= 1
b -= 1
... |
s697582969 | p03608 | u010110540 | 1505101832 | Python | Python (3.4.3) | py | Runtime Error | 1611 | 4084 | 880 | import itertools
import sys
def readline():
return sys.stdin.readline()
def read_int_list():
return list(map(int, readline().split()))
def read_int():
return int(readline())
def main():
N, M, R = read_int_list()
r = [a-1 for a in read_int_list()]
d = [[float('inf')]*N for _ in range(... |
s912637547 | p03608 | u074201886 | 1505100761 | Python | Python (3.4.3) | py | Runtime Error | 83 | 3960 | 429 | n,m,r=map(int,input().split())
r=list(map(int,input().split()))
cost=[[999999999999 if i!=j else 0 for j in range(n)] for i in range(n)]
for _ in range(m):
a,b,c=map(int,input().split())
cost[a-1][b-1]=cost[b-1][a-1]=c
for k in range(n):
for i in range(n):
for j in range(n):
cost=min(co... |
s884659226 | p03608 | u825027400 | 1505090428 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 7144 | 914 | #coding:utf-8
from collections import defaultdict
import itertools
inf = 10 ** 9
N, M, R = map(int, input().split(" "))
r_list = map(int, input().split(" "))
cost = defaultdict(dict)
for i in range(1, N + 1):
for j in range(i, N + 1):
if i == j:
cost[i][j] = 0
else:
cost[... |
s866566572 | p03608 | u076936237 | 1505087907 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 10424 | 847 | import itertools
def main():
length = {}
v = set()
d = {}
N, M, R = list(map(int, input().split(' ')))
r = [int(a) for a in input().split()]
for _ in range(M):
a, b, c = list(map(int, input().split(' ')))
length[(a, b)] = c
length[(b, a)] = c
v.add(a)
... |
s063165456 | p03608 | u076936237 | 1505087635 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 8512 | 858 | import itertools
def main():
length = {}
v = set()
d = {}
N, M, R = list(map(int, input().split(' ')))
r = [int(a) for a in input().split()]
for _ in range(M):
a, b, c = list(map(int, input().split(' ')))
length[(a, b)] = c
length[(b, a)] = c
v.add(a)
... |
s828788420 | p03608 | u100621172 | 1505029780 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 591 | import itertools
import math
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
adj = [[math.inf]*(N+1) for _ in range(N+1)]
for _ in range(M):
A, B, C = map(int, input().split())
adj[A][B] = min(adj[A][B], C)
adj[B][A] = min(adj[B][A], C)
res = math.inf
for k in range(1, N+1):
... |
s930430053 | p03608 | u100621172 | 1505029696 | Python | PyPy3 (2.4.0) | py | Runtime Error | 187 | 38384 | 591 | import itertools
import math
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
adj = [[math.inf]*(N+1) for _ in range(N+1)]
for _ in range(M):
A, B, C = map(int, input().split())
adj[A][B] = min(adj[A][B], C)
adj[B][A] = min(adj[B][A], C)
res = math.inf
for k in range(1, N+1):
... |
s037716213 | p03608 | u280667879 | 1505026644 | Python | Python (2.7.6) | py | Runtime Error | 105 | 11640 | 275 | from scipy.sparse import*;f=lambda:list(map(int,input().split()));N,M,R=f();r=f();a,b,c=zip(*map(f,[0]*M));a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r);print(int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))) |
s658830236 | p03608 | u280667879 | 1505026615 | Python | Python (2.7.6) | py | Runtime Error | 195 | 16088 | 272 | from scipy.sparse import*;f=lambda:map(int,raw_input().split());N,M,R=f();r=f();a,b,c=zip(*map(f,[0]*M));a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r);print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R)))) |
s325723021 | p03608 | u010110540 | 1505017181 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3188 | 47 | 4 6 3
2 3 4
1 2 4
2 3 3
4 3 1
1 4 1
4 2 2
3 1 6 |
s097641671 | p03608 | u119714109 | 1505015843 | Python | Python (3.4.3) | py | Runtime Error | 195 | 4084 | 1395 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
n,m,r=na()
rs = na()
for i in range(r):
rs[i] -= 1
g = [[99999999999]*n for _ in range(n)]
for i in range(n):
g[i][i] = 0
for i in range(m):
a, b, c = na()
a -= 1
... |
s564166622 | p03608 | u280667879 | 1505015476 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 280 | from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());N,M,R=f();r=f();a,b,c=list(zip(*map(f,[0]*M)));a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r);print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R)))) |
s423626872 | p03608 | u280984565 | 1505015190 | Python | PyPy3 (2.4.0) | py | Runtime Error | 353 | 51160 | 1721 | from collections import Counter
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]
n, m, r = read_line(int, int, int)
rs = [int(r) for r in input().split()]
cities = Counter()
routes = {}
costs = {}
for _ in range(m):
a, b, c = read_line(int, int, int)
cities[a] = 1
cities[b]... |
s533357960 | p03608 | u463836923 | 1505014418 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 6980 | 1616 | #coding=UTF-8
def search(jun):
global ans
global R
global rrCost
tmpans=0
if len(jun)==R:
mae=jun[0]
for idx in range(1,R,1):
ba=jun[idx]
tmpans += rrCost[mae][ba]
mae=ba
if ans==None or tmpans<ans:
ans=tmpans
else:
... |
s053313201 | p03608 | u451017206 | 1505013914 | Python | Python (3.4.3) | py | Runtime Error | 2126 | 351036 | 611 | N,M,R = map(int,input().split())
r = list(map(int,input().split()))
from itertools import permutations
t = [[float('inf') for i in range(M)] for j in range(M)]
for i in range(M):
a,b,c = map(int, input().split())
t[a-1][b-1] = c
t[b-1][a-1] = c
for i in range(M):
for j in range(M):
for k in ra... |
s647822442 | p03608 | u451017206 | 1505013802 | Python | Python (3.4.3) | py | Runtime Error | 2127 | 355700 | 724 | N,M,R = map(int,input().split())
r = list(map(int,input().split()))
from itertools import permutations
t = [[float('inf') for i in range(M)] for j in range(M)]
g = {}
for i in range(M):
a,b,c = map(int, input().split())
t[a-1][b-1] = c
t[b-1][a-1] = c
v = g.get(a,[])
v.append((b,c))
g[a] = v
... |
s810676718 | p03608 | u157461801 | 1505011099 | Python | Python (3.4.3) | py | Runtime Error | 93 | 10820 | 882 | import math
def solution():
n,m,r = [int(x) for x in input().split(' ')]
v = input().split(' ')
w = []
graph = {}
for i in range(m):
a,b,c =input().split(' ')
c = int(c)
if a not in graph:
graph[a] = []
if b not in graph:
graph[b] = []
graph[a].append((b,c))
graph[b].append((a,c))
w.append((a,b... |
s453249085 | p03608 | u050708958 | 1505011057 | Python | Python (3.4.3) | py | Runtime Error | 2203 | 1636724 | 898 | import itertools
N, M, R = [int(i) for i in input().split()]
must_visit = [int(i) for i in input().split()]
max_city = max(must_visit)
cities = [i+1 for i in range(max_city)]
min_cost = 999999999
dic = {}
for _ in range(M):
dept, dest, dist = [int(i) for i in input().split()]
if dest < dept:
dest, dept = dept, de... |
s124979924 | p03608 | u280984565 | 1505010880 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 10024 | 1056 | from collections import Counter
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]
n, m, r = read_line(int, int, int)
rs = [int(r) for r in input().split()]
cities = Counter()
routes = {}
for _ in range(m):
a, b, c = read_line(int, int, int)
cities[a] = 1
cities[b] = 1
if... |
s883280690 | p03608 | u050708958 | 1505010809 | Python | Python (3.4.3) | py | Runtime Error | 2209 | 1634548 | 869 | import itertools
N, M, R = [int(i) for i in input().split()]
must_visit = [int(i) for i in input().split()]
max_city = max(must_visit)
cities = [i+1 for i in range(max_city)]
min_cost = 999999999
dic = {}
for _ in range(M):
dept, dest, dist = [int(i) for i in input().split()]
if dest < dept:
dest, dept = dept, de... |
s100826510 | p03608 | u010110540 | 1505010617 | Python | Python (3.4.3) | py | Runtime Error | 147 | 8644 | 1156 | from collections import defaultdict
from itertools import permutations
import heapq
INF = float('inf')
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
memo = [[INF for _ in range(N)] for _ in range(N)]
Adj_list = defaultdict(set)
for i in range(M):
a, b, c = map(int, input().split())
... |
s726922329 | p03608 | u076936237 | 1505010492 | Python | Python (3.4.3) | py | Runtime Error | 220 | 6716 | 948 |
from heapq import *
def search(s, length, N, M, R):
d = [100000+1]*N
d[s-1] = 0
prev = [None]*N
pq = [(100000+1, i+1) for i in range(N)]
heapify(pq)
heapreplace(pq, (0, s))
while len(pq) > 0:
u = heappop(pq)
for v, c in length.get(u[1], []):
alt = d[u[1]-1] ... |
s026123305 | p03608 | u463836923 | 1505010069 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 4576 | 1374 | #coding=UTF-8
def search(jun):
global ans
global R
global Kost
tmpans=0
if len(jun)==R:
mae=jun[0]
for idx in range(1,R,1):
ba=jun[idx]
tmpans += Kost[r[mae]][r[ba]]
mae=ba
if ans==None or tmpans<ans:
ans=tmpans
else:
... |
s959581622 | p03608 | u050708958 | 1505009996 | Python | Python (3.4.3) | py | Runtime Error | 2221 | 1610228 | 844 | import itertools
N, M, R = [int(i) for i in input().split()]
must_visit = [int(i) for i in input().split()]
max_city = max(must_visit)
cities = [i+1 for i in range(max_city)]
min_cost = 999999999999
dic = {}
for _ in range(M):
dept, dest, dist = [int(i) for i in input().split()]
if dest < dept:
dest, dept = dept,... |
s428486577 | p03608 | u050708958 | 1505009502 | Python | Python (3.4.3) | py | Runtime Error | 2203 | 1636212 | 921 | import itertools
N, M, R = [int(i) for i in input().split()]
must_visit = [int(i) for i in input().split()]
max_city = max(must_visit)
cities = [i+1 for i in range(max_city)]
min_cost = 999999999999
dic = {}
for _ in range(M):
dept, dest, dist = [int(i) for i in input().split()]
if dest < dept:
dest, dept = dept, ... |
s103846446 | p03608 | u050708958 | 1505008355 | Python | Python (3.4.3) | py | Runtime Error | 373 | 12516 | 716 | import itertools
N, M, R = [int(i) for i in input().split()]
cities = [int(i) for i in input().split()]
dic = {}
for _ in range(M):
dept, dest, dist = [int(i) for i in input().split()]
if dest < dept:
dest, dept = dept, dest
key1, key2 = "{}->{}".format(dept, dest),"{}->{}".format(dest, dept)
if key1 in dic:
d... |
s793212367 | p03608 | u451017206 | 1505008148 | Python | Python (3.4.3) | py | Runtime Error | 1719 | 48644 | 470 | N,M,R = map(int,input().split())
r = map(int,input().split())
from itertools import permutations
from functools import reduce
import numpy as np
t = np.zeros((M+1,M+1))
for i in range(M):
a,b,c = map(int, input().split())
t[a][b] = c
t[b][a] = c
def cost(l):
last = len(l) - 1
ret = 0
for i,j i... |
s067745822 | p03608 | u906129425 | 1505006414 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 4648 | 903 | import itertools
n, m, r = map(int, input().split())
order = list(map(int, input().split()))
dist = [[-1 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
dist[i][i] = 0
for _ in range(m):
a, b, c = map(int, input().split())
if dist[a][b] == -1:
dist[a][b] = c
else:
... |
s001226941 | p03609 | u888380104 | 1601029439 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8868 | 220 | s = input()
N = len(s)
result = []
for i in range(0, N):
if i == 0 or i % 2 == 0:
result.append(s[i])
s = ''
N = len(result)
for i in range(0, N):
s += result[i]
print(s)
s = input()
N = len(s) |
s380451524 | p03609 | u480766273 | 1600509826 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8992 | 131 | s = input()
for i in range(0, len(s), 2):
print(s[i], end = "")
s = input()
for i in range(0, len(s), 2):
print(s[i], end = "") |
s042839642 | p03609 | u480766273 | 1600509774 | Python | Python (3.8.2) | py | Runtime Error | 21 | 8960 | 133 | s = input()
for i in range(0, len(s), 2):
print(s[i], end = ' ')
s = input()
for i in range(0, len(s), 2):
print(s[i], end = ' ') |
s512987294 | p03609 | u886902015 | 1599848444 | Python | Python (3.8.2) | py | Runtime Error | 19 | 9020 | 56 | x,t=map(int,input().split())
print(x-t if x-t>=0,0 else) |
s474165994 | p03609 | u555356625 | 1599072561 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8956 | 60 | x,t = map(int,input())
print(x-t) if x > t else print('0')
|
s507385573 | p03609 | u555356625 | 1599072224 | Python | Python (3.8.2) | py | Runtime Error | 22 | 9048 | 57 | x,t = map(int,input())
print(x-t) if x > t else print(0) |
s324137509 | p03609 | u347397127 | 1598828109 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9104 | 39 | print(max(0,int(input())-int(input()))) |
s266144133 | p03609 | u347397127 | 1598828069 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9148 | 39 | print(max(0,int(input())-int(input()))) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.