結果
問題 | No.1601 With Animals into Institute |
ユーザー | publfl |
提出日時 | 2021-07-10 14:11:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 268 ms / 3,000 ms |
コード長 | 1,153 bytes |
コンパイル時間 | 434 ms |
コンパイル使用メモリ | 54,244 KB |
実行使用メモリ | 23,368 KB |
最終ジャッジ日時 | 2023-09-14 19:17:21 |
合計ジャッジ時間 | 6,227 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
8,316 KB |
testcase_01 | AC | 4 ms
8,288 KB |
testcase_02 | AC | 4 ms
8,240 KB |
testcase_03 | AC | 6 ms
8,584 KB |
testcase_04 | AC | 6 ms
8,644 KB |
testcase_05 | AC | 6 ms
8,560 KB |
testcase_06 | AC | 267 ms
23,272 KB |
testcase_07 | AC | 267 ms
23,304 KB |
testcase_08 | AC | 260 ms
23,304 KB |
testcase_09 | AC | 257 ms
23,348 KB |
testcase_10 | AC | 256 ms
23,316 KB |
testcase_11 | AC | 261 ms
23,240 KB |
testcase_12 | AC | 260 ms
23,336 KB |
testcase_13 | AC | 264 ms
23,368 KB |
testcase_14 | AC | 262 ms
23,304 KB |
testcase_15 | AC | 265 ms
23,312 KB |
testcase_16 | AC | 264 ms
23,332 KB |
testcase_17 | AC | 268 ms
23,316 KB |
testcase_18 | AC | 7 ms
8,704 KB |
testcase_19 | AC | 6 ms
8,700 KB |
testcase_20 | AC | 7 ms
8,704 KB |
testcase_21 | AC | 7 ms
8,712 KB |
testcase_22 | AC | 7 ms
8,636 KB |
testcase_23 | AC | 6 ms
8,692 KB |
testcase_24 | AC | 6 ms
8,632 KB |
testcase_25 | AC | 7 ms
8,636 KB |
testcase_26 | AC | 7 ms
8,672 KB |
testcase_27 | AC | 4 ms
8,264 KB |
testcase_28 | AC | 4 ms
8,244 KB |
testcase_29 | AC | 4 ms
8,232 KB |
testcase_30 | AC | 4 ms
8,240 KB |
testcase_31 | AC | 3 ms
8,328 KB |
testcase_32 | AC | 3 ms
8,268 KB |
testcase_33 | AC | 4 ms
8,268 KB |
testcase_34 | AC | 4 ms
8,304 KB |
testcase_35 | AC | 4 ms
8,296 KB |
testcase_36 | AC | 4 ms
8,296 KB |
testcase_37 | AC | 4 ms
8,236 KB |
testcase_38 | AC | 4 ms
8,244 KB |
ソースコード
#include <stdio.h> #include <vector> #include <queue> #define MAX (long long int)1e16 struct str{ int first; int second; long long int third; }; bool operator<(str a, str b) { return a.third>b.third; } std::priority_queue<str> Q; std::vector<str> V[200010]; long long int dist[200010][3]; int main() { int a,b; scanf("%d%d",&a,&b); for(int i=1;i<=b;i++) { int c,d,e,f; scanf("%d%d%d%d",&c,&d,&e,&f); V[c].push_back({d,e,f}); V[d].push_back({c,e,f}); } for(int i=1;i<=a;i++) dist[i][0] = dist[i][1] = MAX; Q.push({a,0,0}); dist[0][0] = 0; while(!Q.empty()) { str A = Q.top(); Q.pop(); if(dist[A.first][A.second]<A.third) continue; for(int i=0;i<V[A.first].size();i++) { str B = V[A.first][i]; if(B.third==1) { if(dist[B.first][1]>A.third + B.second) { dist[B.first][1] = A.third + B.second; Q.push({B.first,1,A.third+B.second}); } } else { if(dist[B.first][A.second]>A.third + B.second) { dist[B.first][A.second] = A.third + B.second; Q.push({B.first,A.second,A.third+B.second}); } } } } for(int i=1;i<a;i++) printf("%lld\n",dist[i][1]); }