Submission #3045043
Source Code Expand
h,w = map(int,input().split()) g = [[] for _ in range(0,10)] for i in range(0,10): a = list(map(int,input().split())) for j in range(0,10): g[i].append((j,a[j])) def dijkstra(s): d = [float("inf") for _ in range(0,10)] d[s] = 0 q = [] q.append((s,g[s])) while len(q) > 0: start,edge = q.pop(0) for to,cost in edge: if d[to] > d[start] + cost: d[to] = d[start] + cost q.append((to,g[to])) return d[1] d = [] for i in range(0,10): d.append(dijkstra(i)) ans = 0 for i in range(0,h): a = list(map(int,input().split())) for j in range(0,w): if a[j] != -1: ans += d[a[j]] print(ans)
Submission Info
Submission Time | |
---|---|
Task | D - Wall |
User | shinsakun |
Language | Python (3.4.3) |
Score | 400 |
Code Size | 741 Byte |
Status | AC |
Exec Time | 34 ms |
Memory | 3064 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 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, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 33 ms | 3064 KB |
02.txt | AC | 33 ms | 3064 KB |
03.txt | AC | 30 ms | 3064 KB |
04.txt | AC | 33 ms | 3064 KB |
05.txt | AC | 27 ms | 3064 KB |
06.txt | AC | 33 ms | 3064 KB |
07.txt | AC | 33 ms | 3064 KB |
08.txt | AC | 21 ms | 3064 KB |
09.txt | AC | 20 ms | 3064 KB |
10.txt | AC | 33 ms | 3064 KB |
11.txt | AC | 34 ms | 3064 KB |
12.txt | AC | 33 ms | 3064 KB |
13.txt | AC | 28 ms | 3064 KB |
14.txt | AC | 28 ms | 3064 KB |
15.txt | AC | 18 ms | 3064 KB |
16.txt | AC | 33 ms | 3064 KB |
sample_01.txt | AC | 17 ms | 3064 KB |
sample_02.txt | AC | 17 ms | 3064 KB |
sample_03.txt | AC | 18 ms | 3064 KB |