結果
問題 | No.1601 With Animals into Institute |
ユーザー |
|
提出日時 | 2021-07-10 14:19:05 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 646 ms / 3,000 ms |
コード長 | 1,202 bytes |
コンパイル時間 | 2,310 ms |
コンパイル使用メモリ | 212,064 KB |
実行使用メモリ | 31,256 KB |
最終ジャッジ日時 | 2024-07-02 02:21:37 |
合計ジャッジ時間 | 12,331 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 10 ms
5,376 KB |
testcase_04 | AC | 9 ms
5,376 KB |
testcase_05 | AC | 10 ms
5,376 KB |
testcase_06 | AC | 643 ms
31,140 KB |
testcase_07 | AC | 628 ms
31,072 KB |
testcase_08 | AC | 641 ms
31,096 KB |
testcase_09 | AC | 639 ms
31,140 KB |
testcase_10 | AC | 645 ms
31,088 KB |
testcase_11 | AC | 631 ms
31,224 KB |
testcase_12 | AC | 646 ms
31,092 KB |
testcase_13 | AC | 629 ms
31,256 KB |
testcase_14 | AC | 642 ms
31,080 KB |
testcase_15 | AC | 642 ms
31,084 KB |
testcase_16 | AC | 637 ms
31,124 KB |
testcase_17 | AC | 642 ms
31,060 KB |
testcase_18 | AC | 9 ms
5,376 KB |
testcase_19 | AC | 9 ms
5,376 KB |
testcase_20 | AC | 10 ms
5,376 KB |
testcase_21 | AC | 9 ms
5,376 KB |
testcase_22 | AC | 9 ms
5,376 KB |
testcase_23 | AC | 9 ms
5,376 KB |
testcase_24 | AC | 9 ms
5,376 KB |
testcase_25 | AC | 9 ms
5,376 KB |
testcase_26 | AC | 9 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 2 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:37:27: warning: narrowing conversion of 'b' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 37 | g[a].push_back(edge{b,c}); | ^ main.cpp:38:27: warning: narrowing conversion of 'a' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 38 | g[b].push_back(edge{a,c}); | ^ main.cpp:39:30: warning: narrowing conversion of '(b + ((ll)n))' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 39 | g[a+n].push_back(edge{b+n,c}); | ~^~ main.cpp:40:30: warning: narrowing conversion of '(a + ((ll)n))' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 40 | g[b+n].push_back(edge{a+n,c}); | ~^~ main.cpp:42:28: warning: narrowing conversion of '(b + ((ll)n))' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 42 | g[a].push_back(edge{b+n,c}); | ~^~ main.cpp:43:28: warning: narrowing conversion of '(a + ((ll)n))' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 43 | g[b].push_back(edge{a+n,c}); | ~^~ main.cpp:44:30: warning: narrowing conversion of '(b + ((ll)n))' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 44 | g[a+n].push_back(edge{b+n,c}); | ~^~ main.cpp:45:30: warning: narrowing conversion of '(a + ((ll)n))' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 45 | g[b+n].push_back(edge{a+n,c}); | ~^~
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) using ll = long long; struct edge{int to; ll cost;}; using P = pair<ll,int>; const ll INF = 1e17; void dijkstra(int n, int s, vector<vector<edge>>& g, vector<ll>& d){ priority_queue<P,vector<P>,greater<P>> que; rep(i,n) d[i] = INF; d[s] = 0; que.push(P(0,s)); while(!que.empty()){ P p = que.top(); que.pop(); int v = p.second; if(d[v] < p.first) continue; for(auto e : g[v]){ if(d[e.to] > d[v] + e.cost){ d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } } int main() { int n, m; cin >> n >> m; vector<vector<edge>> g(2*n); rep(i,m) { ll a, b, c, x; cin >> a >> b >> c >> x; a--; b--; if(x == 0) { g[a].push_back(edge{b,c}); g[b].push_back(edge{a,c}); g[a+n].push_back(edge{b+n,c}); g[b+n].push_back(edge{a+n,c}); } else { g[a].push_back(edge{b+n,c}); g[b].push_back(edge{a+n,c}); g[a+n].push_back(edge{b+n,c}); g[b+n].push_back(edge{a+n,c}); } } vector<ll> d(2*n); dijkstra(2*n,n-1,g,d); for(int i = n; i < 2*n-1; i++) cout << d[i] << endl; }