結果

問題 No.1473 おでぶなおばけさん
ユーザー 蜜蜂蜜蜂
提出日時 2021-04-09 21:44:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 325 ms / 2,000 ms
コード長 1,549 bytes
コンパイル時間 4,063 ms
コンパイル使用メモリ 237,264 KB
実行使用メモリ 11,840 KB
最終ジャッジ日時 2023-09-07 10:38:38
合計ジャッジ時間 10,601 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 204 ms
10,344 KB
testcase_03 AC 87 ms
8,648 KB
testcase_04 AC 76 ms
6,944 KB
testcase_05 AC 31 ms
4,380 KB
testcase_06 AC 112 ms
8,508 KB
testcase_07 AC 124 ms
10,356 KB
testcase_08 AC 132 ms
10,428 KB
testcase_09 AC 120 ms
10,384 KB
testcase_10 AC 37 ms
5,080 KB
testcase_11 AC 37 ms
5,232 KB
testcase_12 AC 37 ms
5,120 KB
testcase_13 AC 25 ms
5,124 KB
testcase_14 AC 18 ms
4,376 KB
testcase_15 AC 33 ms
5,076 KB
testcase_16 AC 36 ms
5,256 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 42 ms
5,232 KB
testcase_20 AC 60 ms
7,788 KB
testcase_21 AC 101 ms
7,188 KB
testcase_22 AC 167 ms
10,796 KB
testcase_23 AC 138 ms
9,036 KB
testcase_24 AC 134 ms
9,832 KB
testcase_25 AC 264 ms
11,772 KB
testcase_26 AC 271 ms
11,840 KB
testcase_27 AC 43 ms
5,760 KB
testcase_28 AC 98 ms
10,448 KB
testcase_29 AC 68 ms
6,552 KB
testcase_30 AC 79 ms
7,068 KB
testcase_31 AC 325 ms
11,244 KB
testcase_32 AC 81 ms
8,548 KB
testcase_33 AC 112 ms
8,136 KB
testcase_34 AC 61 ms
5,956 KB
testcase_35 AC 42 ms
5,452 KB
testcase_36 AC 105 ms
8,412 KB
testcase_37 AC 138 ms
8,664 KB
testcase_38 AC 23 ms
4,380 KB
testcase_39 AC 36 ms
5,180 KB
testcase_40 AC 36 ms
5,296 KB
testcase_41 AC 33 ms
5,364 KB
testcase_42 AC 33 ms
5,256 KB
testcase_43 AC 54 ms
8,716 KB
testcase_44 AC 54 ms
8,600 KB
testcase_45 AC 54 ms
8,572 KB
testcase_46 AC 92 ms
7,884 KB
testcase_47 AC 115 ms
8,716 KB
testcase_48 AC 100 ms
8,336 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:49:11: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   49 |       auto[a,b,c]=g[i];
      |           ^
main.cpp:65:9: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   65 |     auto[a,b,c]=g[i];
      |         ^
main.cpp:78:9: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   78 |     auto[now,time]=que.top();
      |         ^

ソースコード

diff #

//g++ 4.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>;

#define fi first
#define se second
#define pb push_back
#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--)

using T = tuple<int,int,ll>;
using P = pair<int,int>;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n,m;
  cin>>n>>m;

  vector<T> g;
  rep(i,0,m){
    int s,t;
    ll d;
    cin>>s>>t>>d;
    s--;t--;
    g.pb({s,t,d});
  }

  ll ng=1e18,ok=0;
  while(ng-ok>1){
    ll check=(ng+ok)/2;
    dsu d(n);
    rep(i,0,m){
      auto[a,b,c]=g[i];
      if(c>=check){
        d.merge(a,b);
      }
    }

    if(d.same(0,n-1)==true){
      ok=check;
    }
    else{
      ng=check;
    }
  }

  vvi graph(n);
  rep(i,0,m){
    auto[a,b,c]=g[i];
    if(c>=ok){
      graph[a].pb(b);
      graph[b].pb(a);
    }
  }

  priority_queue<P,vector<P>,greater<P>> que;
  vi dist(n,1e6);
  que.push({0,0});
  dist[0]=0;

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

    if(time>dist[now])continue;

    for(int next:graph[now]){
      if(dist[next]>dist[now]+1){
        dist[next]=dist[now]+1;
        que.push({next,dist[now]+1});
      }
    }
  }

  cout<<ok<<" "<<dist[n-1]<<endl;
}
0