Submission #1785136


Source Code Expand

Copy
h,w = map(int,raw_input().split())
c = []
dist = []
for i in xrange(10):
    c.append(map(int,raw_input().split()))
    dist.append([100000000]*10)
a = []
for i in xrange(h):
    a.append(map(int,raw_input().split()))

for i in xrange(10):
    for j in xrange(10):
        dist[i][j] = c[i][j]
for k in xrange(10):
    for i in xrange(10):
        for j in xrange(10):
            if dist[i][j] > dist[i][k] + dist[k][j]:
                dist[i][j] = dist[i][k] + dist[k][j]

cost = 0
for i in xrange(h):
    for j in xrange(w):
        if a[i][j] != -1:
            cost += dist[a[i][j]][1]
print cost

Submission Info

Submission Time
Task D - Wall
User kcborys
Language Python2 (2.7.6)
Score 400
Code Size 626 Byte
Status
Exec Time 37 ms
Memory 2948 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 400 / 400 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 36 ms 2948 KB
02.txt 36 ms 2948 KB
03.txt 32 ms 2948 KB
04.txt 37 ms 2948 KB
05.txt 24 ms 2820 KB
06.txt 36 ms 2948 KB
07.txt 33 ms 2948 KB
08.txt 15 ms 2696 KB
09.txt 15 ms 2696 KB
10.txt 35 ms 2948 KB
11.txt 32 ms 2948 KB
12.txt 33 ms 2948 KB
13.txt 31 ms 2948 KB
14.txt 30 ms 2948 KB
15.txt 11 ms 2696 KB
16.txt 34 ms 2948 KB
sample_01.txt 11 ms 2696 KB
sample_02.txt 11 ms 2696 KB
sample_03.txt 11 ms 2696 KB