Submission #3825527
Source Code Expand
#include <algorithm> #include <bitset> #include <cctype> #include <chrono> #include <cmath> #include <cstdio> #include <ctime> #include <deque> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; /*----------------------------------------*/ int main() { cin.tie(0); ios::sync_with_stdio(false); // freopen("input.txt", "r", stdin); int t; cin >> t; REP(repeat, t) { int n; cin >> n; vector<vector<int> > a(n, vector<int>(n)); bool ok = true; REP(i, n) REP(j, n) { cin >> a[i][j]; if (i == j && a[i][j] != 0) ok = false; } REP(i, n) REP(j, n) { if (i == j) continue; int ans = INF; vector<bool> used(n, false); used[i] = true; priority_queue<pair<int, int>> que; REP(k, n) if (k != i && k != j && a[i][k] != -1) { que.push(make_pair(a[i][k], k)); used[k] = true; } while (!que.empty()) { auto aut = que.top(); que.pop(); if (aut.second == j) { ans = aut.first; break; } REP(k, n) if (!used[k] && a[aut.second][k] != -1) { que.push(make_pair(aut.first + a[aut.second][k], k)); used[k] = true; } } if (a[i][j] > ans) { ok = false; break; } } cout << (ok? "YES" : "NO") << '\n'; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 最短経路 |
User | emthrm |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1711 Byte |
Status | WA |
Exec Time | 41 ms |
Memory | 256 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_sample.txt, 10_random_00.txt, 10_random_01.txt, 10_random_02.txt, 10_random_03.txt, 10_random_04.txt, 10_random_05.txt, 10_random_06.txt, 10_random_07.txt, 10_random_08.txt, 10_random_09.txt, 10_random_10.txt, 10_random_11.txt, 10_random_12.txt, 10_random_13.txt, 10_random_14.txt, 10_random_15.txt, 10_random_16.txt, 10_random_17.txt, 10_random_18.txt, 10_random_19.txt, 10_random_20.txt, 10_random_21.txt, 10_random_22.txt, 10_random_23.txt, 10_random_24.txt, 10_random_25.txt, 10_random_26.txt, 10_random_27.txt, 10_random_28.txt, 10_random_29.txt, 22_random_30.txt, 22_random_31.txt, 23_coplete_32.txt, 23_coplete_33.txt, 24_path_34.txt, 24_path_35.txt, 25_tree_36.txt, 25_tree_37.txt, 26_noedge_38.txt, 27_dot_39.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample.txt | AC | 1 ms | 256 KB |
10_random_00.txt | WA | 31 ms | 256 KB |
10_random_01.txt | WA | 30 ms | 256 KB |
10_random_02.txt | WA | 29 ms | 256 KB |
10_random_03.txt | WA | 25 ms | 256 KB |
10_random_04.txt | WA | 33 ms | 256 KB |
10_random_05.txt | WA | 31 ms | 256 KB |
10_random_06.txt | WA | 27 ms | 256 KB |
10_random_07.txt | WA | 28 ms | 256 KB |
10_random_08.txt | WA | 30 ms | 256 KB |
10_random_09.txt | WA | 33 ms | 256 KB |
10_random_10.txt | WA | 30 ms | 256 KB |
10_random_11.txt | WA | 29 ms | 256 KB |
10_random_12.txt | WA | 29 ms | 256 KB |
10_random_13.txt | WA | 31 ms | 256 KB |
10_random_14.txt | WA | 28 ms | 256 KB |
10_random_15.txt | WA | 32 ms | 256 KB |
10_random_16.txt | WA | 25 ms | 256 KB |
10_random_17.txt | WA | 31 ms | 256 KB |
10_random_18.txt | WA | 29 ms | 256 KB |
10_random_19.txt | WA | 26 ms | 256 KB |
10_random_20.txt | WA | 34 ms | 256 KB |
10_random_21.txt | WA | 31 ms | 256 KB |
10_random_22.txt | WA | 30 ms | 256 KB |
10_random_23.txt | WA | 30 ms | 256 KB |
10_random_24.txt | WA | 31 ms | 256 KB |
10_random_25.txt | WA | 29 ms | 256 KB |
10_random_26.txt | WA | 31 ms | 256 KB |
10_random_27.txt | WA | 32 ms | 256 KB |
10_random_28.txt | WA | 30 ms | 256 KB |
10_random_29.txt | WA | 31 ms | 256 KB |
22_random_30.txt | WA | 28 ms | 256 KB |
22_random_31.txt | WA | 28 ms | 256 KB |
23_coplete_32.txt | AC | 24 ms | 256 KB |
23_coplete_33.txt | AC | 24 ms | 256 KB |
24_path_34.txt | WA | 41 ms | 256 KB |
24_path_35.txt | WA | 41 ms | 256 KB |
25_tree_36.txt | WA | 14 ms | 256 KB |
25_tree_37.txt | WA | 14 ms | 256 KB |
26_noedge_38.txt | AC | 6 ms | 256 KB |
27_dot_39.txt | AC | 1 ms | 256 KB |