Submission #3888526

Source Code Expand

Copy
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    int H, W;
    cin >> H >> W;

    int c[10][10];
    FOR(i, 0, 10){
        FOR(j, 0, 10){
            cin >> c[i][j];
        }
    }

    FOR(i, 0, 10){ // 経由点
        FOR(j, 0, 10){ // 始点
            FOR(k, 0, 10){ // 終点
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    ll cost = 0;
    FOR(i, 0, H){
        FOR(j, 0, W){
            int a;
            cin >> a;
            if(a!=-1){
                cost += c[a][1];
            }
        }
    }

    p(cost);
    
    return 0;
}

Submission Info

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