Submission #2531316
Source Code Expand
import itertools N,M,R = map(int,input().split()) r = list(map(int,input().split())) g = [[] for _ in range(N+1)] for _ in range(M): A,B,C = map(int,input().split()) g[A].append([B,C]) g[B].append([A,C]) def DFS(v): d = [-1]*(N+1) d[v] = 0 q = [v] while q: u = q.pop() for i in g[u]: if d[i[0]] == -1 or d[i[0]] > (d[u] + i[1]): d[i[0]] = d[u] + i[1] [q.append(j[0]) for j in g[i[0]]] return d d = [[] for _ in range(N+1)] for i in r: d[i] = DFS(i) ans = -1 for i in list(itertools.permutations(r)): a = 0 for j in range(len(i)-1): a += d[i[j]][i[j+1]] if ans == -1 or ans > a: ans = a print(ans)
Submission Info
Submission Time | |
---|---|
Task | D - joisino's travel |
User | lisbun |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 891 Byte |
Status | WA |
Exec Time | 2104 ms |
Memory | 10776 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | TLE | 2104 ms | 10776 KB |
02.txt | WA | 115 ms | 8016 KB |
03.txt | WA | 115 ms | 8016 KB |
04.txt | WA | 767 ms | 8428 KB |
05.txt | TLE | 2104 ms | 4836 KB |
06.txt | TLE | 2104 ms | 10264 KB |
07.txt | TLE | 2104 ms | 8288 KB |
08.txt | WA | 111 ms | 8012 KB |
sample_01.txt | AC | 18 ms | 3064 KB |
sample_02.txt | AC | 18 ms | 3064 KB |
sample_03.txt | AC | 18 ms | 3064 KB |