結果
問題 | No.1254 補強への架け橋 |
ユーザー | srjywrdnprkt |
提出日時 | 2023-12-23 18:06:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 2,282 bytes |
コンパイル時間 | 2,700 ms |
コンパイル使用メモリ | 217,528 KB |
実行使用メモリ | 25,672 KB |
最終ジャッジ日時 | 2024-09-27 12:31:16 |
合計ジャッジ時間 | 15,249 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 2 ms
6,944 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,944 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | AC | 2 ms
6,944 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | AC | 2 ms
6,944 KB |
testcase_40 | AC | 2 ms
6,944 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,944 KB |
testcase_43 | AC | 2 ms
6,940 KB |
testcase_44 | AC | 2 ms
6,940 KB |
testcase_45 | AC | 2 ms
6,940 KB |
testcase_46 | AC | 2 ms
6,940 KB |
testcase_47 | AC | 2 ms
6,944 KB |
testcase_48 | AC | 2 ms
6,944 KB |
testcase_49 | AC | 2 ms
6,940 KB |
testcase_50 | AC | 2 ms
6,940 KB |
testcase_51 | AC | 2 ms
6,944 KB |
testcase_52 | AC | 2 ms
6,944 KB |
testcase_53 | AC | 2 ms
6,944 KB |
testcase_54 | AC | 2 ms
6,940 KB |
testcase_55 | AC | 3 ms
6,940 KB |
testcase_56 | AC | 2 ms
6,940 KB |
testcase_57 | AC | 2 ms
6,940 KB |
testcase_58 | AC | 2 ms
6,940 KB |
testcase_59 | AC | 2 ms
6,944 KB |
testcase_60 | AC | 2 ms
6,940 KB |
testcase_61 | AC | 2 ms
6,944 KB |
testcase_62 | AC | 2 ms
6,940 KB |
testcase_63 | AC | 8 ms
6,940 KB |
testcase_64 | AC | 3 ms
6,944 KB |
testcase_65 | AC | 5 ms
6,944 KB |
testcase_66 | AC | 5 ms
6,944 KB |
testcase_67 | AC | 3 ms
6,944 KB |
testcase_68 | AC | 5 ms
6,940 KB |
testcase_69 | AC | 6 ms
6,940 KB |
testcase_70 | AC | 4 ms
6,940 KB |
testcase_71 | AC | 3 ms
6,940 KB |
testcase_72 | AC | 6 ms
6,940 KB |
testcase_73 | AC | 3 ms
6,944 KB |
testcase_74 | AC | 5 ms
6,940 KB |
testcase_75 | AC | 5 ms
6,940 KB |
testcase_76 | AC | 3 ms
6,940 KB |
testcase_77 | AC | 5 ms
6,940 KB |
testcase_78 | AC | 7 ms
6,940 KB |
testcase_79 | AC | 7 ms
6,940 KB |
testcase_80 | AC | 6 ms
6,944 KB |
testcase_81 | AC | 8 ms
6,940 KB |
testcase_82 | AC | 7 ms
6,940 KB |
testcase_83 | AC | 96 ms
16,492 KB |
testcase_84 | AC | 91 ms
16,788 KB |
testcase_85 | AC | 44 ms
11,112 KB |
testcase_86 | AC | 69 ms
15,708 KB |
testcase_87 | AC | 81 ms
15,904 KB |
testcase_88 | AC | 11 ms
6,940 KB |
testcase_89 | AC | 87 ms
16,264 KB |
testcase_90 | AC | 49 ms
11,616 KB |
testcase_91 | AC | 37 ms
9,980 KB |
testcase_92 | AC | 18 ms
6,944 KB |
testcase_93 | AC | 67 ms
16,012 KB |
testcase_94 | AC | 59 ms
14,940 KB |
testcase_95 | AC | 62 ms
14,928 KB |
testcase_96 | AC | 85 ms
16,060 KB |
testcase_97 | AC | 30 ms
9,172 KB |
testcase_98 | AC | 85 ms
16,008 KB |
testcase_99 | AC | 47 ms
10,940 KB |
testcase_100 | AC | 88 ms
17,024 KB |
testcase_101 | AC | 16 ms
6,944 KB |
testcase_102 | AC | 9 ms
6,940 KB |
testcase_103 | AC | 18 ms
6,940 KB |
testcase_104 | AC | 25 ms
8,752 KB |
testcase_105 | AC | 72 ms
14,988 KB |
testcase_106 | AC | 35 ms
9,596 KB |
testcase_107 | AC | 99 ms
17,076 KB |
testcase_108 | AC | 92 ms
16,204 KB |
testcase_109 | AC | 69 ms
15,432 KB |
testcase_110 | AC | 61 ms
14,352 KB |
testcase_111 | AC | 63 ms
15,636 KB |
testcase_112 | AC | 23 ms
7,608 KB |
testcase_113 | AC | 54 ms
12,280 KB |
testcase_114 | AC | 32 ms
9,492 KB |
testcase_115 | AC | 11 ms
6,944 KB |
testcase_116 | AC | 38 ms
10,148 KB |
testcase_117 | AC | 24 ms
8,780 KB |
testcase_118 | AC | 88 ms
15,808 KB |
testcase_119 | AC | 42 ms
10,616 KB |
testcase_120 | AC | 88 ms
15,648 KB |
testcase_121 | AC | 20 ms
7,148 KB |
testcase_122 | AC | 37 ms
9,936 KB |
testcase_123 | AC | 2 ms
6,940 KB |
testcase_124 | AC | 118 ms
25,644 KB |
testcase_125 | AC | 118 ms
25,672 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, A, B; cin >> N; vector<vector<pair<int, int>>> E(N); for (int i=0; i<N; i++){ cin >> A >> B; A--; B--; E[A].push_back({B, i}); E[B].push_back({A, i}); } vector<int> in(N, -1), low(N), tour, ancestor(N); vector<bool> double_edge(N); auto lowlink=[&](auto self, int from, int p)->void{ in[from] = tour.size(); low[from] = tour.size(); tour.push_back(from); ancestor[from] = p; for (auto [to, _] : E[from]){ if (to == p){ if (double_edge[from]) low[from] = min(low[from], in[to]); else double_edge[from]=1; continue; } if (in[to] != -1){ if (in[to] > in[from]) continue; low[from] = min(low[from], in[to]); //後退辺(子孫->祖先)を遡る } else self(self, to, from); } }; lowlink(lowlink, 0, -1); for (int i=N-1; i>=0; i--){ int x = tour[i]; for (auto [y, _] : E[x]){ if (y == ancestor[x]) continue; low[x] = min(low[x], low[y]); } } //二重辺連結成分分解(two edge connected component) vector<vector<int>> tecc_groups; vector<int> _tecc, bridge, roots={0}; vector<int> tecc_idx(N, -1); //頂点iの含まれる成分の番号 auto tecc=[&](auto self, int from)->void{ _tecc.push_back(from); tecc_idx[from] = tecc_groups.size(); for (auto [to, idx] : E[from]){ if (tecc_idx[to] != -1) continue; if (low[to] > in[from]){ bridge.push_back(idx); roots.push_back(to); } else self(self, to); } }; while(!roots.empty()){ int root = roots.back(); roots.pop_back(); tecc(tecc, root); tecc_groups.push_back(_tecc); _tecc.clear(); } vector<bool> ok(N, 1); for (auto x : bridge) ok[x] = 0; cout << N-bridge.size() << endl; for (int i=0; i<N; i++) if (ok[i]) cout << i+1 << " "; cout << endl; return 0; }