結果

問題 No.1480 Many Complete Graphs
ユーザー 蜜蜂蜜蜂
提出日時 2021-03-04 19:31:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 937 bytes
コンパイル時間 2,345 ms
コンパイル使用メモリ 174,284 KB
実行使用メモリ 15,504 KB
最終ジャッジ日時 2023-09-16 02:41:20
合計ジャッジ時間 9,745 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 19 ms
7,272 KB
testcase_14 AC 15 ms
6,016 KB
testcase_15 AC 38 ms
8,152 KB
testcase_16 WA -
testcase_17 AC 24 ms
6,560 KB
testcase_18 AC 7 ms
5,732 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 26 ms
6,948 KB
testcase_22 AC 14 ms
5,100 KB
testcase_23 AC 49 ms
10,944 KB
testcase_24 WA -
testcase_25 AC 80 ms
10,288 KB
testcase_26 AC 102 ms
10,912 KB
testcase_27 AC 70 ms
8,840 KB
testcase_28 AC 149 ms
12,328 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 178 ms
13,452 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 104 ms
12,368 KB
testcase_41 AC 132 ms
12,364 KB
testcase_42 AC 81 ms
12,472 KB
testcase_43 AC 105 ms
12,420 KB
testcase_44 AC 109 ms
12,328 KB
testcase_45 AC 118 ms
12,648 KB
testcase_46 AC 124 ms
12,472 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 74 ms
14,340 KB
testcase_51 AC 269 ms
15,336 KB
testcase_52 AC 87 ms
13,972 KB
testcase_53 WA -
testcase_54 AC 75 ms
13,792 KB
testcase_55 AC 74 ms
13,948 KB
testcase_56 AC 90 ms
13,972 KB
testcase_57 AC 77 ms
14,008 KB
testcase_58 AC 69 ms
14,144 KB
evil_aftercontest.txt AC 139 ms
25,256 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+1});
    for(int j=0;j<k;j++){
      int s;
      cin>>s;
      graph[s-1].pb({n+2*i,s/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