CSES - Leirikisa 4 - Results
Submission details
Task:putnik
Sender:eXeP
Submission time:2016-08-01 16:11:34 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.06 sdetails
#4ACCEPTED0.05 sdetails
#5ACCEPTED0.06 sdetails
#6--details
#7--details
#8--details

Code

#include <bits/stdc++.h>

#define i64 long long
#define u64 unsigned long long
#define i32 int
#define u32 unsigned int

#define pii pair<int, int>
#define pll pair<long long, long long>

#define ld long double
#define defmod 1000000007

#define mati64(a,b) vector<vector<i64>>(a, vector<i64>(b, 0));
using namespace std;

int n;
int v[1010][1010];

i64 hae(int alk, int lop, int cur){
  if(cur == 0)
    return v[alk][lop];
  i64 lol = min(v[alk][cur]+hae(cur, lop, cur-1), v[cur][lop]+hae(alk, cur, cur-1));
  //cout << alk << " " << lop << " " << cur << " " << lol << endl;
  return lol;
}
int main(){
  cin.sync_with_stdio(0);
  cin.tie(0);

  cin >> n;
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= n; ++j)
      cin >> v[i][j];
  }
  cout << hae(0, 0, n) << endl;
  return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
3
0 5 2
5 0 4
2 4 0

correct output
7

user output
7

Test 2

Verdict: ACCEPTED

input
4
0 15 7 8
15 0 16 9
7 16 0 12
8 9 12 0

correct output
31

user output
31

Test 3

Verdict: ACCEPTED

input
5
0 929 320 220 170
929 0 16 856 166
320 16 0 989 554
220 856 989 0 695
...

correct output
1719

user output
1719

Test 4

Verdict: ACCEPTED

input
8
0 506 801 997 312 671 746 780
506 0 634 349 891 378 259 767
801 634 0 806 899 355 545 800
997 349 806 0 780 454 434 962
...

correct output
3214

user output
3214

Test 5

Verdict: ACCEPTED

input
16
0 432 752 452 683 655 785 402 ...

correct output
4696

user output
4696

Test 6

Verdict:

input
300
0 118 579 90 535 606 866 184 1...

correct output
88301

user output
(empty)

Test 7

Verdict:

input
1500
0 27 341 796 776 497 727 796 5...

correct output
440136

user output
(empty)

Test 8

Verdict:

input
1499
0 674 891 871 992 186 562 169 ...

correct output
426711

user output
(empty)