結果

問題 No.1473 おでぶなおばけさん
ユーザー chocoruskchocorusk
提出日時 2021-04-09 21:41:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,096 bytes
コンパイル時間 3,717 ms
コンパイル使用メモリ 192,120 KB
実行使用メモリ 10,540 KB
最終ジャッジ日時 2023-09-07 10:31:24
合計ジャッジ時間 11,039 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,796 KB
testcase_01 AC 3 ms
5,752 KB
testcase_02 AC 172 ms
10,428 KB
testcase_03 AC 139 ms
9,404 KB
testcase_04 AC 95 ms
8,808 KB
testcase_05 AC 34 ms
6,640 KB
testcase_06 AC 151 ms
9,204 KB
testcase_07 AC 184 ms
10,540 KB
testcase_08 AC 186 ms
10,448 KB
testcase_09 AC 185 ms
10,496 KB
testcase_10 AC 82 ms
6,964 KB
testcase_11 AC 81 ms
7,488 KB
testcase_12 AC 81 ms
7,444 KB
testcase_13 AC 50 ms
6,720 KB
testcase_14 AC 37 ms
6,700 KB
testcase_15 AC 69 ms
7,168 KB
testcase_16 AC 79 ms
7,328 KB
testcase_17 AC 8 ms
6,700 KB
testcase_18 AC 12 ms
6,684 KB
testcase_19 AC 63 ms
7,608 KB
testcase_20 AC 94 ms
8,728 KB
testcase_21 AC 98 ms
8,236 KB
testcase_22 AC 91 ms
9,852 KB
testcase_23 AC 78 ms
9,576 KB
testcase_24 AC 79 ms
9,116 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 151 ms
10,504 KB
testcase_29 AC 105 ms
8,044 KB
testcase_30 AC 131 ms
8,388 KB
testcase_31 AC 142 ms
10,436 KB
testcase_32 AC 114 ms
9,120 KB
testcase_33 AC 98 ms
9,084 KB
testcase_34 AC 54 ms
7,632 KB
testcase_35 AC 54 ms
7,772 KB
testcase_36 AC 95 ms
8,440 KB
testcase_37 AC 109 ms
9,252 KB
testcase_38 AC 23 ms
6,400 KB
testcase_39 AC 81 ms
7,268 KB
testcase_40 AC 80 ms
6,952 KB
testcase_41 AC 70 ms
7,148 KB
testcase_42 AC 70 ms
7,304 KB
testcase_43 AC 94 ms
9,120 KB
testcase_44 AC 94 ms
8,988 KB
testcase_45 AC 94 ms
8,952 KB
testcase_46 AC 134 ms
9,236 KB
testcase_47 AC 162 ms
9,388 KB
testcase_48 AC 142 ms
9,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
struct unionfind{
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int main()
{
    int n; cin>>n;
    int m; cin>>m;
    int a[100010], b[100010], d[100010];
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i]>>d[i];
        a[i]--; b[i]--;
    }
    int l=0, r=1e9;
    while(r-l>1){
        int mid=(l+r)/2;
        unionfind uf(n);
        for(int i=0; i<m; i++){
            if(d[i]>=mid) uf.unite(a[i], b[i]); 
        }
        if(uf.same(0, n-1)) l=mid;
        else r=mid;
    }
    cout<<l<<" ";
    int e[100010];
    const int INF=1e9;
    fill(e, e+n, INF);
    e[0]=0;
    queue<int> que; que.push(0);
    vector<int> g[100010];
    for(int i=0; i<m; i++){
        if(d[i]>=l){
            g[a[i]].push_back(b[i]);
            g[b[i]].push_back(a[i]);
        }
    }
    while(!que.empty()){
        int x=que.front(); que.pop();
        for(auto y:g[x]){
            if(e[y]>e[x]+1){
                e[y]=e[x]+1;
                que.push(y);
            }
        }
    }
    cout<<e[n-1]<<endl;
    return 0;
}
0