結果
問題 | No.2805 Go to School |
ユーザー | silv723 |
提出日時 | 2024-07-05 11:28:24 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,555 bytes |
コンパイル時間 | 2,537 ms |
コンパイル使用メモリ | 213,568 KB |
実行使用メモリ | 22,484 KB |
最終ジャッジ日時 | 2024-07-05 11:28:41 |
合計ジャッジ時間 | 12,473 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | AC | 102 ms
9,072 KB |
testcase_10 | AC | 263 ms
21,172 KB |
testcase_11 | AC | 163 ms
14,432 KB |
testcase_12 | AC | 232 ms
18,260 KB |
testcase_13 | AC | 36 ms
6,144 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 183 ms
15,164 KB |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | AC | 13 ms
7,168 KB |
testcase_28 | AC | 22 ms
7,936 KB |
testcase_29 | RE | - |
testcase_30 | AC | 115 ms
10,624 KB |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | AC | 95 ms
10,496 KB |
testcase_37 | AC | 167 ms
15,916 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:24:33: warning: narrowing conversion of 'b' from 'long long int' to 'int' [-Wnarrowing] 24 | g[a].push_back({b, c}); | ^ main.cpp:25:33: warning: narrowing conversion of 'a' from 'long long int' to 'int' [-Wnarrowing] 25 | g[b].push_back({a, c}); | ^
ソースコード
#include<bits/stdc++.h> using namespace std; struct edge{ int to; long long cost; }; using graph = vector<vector<edge>>; int main(){ long long n, m, l, s, e; cin >> n >> m >> l >> s >> e; assert(2 <= n && n <= 200000); assert(1 <= m && m <= 200000); assert(1 <= l && l <= n); assert(1 <= s && s <= 1000000000); assert(1 <= e && e <= 1000000000); graph g(n); for(int i = 0; i < m; i++){ long long a, b, c; cin >> a >> b >> c; assert(1 <= a && a <= n); assert(1 <= b && b <= n); assert(1 <= c && c <= 1000000000); a--, b--; g[a].push_back({b, c}); g[b].push_back({a, c}); } vector<int> t(n); for(int i = 0; i < l; i++){ int x; cin >> x; assert(1 <= x && x <= n); x--; t[x] = 1; } vector<long long> d(2*n, 1e18); d[0] = 0; using p = pair<long long, int>; priority_queue<p, vector<p>, greater<p>> pq; pq.push({0, 0}); while(!pq.empty()){ p q = pq.top(); pq.pop(); if(d[q.second] != q.first) continue; if(q.second%2 == 0 && t[q.second/2] == 1){ if(s <= q.first && q.first <= s+e-1){ if(d[q.second+1] > q.first+1){ d[q.second+1] = q.first+1; pq.push({q.first+1, q.second+1}); } }else if(q.first < s){ if(d[q.second+1] > s+1){ d[q.second+1] = s+1; pq.push({q.first+1, s+1}); } } } for(auto eg:g[q.second/2]){ if(d[eg.to*2+q.second%2] > d[q.second] + eg.cost){ d[eg.to*2+q.second%2] = d[q.second] + eg.cost; pq.push({d[q.second] + eg.cost, eg.to*2+q.second%2}); } } } if(d[2*n-1] > 1e17) cout << -1 << '\n'; else cout << d[2*n-1] << '\n'; }