Submission #75874
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #include <bits/stdc++.h> using namespace std; constexpr long long INF = numeric_limits< long long >::max(); int main() { int n, m; cin >> n >> m; assert (2 <= n && n <= 100000); // assert(1 <= m && m <= 100000); // assert(1 <= m && m <= (long long) n * (n - 1) / 2); vector g(n, vector<tuple< int , int , int > >()); for ( int i = 0; i < m; ++i) { int u, v, h, w; cin >> u >> v >> h >> w; // assert(1 <= u && u < v && v <= n); // assert(1 <= h && h <= 1000000000); // assert(0 <= w && w <= 1000000000); --u, --v; g[u].emplace_back(v, h, w); g[v].emplace_back(u, h, w); } vector dist(n, INF); priority_queue<pair< long long , int >, vector<pair< long long , int > > , greater<> > pq; dist[0] = 0; pq.emplace(0, 0); while (!pq.empty()) { auto [cur_dist, cur] = pq.top(); pq.pop(); if (dist[cur] < cur_dist) continue ; for (auto [to, h, w] : g[cur]) { long long new_dist = max< long long >(dist[cur], w) + h; if (dist[to] > new_dist) { dist[to] = new_dist; pq.emplace(dist[to], to); } } } long long res = 0; for ( int i = 1; i < n; ++i) { if (dist[i] != INF && dist[res] < dist[i]) { res = i; } } cout << res + 1 << '\n' ; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 1659 - Yet Unavailable Roads |
ユーザー名 | syoribu |
投稿日時 | 2023-09-10 14:37:42 |
言語 | C++17 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 1466 Byte |
最大実行時間 | 144 ms |
最大メモリ使用量 | 8208 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
corner_input00.txt | AC | 89 ms | 8084 KB |
1
|
corner_input01.txt | AC | 95 ms | 7972 KB |
1
|
corner_input02.txt | AC | 100 ms | 6260 KB |
1
|
random_input01.txt | AC | 17 ms | 504 KB |
1
|
random_input02.txt | AC | 19 ms | 572 KB |
1
|
random_input03.txt | AC | 20 ms | 636 KB |
1
|
random_input04.txt | AC | 17 ms | 552 KB |
1
|
random_input05.txt | AC | 20 ms | 480 KB |
1
|
random_input06.txt | AC | 31 ms | 564 KB |
1
|
random_input07.txt | AC | 21 ms | 596 KB |
1
|
random_input08.txt | AC | 27 ms | 656 KB |
1
|
random_input09.txt | AC | 27 ms | 1216 KB |
1
|
random_input10.txt | AC | 21 ms | 828 KB |
1
|
random_input11.txt | AC | 26 ms | 896 KB |
1
|
random_input12.txt | AC | 23 ms | 952 KB |
1
|
random_input13.txt | AC | 26 ms | 1088 KB |
1
|
random_input14.txt | AC | 32 ms | 1032 KB |
1
|
random_input15.txt | AC | 23 ms | 1180 KB |
1
|
random_input16.txt | AC | 21 ms | 1000 KB |
1
|
random_input17.txt | AC | 90 ms | 4976 KB |
1
|
random_input18.txt | AC | 101 ms | 5544 KB |
1
|
random_input19.txt | AC | 76 ms | 4652 KB |
1
|
random_input20.txt | AC | 42 ms | 2276 KB |
1
|
random_input21.txt | AC | 125 ms | 6380 KB |
1
|
random_input22.txt | AC | 119 ms | 6700 KB |
1
|
random_input23.txt | AC | 49 ms | 2368 KB |
1
|
random_input24.txt | AC | 53 ms | 2452 KB |
1
|
random_input25.txt | AC | 134 ms | 8020 KB |
1
|
random_input26.txt | AC | 144 ms | 8208 KB |
1
|
random_input27.txt | AC | 117 ms | 7156 KB |
1
|
random_input28.txt | AC | 111 ms | 7108 KB |
1
|
sample_input01.txt | AC | 21 ms | 804 KB |
1
|
sample_input02.txt | AC | 20 ms | 652 KB |
1
|
sample_input03.txt | AC | 17 ms | 620 KB |
1
|
sample_input04.txt | AC | 19 ms | 588 KB |
1
|
sample_input05.txt | AC | 17 ms | 560 KB |
1
|