Submission #1695823
Source Code Expand
import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.format; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; void main() { int n = readln.chomp.to!int; auto a = new long[][](n); foreach (i; 0 .. n) { a[i] = readln.chomp.split.map!(to!long).array; } long sum = 0; bool yes = true; foreach (i; 0 .. n) { foreach (j; i + 1 .. n) { bool ok = true; foreach (k; 0 .. n) { if (k == i || k == j) { continue; } yes &= a[i][j] <= a[i][k] + a[k][j]; ok &= a[i][j] < a[i][k] + a[k][j]; } if (ok) { sum += a[i][j]; } } } if (yes) sum.writeln; else writeln = -1; }
Submission Info
Submission Time | |
---|---|
Task | D - Restoring Road Network |
User | dptbl |
Language | D (DMD64 v2.070.1) |
Score | 500 |
Code Size | 840 Byte |
Status | AC |
Exec Time | 102 ms |
Memory | 5372 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 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 | 102 ms | 5372 KB |
02.txt | AC | 101 ms | 5372 KB |
03.txt | AC | 99 ms | 5372 KB |
04.txt | AC | 102 ms | 5372 KB |
05.txt | AC | 101 ms | 5372 KB |
06.txt | AC | 99 ms | 5372 KB |
07.txt | AC | 99 ms | 5372 KB |
08.txt | AC | 97 ms | 5372 KB |
09.txt | AC | 94 ms | 4220 KB |
10.txt | AC | 97 ms | 5372 KB |
11.txt | AC | 98 ms | 5372 KB |
12.txt | AC | 100 ms | 5372 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 |