結果

問題 No.1473 おでぶなおばけさん
ユーザー abc3abc3
提出日時 2021-04-10 03:35:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 1,445 bytes
コンパイル時間 3,449 ms
コンパイル使用メモリ 207,424 KB
実行使用メモリ 11,552 KB
最終ジャッジ日時 2023-09-07 23:22:03
合計ジャッジ時間 11,859 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 197 ms
11,212 KB
testcase_03 AC 146 ms
10,328 KB
testcase_04 AC 115 ms
7,824 KB
testcase_05 AC 43 ms
4,612 KB
testcase_06 AC 202 ms
10,756 KB
testcase_07 AC 194 ms
11,416 KB
testcase_08 AC 277 ms
11,552 KB
testcase_09 AC 182 ms
11,364 KB
testcase_10 AC 89 ms
7,280 KB
testcase_11 AC 91 ms
8,836 KB
testcase_12 AC 90 ms
8,172 KB
testcase_13 AC 53 ms
6,268 KB
testcase_14 AC 39 ms
5,180 KB
testcase_15 AC 76 ms
7,572 KB
testcase_16 AC 84 ms
6,812 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 82 ms
7,504 KB
testcase_20 AC 109 ms
9,376 KB
testcase_21 AC 131 ms
9,340 KB
testcase_22 AC 108 ms
10,312 KB
testcase_23 AC 85 ms
9,656 KB
testcase_24 AC 87 ms
9,572 KB
testcase_25 AC 246 ms
10,600 KB
testcase_26 AC 255 ms
10,488 KB
testcase_27 AC 65 ms
5,844 KB
testcase_28 AC 232 ms
11,208 KB
testcase_29 AC 141 ms
9,148 KB
testcase_30 AC 188 ms
10,296 KB
testcase_31 AC 178 ms
11,404 KB
testcase_32 AC 157 ms
10,792 KB
testcase_33 AC 119 ms
9,384 KB
testcase_34 AC 63 ms
6,412 KB
testcase_35 AC 64 ms
6,636 KB
testcase_36 AC 113 ms
8,228 KB
testcase_37 AC 144 ms
9,156 KB
testcase_38 AC 25 ms
4,428 KB
testcase_39 AC 85 ms
6,724 KB
testcase_40 AC 86 ms
6,728 KB
testcase_41 AC 76 ms
6,328 KB
testcase_42 AC 76 ms
6,328 KB
testcase_43 AC 95 ms
9,136 KB
testcase_44 AC 96 ms
8,940 KB
testcase_45 AC 97 ms
9,068 KB
testcase_46 AC 122 ms
8,968 KB
testcase_47 AC 174 ms
10,184 KB
testcase_48 AC 147 ms
9,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<int,int>;
    const ll INF=1e18;
    const int mod=1e9+7;
    
    struct edge{
      int to;
      ll w;
      edge(int to,ll w):to(to),w(w){}
    };
    int main(){
      ll n,m;
      cin>>n>>m;
      vector<vector<edge>>G(n);
      rep(i,m){
        int s,t,d;
        cin>>s>>t>>d;
        s--;t--;
        G[s].push_back(edge(t,d));
        G[t].push_back(edge(s,d));
      }
      auto f=[&](ll W){
        vector<ll>dist(n,INF);
        dist[0]=0;
        queue<ll>q;
        q.push(0);
        while(!q.empty()){
          auto p=q.front();q.pop();
          for(auto u:G[p]){
            if(dist[u.to]==INF&&u.w>=W){
              q.push(u.to);
              dist[u.to]=dist[p]+1;
            }
          }
        }
        return dist[n-1];
      };
      ll l=0,r=1e9+5;
      ll len=INF;
      while(r-l>1){
        ll mid=(l+r)/2;
        ll dist=f(mid);
        if(dist!=INF){l=mid;len=dist;}
        else{r=mid;}
      }
      cout<<l<<" "<<len<<endl;
      return 0;
    }
0