結果
問題 |
No.1812 Uribo Road
|
ユーザー |
![]() |
提出日時 | 2022-01-14 22:11:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,648 bytes |
コンパイル時間 | 4,355 ms |
コンパイル使用メモリ | 239,952 KB |
実行使用メモリ | 615,172 KB |
最終ジャッジ日時 | 2024-11-20 11:04:25 |
合計ジャッジ時間 | 57,681 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 TLE * 7 MLE * 1 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:58:24: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow] 58 | vvi dist(n,vi((1<<k),1e18)); | ^~~~ main.cpp:64:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 64 | auto [d,now,road]=que.top(); | ^ main.cpp:71:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 71 | for(auto [next,dis,id]:g[now]){ | ^
ソースコード
//g++ 2.cpp -std=c++14 -O2 -I . #include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; using vvld = vector<vld>; using vst = vector<string>; using vvst = vector<vst>; #define fi first #define se second #define pb push_back #define pq_big(T) priority_queue<T,vector<T>,less<T>> #define pq_small(T) priority_queue<T,vector<T>,greater<T>> #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) #define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) // 距離 現在地 回収状況 using T = tuple<ll,int,int>; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,m,k; cin>>n>>m>>k; vi need(m,-1); rep(i,0,k){ int r; cin>>r; r--; need[r]=i; } // 行先 距離 index vector<vector<T>> g(n); rep(i,0,m){ int a,b,c; cin>>a>>b>>c; a--;b--; g[a].emplace_back(b,c,i); g[b].emplace_back(a,c,i); } vvi dist(n,vi((1<<k),1e18)); dist[0][0]=0; pq_small(T) que; que.push({0,0,0}); while(!que.empty()){ auto [d,now,road]=que.top(); que.pop(); if(d>dist[now][road]){ continue; } for(auto [next,dis,id]:g[now]){ int r=road; if(need[id]!=-1){ r=(r|(1<<need[id])); } if(dist[next][r]>d+dis){ dist[next][r]=d+dis; que.push({d+dis,next,r}); } } } cout<<dist[n-1][(1<<k)-1]<<endl; }