結果

問題 No.1473 おでぶなおばけさん
ユーザー umezoumezo
提出日時 2021-04-09 23:18:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,018 ms / 2,000 ms
コード長 1,294 bytes
コンパイル時間 2,271 ms
コンパイル使用メモリ 218,032 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2023-09-07 13:07:11
合計ジャッジ時間 18,763 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 685 ms
12,324 KB
testcase_03 AC 428 ms
10,132 KB
testcase_04 AC 432 ms
8,156 KB
testcase_05 AC 132 ms
5,064 KB
testcase_06 AC 547 ms
10,636 KB
testcase_07 AC 796 ms
13,440 KB
testcase_08 AC 988 ms
13,412 KB
testcase_09 AC 752 ms
13,132 KB
testcase_10 AC 81 ms
6,776 KB
testcase_11 AC 83 ms
7,372 KB
testcase_12 AC 81 ms
6,868 KB
testcase_13 AC 47 ms
5,484 KB
testcase_14 AC 37 ms
4,956 KB
testcase_15 AC 68 ms
6,508 KB
testcase_16 AC 80 ms
6,340 KB
testcase_17 AC 8 ms
4,384 KB
testcase_18 AC 12 ms
4,376 KB
testcase_19 AC 99 ms
5,612 KB
testcase_20 AC 236 ms
9,596 KB
testcase_21 AC 203 ms
8,932 KB
testcase_22 AC 106 ms
12,024 KB
testcase_23 AC 91 ms
10,396 KB
testcase_24 AC 88 ms
10,368 KB
testcase_25 AC 987 ms
12,020 KB
testcase_26 AC 1,018 ms
12,200 KB
testcase_27 AC 195 ms
6,972 KB
testcase_28 AC 626 ms
13,252 KB
testcase_29 AC 301 ms
11,492 KB
testcase_30 AC 493 ms
12,540 KB
testcase_31 AC 491 ms
12,912 KB
testcase_32 AC 308 ms
10,804 KB
testcase_33 AC 267 ms
9,568 KB
testcase_34 AC 161 ms
6,880 KB
testcase_35 AC 100 ms
5,708 KB
testcase_36 AC 272 ms
10,248 KB
testcase_37 AC 434 ms
10,456 KB
testcase_38 AC 61 ms
5,156 KB
testcase_39 AC 84 ms
6,580 KB
testcase_40 AC 79 ms
6,356 KB
testcase_41 AC 70 ms
5,984 KB
testcase_42 AC 68 ms
6,044 KB
testcase_43 AC 211 ms
10,648 KB
testcase_44 AC 214 ms
10,512 KB
testcase_45 AC 211 ms
10,664 KB
testcase_46 AC 449 ms
10,204 KB
testcase_47 AC 535 ms
11,760 KB
testcase_48 AC 496 ms
11,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

const int INF=1e9+10;

struct Edge{
  int to;
  ll w;
  Edge(int to,ll w) : to(to),w(w) {}
};

using Graph=vector<vector<Edge>>;
using pli=pair<ll,int>;

template<class T> bool chmin(T& a,T b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> S(m),T(m),D(m);
  rep(i,m){
    cin>>S[i]>>T[i]>>D[i];
    S[i]--,T[i]--;
  }
  
  map<ll,ll> ma;
  ll ok=0,ng=1e9+7;
  while(ng-ok>1){
    ll mid=(ok+ng)/2;
    
    Graph G(n);
    rep(i,m){
      if(D[i]<mid) continue;
      G[S[i]].push_back(Edge(T[i],1));
      G[T[i]].push_back(Edge(S[i],1));
    }
  
    vector<ll> dist(n,INF);
    int s=0;
    dist[s]=0;
  
    priority_queue<pli,vector<pli>,greater<pli>> que;
    que.push({dist[s],s});
  
    while(!que.empty()){
      int v=que.top().second;
      ll d=que.top().first;
      que.pop();
    
      if(d>dist[v]) continue;
    
      for(auto e:G[v]){
        if(chmin(dist[e.to],dist[v]+e.w)){
          que.push({dist[e.to],e.to});
        }
      }
    }
    ma[mid]=dist[n-1];
    if(dist[n-1]==INF) ng=mid;
    else ok=mid;
  }
  cout<<ok<<" "<<ma[ok]<<endl;

  return 0;
}
0