結果
問題 | No.1812 Uribo Road |
ユーザー | Haa |
提出日時 | 2022-01-14 22:32:34 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,538 bytes |
コンパイル時間 | 2,204 ms |
コンパイル使用メモリ | 191,104 KB |
実行使用メモリ | 14,024 KB |
最終ジャッジ日時 | 2024-04-30 16:00:57 |
合計ジャッジ時間 | 8,608 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 30 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 56 ms
7,036 KB |
testcase_09 | AC | 104 ms
9,476 KB |
testcase_10 | AC | 42 ms
7,096 KB |
testcase_11 | AC | 20 ms
6,940 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:54:33: warning: narrowing conversion of 'i' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 54 | g[a].push_back(edge{b,c,i}); | ^ main.cpp:55:33: warning: narrowing conversion of 'i' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 55 | g[b].push_back(edge{a,c,i}); | ^
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> P; typedef vector<ll> VI; typedef vector<VI> VVI; #define REP(i,n) for(ll i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;}; template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;}; constexpr ll MOD=1000000007; constexpr ll INF=2e18; int n, m, k; struct edge { int to, cost, id; }; vector<edge> g[21000]; unordered_map<int,ll> d; unordered_map<int,int> ri; void dijkstra(int s){ priority_queue<P,vector<P>,greater<P>> que; d[s]=0; que.push({0,s}); while(!que.empty()){ P p=que.top(); que.pop(); int v=p.second/(1<<k); int w=p.second%(1<<k); if(d[p.second]<p.first) continue; for(auto e:g[v]){ int to=e.to*(1<<k)+w; if(ri[e.id]>0) to|=(1<<(ri[e.id]-1)); if(d.find(to)==d.end()) d[to]=INF; if(d[to]>d[p.second]+e.cost){ d[to]=d[p.second]+e.cost; que.push({d[to],to}); } } } } int main(){ cin >> n >> m >> k; VI r(k); REP(i,k) cin >> r[i]; REP(i,k) ri[r[i]-1]=i+1; int a, b, c; REP(i,m){ cin >> a >> b >> c; a--, b--; g[a].push_back(edge{b,c,i}); g[b].push_back(edge{a,c,i}); } dijkstra(0); int p=(n-1)*(1<<k)+(1<<k)-1; cout << d[p] << endl; return 0; }