結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | GGanari |
提出日時 | 2024-03-22 14:18:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 2,154 bytes |
コンパイル時間 | 3,583 ms |
コンパイル使用メモリ | 235,240 KB |
実行使用メモリ | 10,772 KB |
最終ジャッジ日時 | 2024-03-22 14:19:00 |
合計ジャッジ時間 | 8,910 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
6,676 KB |
testcase_01 | AC | 4 ms
6,676 KB |
testcase_02 | AC | 124 ms
10,388 KB |
testcase_03 | AC | 91 ms
9,364 KB |
testcase_04 | AC | 67 ms
8,596 KB |
testcase_05 | AC | 25 ms
6,868 KB |
testcase_06 | AC | 98 ms
9,364 KB |
testcase_07 | AC | 128 ms
10,772 KB |
testcase_08 | AC | 130 ms
10,772 KB |
testcase_09 | AC | 131 ms
10,772 KB |
testcase_10 | AC | 36 ms
7,700 KB |
testcase_11 | AC | 35 ms
7,700 KB |
testcase_12 | AC | 35 ms
7,700 KB |
testcase_13 | AC | 24 ms
7,700 KB |
testcase_14 | AC | 18 ms
6,868 KB |
testcase_15 | AC | 32 ms
7,700 KB |
testcase_16 | AC | 35 ms
7,700 KB |
testcase_17 | AC | 7 ms
6,676 KB |
testcase_18 | AC | 8 ms
6,676 KB |
testcase_19 | AC | 34 ms
7,700 KB |
testcase_20 | AC | 57 ms
8,980 KB |
testcase_21 | AC | 57 ms
8,212 KB |
testcase_22 | AC | 50 ms
10,004 KB |
testcase_23 | AC | 42 ms
9,620 KB |
testcase_24 | AC | 43 ms
9,364 KB |
testcase_25 | AC | 116 ms
9,876 KB |
testcase_26 | AC | 127 ms
9,876 KB |
testcase_27 | AC | 39 ms
7,444 KB |
testcase_28 | AC | 98 ms
10,644 KB |
testcase_29 | AC | 60 ms
8,212 KB |
testcase_30 | AC | 79 ms
8,596 KB |
testcase_31 | AC | 95 ms
10,644 KB |
testcase_32 | AC | 65 ms
9,364 KB |
testcase_33 | AC | 77 ms
8,980 KB |
testcase_34 | AC | 34 ms
7,700 KB |
testcase_35 | AC | 32 ms
7,444 KB |
testcase_36 | AC | 59 ms
8,596 KB |
testcase_37 | AC | 66 ms
9,364 KB |
testcase_38 | AC | 16 ms
6,740 KB |
testcase_39 | AC | 35 ms
7,700 KB |
testcase_40 | AC | 35 ms
7,700 KB |
testcase_41 | AC | 32 ms
7,700 KB |
testcase_42 | AC | 33 ms
7,700 KB |
testcase_43 | AC | 45 ms
9,492 KB |
testcase_44 | AC | 45 ms
9,492 KB |
testcase_45 | AC | 45 ms
9,492 KB |
testcase_46 | AC | 86 ms
9,108 KB |
testcase_47 | AC | 107 ms
9,620 KB |
testcase_48 | AC | 91 ms
9,492 KB |
ソースコード
#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2") #include <bits/stdc++.h> #define INF 1000000001LL #define LNF 1000000000000000001LL #define MOD 1000000007LL #define MAX 502 #define long long long #define all(x) x.begin(),x.end() using namespace std; vector<pair<int,pair<int,int>>> edge; vector<int> graph[100001]; vector<int> parent(100001); int find(int x) { if(parent[x] == x) return x; return parent[x] = find(parent[x]); } bool merge(int x, int y) { x = find(x); y = find(y); if(x == y) return 1; if(x < y) parent[y] = x; else parent[x] = y; return 0; } int check(int n,int x) { for(int i = 0; i<=n; i++) parent[i] = i; for(int i = 0; i<edge.size(); i++) { int d = edge[i].first; int u = edge[i].second.first; int v = edge[i].second.second; if(d >= x) merge(u,v); } return merge(1,n); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,m; cin >> n >> m; for(int i = 0; i<m; i++) { int a,b,c; cin >> a >> b >> c; edge.push_back({c,{a,b}}); } int start = 0; int end = INF; int res = 0; while(start<=end) { int mid = (start+end)/2; if(check(n,mid)) { start = mid+1; res = mid; } else end = mid-1; } for(int i = 0; i<m; i++) { if(edge[i].first >= res) { int a = edge[i].second.first; int b = edge[i].second.second; graph[a].push_back(b); graph[b].push_back(a); } } vector<int> vis(n+1,-1); queue<int> q; q.push(1); vis[1] = 0; int mx = 0; while(!q.empty()) { int x = q.front(); q.pop(); mx = max(mx,vis[x]); for(int y : graph[x]) { if(vis[y] != -1) continue; vis[y] = vis[x]+1; q.push(y); } } cout << res << " " << vis[n] << endl; return 0; }