結果

問題 No.1812 Uribo Road
ユーザー 蜜蜂蜜蜂
提出日時 2022-01-14 22:11:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,648 bytes
コンパイル時間 3,508 ms
コンパイル使用メモリ 239,492 KB
実行使用メモリ 176,816 KB
最終ジャッジ日時 2024-04-30 15:10:02
合計ジャッジ時間 10,398 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 10 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 19 ms
6,940 KB
testcase_09 AC 38 ms
6,940 KB
testcase_10 AC 13 ms
6,940 KB
testcase_11 AC 7 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: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]){
      |              ^

ソースコード

diff #

//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;
}
0