Submission #1965974


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int h,w;
  cin>>h>>w;
  int n=10;
  vector<vi> d(n,vi(n));
  rep(i,n)rep(j,n)cin>>d[i][j];
  rep(k,n)rep(i,n)rep(j,n)
    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  vi num(n,0);
  rep(i,h)rep(j,w){
    int a;
    cin>>a;
    if(a>=0)num[a]++;
  }
  int ans=0;
  rep(i,n)if(i!=1)ans+=d[i][1]*num[i];
  cout<<ans<<endl;
}

Submission Info

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