結果

問題 No.1480 Many Complete Graphs
ユーザー 蜜蜂蜜蜂
提出日時 2021-03-04 19:55:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 939 bytes
コンパイル時間 1,824 ms
コンパイル使用メモリ 174,464 KB
実行使用メモリ 15,512 KB
最終ジャッジ日時 2023-09-16 02:41:48
合計ジャッジ時間 8,882 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 19 ms
7,268 KB
testcase_14 AC 14 ms
5,944 KB
testcase_15 WA -
testcase_16 AC 19 ms
6,916 KB
testcase_17 AC 23 ms
6,488 KB
testcase_18 AC 7 ms
5,744 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 22 ms
6,964 KB
testcase_22 AC 12 ms
5,228 KB
testcase_23 AC 47 ms
10,928 KB
testcase_24 AC 67 ms
8,760 KB
testcase_25 WA -
testcase_26 AC 107 ms
10,884 KB
testcase_27 AC 68 ms
8,764 KB
testcase_28 AC 147 ms
12,428 KB
testcase_29 AC 163 ms
13,400 KB
testcase_30 AC 146 ms
12,324 KB
testcase_31 AC 167 ms
13,376 KB
testcase_32 AC 214 ms
13,692 KB
testcase_33 AC 149 ms
12,508 KB
testcase_34 AC 150 ms
12,332 KB
testcase_35 AC 102 ms
12,412 KB
testcase_36 AC 113 ms
12,568 KB
testcase_37 AC 92 ms
12,300 KB
testcase_38 AC 109 ms
12,328 KB
testcase_39 AC 103 ms
12,528 KB
testcase_40 AC 105 ms
12,388 KB
testcase_41 WA -
testcase_42 AC 81 ms
12,376 KB
testcase_43 AC 106 ms
12,648 KB
testcase_44 AC 109 ms
12,356 KB
testcase_45 AC 116 ms
12,380 KB
testcase_46 AC 115 ms
12,376 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 72 ms
14,588 KB
testcase_51 AC 268 ms
15,512 KB
testcase_52 WA -
testcase_53 AC 75 ms
13,852 KB
testcase_54 AC 74 ms
13,988 KB
testcase_55 AC 76 ms
13,972 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 67 ms
14,172 KB
evil_aftercontest.txt AC 140 ms
25,168 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:37:10: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   37 |     auto [now,dist] = que.top();
      |          ^
main.cpp:44:14: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   44 |     for(auto [next,dist2] : graph[now]){
      |              ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
#define fi first
#define se second
#define pb push_back

using T = pair<int,ll>;

int main(){
  int n,m;
  cin>>n>>m;

  vector<vector<T>> graph(n+2*m);
  vector<ll> ans(n+2*m,1e18);
  ans[0]=0;
  
  for(int i=0;i<m;i++){
    int k;
    ll c;
    cin>>k>>c;
    graph[n+2*i].pb({n+2*i+1,c});
    for(int j=0;j<k;j++){
      int s;
      cin>>s;
      graph[s-1].pb({n+2*i,(s+1)/2});
      graph[n+2*i+1].pb({s-1,s/2});
    }
  }

  priority_queue<T,vector<T>,greater<T>> que;
  que.push({0,0});

  while(!que.empty()){
    auto [now,dist] = que.top();
    que.pop();

    if(dist>ans[now]){
      continue;
    }

    for(auto [next,dist2] : graph[now]){
      if(ans[now]+dist2<ans[next]){
        que.push({next,dist2});
        ans[next]=ans[now]+dist2;
      }
    }
  }
  
  if(ans[n-1]>=1e18){
    ans[n-1]=-1;
  }
  cout<<ans[n-1]<<endl;
}
0