Submission #1783868


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	int c[10][10];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	int a[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == -1) {
				continue;
			}
			ans += c[a[i][j]][1];
		}
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task D - Wall
User jbyxm
Language C++14 (GCC 5.4.1)
Score 400
Code Size 677 Byte
Status
Exec Time 10 ms
Memory 512 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 8 ms 384 KB
02.txt 10 ms 512 KB
03.txt 7 ms 384 KB
04.txt 8 ms 384 KB
05.txt 5 ms 384 KB
06.txt 8 ms 384 KB
07.txt 8 ms 384 KB
08.txt 2 ms 256 KB
09.txt 2 ms 256 KB
10.txt 8 ms 384 KB
11.txt 8 ms 384 KB
12.txt 8 ms 384 KB
13.txt 10 ms 384 KB
14.txt 10 ms 384 KB
15.txt 1 ms 256 KB
16.txt 8 ms 384 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB