結果
問題 | No.1601 With Animals into Institute |
ユーザー | kens |
提出日時 | 2021-07-10 14:19:05 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 629 ms / 3,000 ms |
コード長 | 1,202 bytes |
コンパイル時間 | 2,209 ms |
コンパイル使用メモリ | 210,256 KB |
実行使用メモリ | 30,912 KB |
最終ジャッジ日時 | 2023-09-14 19:22:23 |
合計ジャッジ時間 | 12,082 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 8 ms
4,380 KB |
testcase_04 | AC | 9 ms
4,376 KB |
testcase_05 | AC | 9 ms
4,376 KB |
testcase_06 | AC | 609 ms
30,724 KB |
testcase_07 | AC | 612 ms
30,892 KB |
testcase_08 | AC | 615 ms
30,644 KB |
testcase_09 | AC | 611 ms
30,876 KB |
testcase_10 | AC | 619 ms
30,640 KB |
testcase_11 | AC | 615 ms
30,720 KB |
testcase_12 | AC | 626 ms
30,648 KB |
testcase_13 | AC | 613 ms
30,696 KB |
testcase_14 | AC | 623 ms
30,660 KB |
testcase_15 | AC | 629 ms
30,712 KB |
testcase_16 | AC | 623 ms
30,908 KB |
testcase_17 | AC | 622 ms
30,912 KB |
testcase_18 | AC | 9 ms
4,380 KB |
testcase_19 | AC | 9 ms
4,380 KB |
testcase_20 | AC | 8 ms
4,380 KB |
testcase_21 | AC | 9 ms
4,376 KB |
testcase_22 | AC | 9 ms
4,380 KB |
testcase_23 | AC | 9 ms
4,380 KB |
testcase_24 | AC | 9 ms
4,376 KB |
testcase_25 | AC | 9 ms
4,380 KB |
testcase_26 | AC | 9 ms
4,380 KB |
testcase_27 | AC | 1 ms
4,376 KB |
testcase_28 | AC | 2 ms
4,376 KB |
testcase_29 | AC | 1 ms
4,384 KB |
testcase_30 | AC | 1 ms
4,376 KB |
testcase_31 | AC | 2 ms
4,376 KB |
testcase_32 | AC | 2 ms
4,376 KB |
testcase_33 | AC | 2 ms
4,376 KB |
testcase_34 | AC | 1 ms
4,380 KB |
testcase_35 | AC | 2 ms
4,380 KB |
testcase_36 | AC | 2 ms
4,376 KB |
testcase_37 | AC | 1 ms
4,380 KB |
testcase_38 | AC | 1 ms
4,376 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:37:27: 警告: 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: 警告: 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: 警告: 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: 警告: 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: 警告: 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: 警告: 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: 警告: 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: 警告: 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; }