Submission #1691505
Source Code Expand
#include <stdio.h> #include <stdlib.h> int main(void) { int N; int A[300][300], A2[300][300]; int i, j, k; int cost; long long int sum = 0; scanf("%d", &N); for (j = 0; j < N; j++) { for (i = 0; i < N; i++) { scanf("%d", &A[j][i]); } } for (j = 0; j < N - 1; j++) { for (i = j + 1; i < N; i++) { A2[j][i] = 0; for (k = 0; k < N; k++) { if (A[j][k] * A[k][i] != 0 && (A2[j][i] > (cost = A[j][k] + A[k][i]) || A2[j][i] == 0)) { A2[j][i] = cost; } } } } for (j = 0; j < N - 1; j++) { for (i = j + 1; i < N; i++) { if (A2[j][i] < A[j][i]) { printf("-1\n"); return 0; } else if (A2[j][i] > A[j][i]) { sum += A[j][i]; } } } printf("%lld\n", sum); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Restoring Road Network |
User | gidoichi |
Language | C (GCC 5.4.1) |
Score | 0 |
Code Size | 884 Byte |
Status | WA |
Exec Time | 34 ms |
Memory | 896 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:11:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.c:14:7: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &A[j][i]); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
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 | AC | 32 ms | 896 KB |
02.txt | AC | 32 ms | 896 KB |
03.txt | AC | 33 ms | 896 KB |
04.txt | AC | 33 ms | 896 KB |
05.txt | AC | 33 ms | 896 KB |
06.txt | AC | 32 ms | 896 KB |
07.txt | AC | 32 ms | 896 KB |
08.txt | AC | 32 ms | 896 KB |
09.txt | AC | 32 ms | 896 KB |
10.txt | AC | 32 ms | 896 KB |
11.txt | AC | 32 ms | 896 KB |
12.txt | AC | 34 ms | 896 KB |
13.txt | WA | 0 ms | 128 KB |
subtask0_0.txt | AC | 0 ms | 128 KB |
subtask0_1.txt | AC | 0 ms | 128 KB |
subtask0_2.txt | AC | 0 ms | 128 KB |
subtask0_3.txt | AC | 0 ms | 128 KB |