結果

問題 No.1473 おでぶなおばけさん
ユーザー umezoumezo
提出日時 2021-04-09 23:06:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,296 bytes
コンパイル時間 2,462 ms
コンパイル使用メモリ 218,492 KB
実行使用メモリ 13,524 KB
最終ジャッジ日時 2023-09-07 12:51:05
合計ジャッジ時間 19,368 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 762 ms
12,336 KB
testcase_03 AC 436 ms
10,132 KB
testcase_04 AC 448 ms
8,272 KB
testcase_05 AC 131 ms
5,136 KB
testcase_06 AC 547 ms
10,728 KB
testcase_07 AC 781 ms
13,372 KB
testcase_08 AC 997 ms
13,524 KB
testcase_09 AC 803 ms
13,156 KB
testcase_10 AC 84 ms
6,412 KB
testcase_11 AC 83 ms
7,340 KB
testcase_12 AC 85 ms
6,752 KB
testcase_13 AC 51 ms
5,480 KB
testcase_14 AC 37 ms
5,168 KB
testcase_15 AC 69 ms
6,524 KB
testcase_16 AC 81 ms
6,156 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 94 ms
5,528 KB
testcase_20 AC 235 ms
9,600 KB
testcase_21 AC 206 ms
8,916 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,020 ms
11,872 KB
testcase_26 AC 1,053 ms
12,408 KB
testcase_27 AC 206 ms
6,948 KB
testcase_28 AC 762 ms
13,168 KB
testcase_29 AC 324 ms
11,712 KB
testcase_30 AC 523 ms
12,588 KB
testcase_31 AC 493 ms
13,064 KB
testcase_32 AC 310 ms
10,724 KB
testcase_33 AC 277 ms
9,760 KB
testcase_34 AC 155 ms
6,952 KB
testcase_35 AC 95 ms
5,636 KB
testcase_36 AC 299 ms
10,264 KB
testcase_37 AC 434 ms
10,460 KB
testcase_38 AC 63 ms
5,100 KB
testcase_39 AC 83 ms
6,388 KB
testcase_40 AC 84 ms
6,396 KB
testcase_41 AC 72 ms
6,100 KB
testcase_42 AC 71 ms
6,156 KB
testcase_43 AC 214 ms
10,596 KB
testcase_44 AC 209 ms
10,648 KB
testcase_45 AC 216 ms
10,496 KB
testcase_46 AC 445 ms
10,076 KB
testcase_47 AC 584 ms
11,880 KB
testcase_48 AC 538 ms
11,344 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 ll INF=1LL<<60;

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;
  int ok=1,ng=1e9+1;
  while(ng-ok>1){
    int 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