Submission #1868043


Source Code Expand

#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const ll INF = 1e9;
ll n, ans;
ll a[105][105];
bool bo[105][105];

int main()
{
    scanf("%lld", &n);
//    for(ll i = 1; i <= n; i++) for(ll j = 1; j <= n; j++) a[i][j] = INF;
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    for(ll k = 1; k <= n; k++)
    {
        for(ll i = 1; i <= n; i++)
        {
            for(ll j = 1; j <= n; j++)
            {
                if(i == k || j == k || i == j) continue;
                if(a[i][j] > a[i][k] + a[k][j]) {printf("-1"); return 0;}
                if(a[i][j] == a[i][k] + a[k][j])
                {
                    bo[i][j] = true;
                }
            }
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            ans += (1 - bo[i][j]) * a[i][j];
        }
    }
    printf("%lld", ans / 2);
    return 0;
}

Submission Info

Submission Time
Task D - Restoring Road Network
User mathking1021
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1051 Byte
Status RE
Exec Time 99 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &n);
                      ^
./Main.cpp:21:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld", &a[i][j]);
                                    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 4
AC × 5
RE × 12
Set Name Test Cases
Sample subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt
All 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, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt
Case Name Status Exec Time Memory
01.txt RE 99 ms 384 KB
02.txt RE 98 ms 384 KB
03.txt RE 99 ms 384 KB
04.txt RE 99 ms 384 KB
05.txt RE 98 ms 384 KB
06.txt RE 99 ms 384 KB
07.txt RE 97 ms 384 KB
08.txt RE 97 ms 384 KB
09.txt RE 98 ms 384 KB
10.txt RE 98 ms 384 KB
11.txt RE 98 ms 384 KB
12.txt RE 98 ms 384 KB
13.txt AC 1 ms 256 KB
subtask0_0.txt AC 1 ms 256 KB
subtask0_1.txt AC 1 ms 256 KB
subtask0_2.txt AC 1 ms 256 KB
subtask0_3.txt AC 1 ms 256 KB