結果
問題 | No.1601 With Animals into Institute |
ユーザー | kens |
提出日時 | 2021-07-10 14:19:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,101 ms / 3,000 ms |
コード長 | 1,202 bytes |
コンパイル時間 | 4,732 ms |
コンパイル使用メモリ | 203,752 KB |
最終ジャッジ日時 | 2025-01-23 00:08:38 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
コンパイルメッセージ
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; }