結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | 👑 Nachia |
提出日時 | 2021-04-09 21:50:39 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,151 bytes |
コンパイル時間 | 4,653 ms |
コンパイル使用メモリ | 214,392 KB |
実行使用メモリ | 11,516 KB |
最終ジャッジ日時 | 2023-09-07 10:53:29 |
合計ジャッジ時間 | 12,117 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
8,760 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 300 ms
10,688 KB |
testcase_03 | AC | 107 ms
8,900 KB |
testcase_04 | AC | 76 ms
7,628 KB |
testcase_05 | AC | 40 ms
4,412 KB |
testcase_06 | AC | 155 ms
8,948 KB |
testcase_07 | AC | 148 ms
11,516 KB |
testcase_08 | AC | 154 ms
11,472 KB |
testcase_09 | AC | 151 ms
11,420 KB |
testcase_10 | AC | 87 ms
4,400 KB |
testcase_11 | AC | 86 ms
4,376 KB |
testcase_12 | AC | 87 ms
4,376 KB |
testcase_13 | AC | 54 ms
4,380 KB |
testcase_14 | AC | 40 ms
4,380 KB |
testcase_15 | AC | 74 ms
4,380 KB |
testcase_16 | AC | 85 ms
4,384 KB |
testcase_17 | AC | 7 ms
4,380 KB |
testcase_18 | AC | 11 ms
4,376 KB |
testcase_19 | AC | 73 ms
4,904 KB |
testcase_20 | AC | 88 ms
8,320 KB |
testcase_21 | AC | 273 ms
6,488 KB |
testcase_22 | AC | 1,674 ms
10,008 KB |
testcase_23 | AC | 112 ms
9,468 KB |
testcase_24 | AC | 546 ms
8,836 KB |
testcase_25 | TLE | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; #define rep(i,n) for(int i=0; i<(n); i++) struct DSU{ vector<int> V; DSU(int n=0){ V.resize(n); rep(i,n) V[i]=i; } int leader(int a){ return (V[a]==a)?a:(a=leader(V[a])); } void merge(int u,int v){ V[leader(u)]=leader(v); } }; struct Edge{ int u,v,w; }; bool compEdge_w(Edge l, Edge r){ return l.w>r.w; } int N,M; vector<Edge> edges; vector<vector<int>> E; DSU dsu; vector<int> D; int main(){ cin>>N>>M; edges.resize(M); rep(i,M){ int u,v,w; cin>>u>>v>>w; u--; v--; edges[i]={u,v,w}; } sort(edges.begin(),edges.end(),compEdge_w); E.resize(N); dsu = DSU(N); int W=1001001001; for(Edge e:edges){ dsu.merge(e.u,e.v); E[e.u].push_back(e.v); E[e.v].push_back(e.u); W = e.w; if(dsu.leader(0) == dsu.leader(N-1)) break; } for(Edge e:edges) if(e.w>=W){ E[e.u].push_back(e.v); E[e.v].push_back(e.u); } D.assign(N,-1); queue<int> Q; D[0]=0; Q.push(0); while(Q.size()){ int p=Q.front(); Q.pop(); for(int e:E[p]) if(D[e]==-1){ D[e] = D[p]+1; Q.push(e); } } cout<<W<<" "<<D[N-1]<<"\n"; return 0; }