Submission #1872887
Source Code Expand
import numpy as np from copy import deepcopy def dijkstra(N, matrix, s): d = [np.inf for _ in range(N)] d[s] = 0 prev = [-1 for _ in range(N)] Q = set([i for i in range(N)]) def min_index(): mi = np.inf mii = 0 for i in Q: if d[i] < mi: mii = i return mii while Q: u = min_index() Q.remove(u) for v in range(N): if matrix[u][v] >= 0: alt = d[u] + matrix[u][v] if d[v] > alt: d[v] = alt prev[v] = u return d H, W = map(int, input().split()) c = [] for _ in range(10): c.append([int(x) for x in input().split()]) c_tmp = deepcopy(c) for i in range(10): for j in range(10): c_tmp[i][j] = c[j][i] c = c_tmp k = [0 for _ in range(10)] for i in range(H): xs = [int(x) for x in input().split()] for x in xs: if x > 0: k[x] += 1 d = dijkstra(10, c, 1) count = 0 for i in range(10): if i != 1: count += d[i] * k[i] print(count)
Submission Info
Submission Time | |
---|---|
Task | D - Wall |
User | izziiyt |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1146 Byte |
Status | WA |
Exec Time | 165 ms |
Memory | 14268 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, 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 | WA | 162 ms | 12232 KB |
02.txt | WA | 161 ms | 14268 KB |
03.txt | WA | 162 ms | 12232 KB |
04.txt | WA | 162 ms | 12232 KB |
05.txt | AC | 158 ms | 12232 KB |
06.txt | WA | 161 ms | 12232 KB |
07.txt | WA | 162 ms | 12232 KB |
08.txt | WA | 153 ms | 12232 KB |
09.txt | WA | 153 ms | 12232 KB |
10.txt | WA | 161 ms | 12232 KB |
11.txt | WA | 163 ms | 12232 KB |
12.txt | WA | 164 ms | 12232 KB |
13.txt | AC | 160 ms | 12232 KB |
14.txt | AC | 161 ms | 12232 KB |
15.txt | WA | 147 ms | 12232 KB |
16.txt | WA | 165 ms | 12232 KB |
sample_01.txt | AC | 150 ms | 12232 KB |
sample_02.txt | AC | 148 ms | 12232 KB |
sample_03.txt | AC | 150 ms | 12232 KB |