結果
問題 | No.1254 補強への架け橋 |
ユーザー | gyouzasushi |
提出日時 | 2024-05-31 16:08:54 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 315 ms / 2,000 ms |
コード長 | 3,472 bytes |
コンパイル時間 | 2,873 ms |
コンパイル使用メモリ | 218,824 KB |
実行使用メモリ | 28,164 KB |
最終ジャッジ日時 | 2024-12-20 21:59:56 |
合計ジャッジ時間 | 19,330 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 3 ms
6,816 KB |
testcase_04 | AC | 2 ms
6,820 KB |
testcase_05 | AC | 2 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,816 KB |
testcase_07 | AC | 2 ms
6,820 KB |
testcase_08 | AC | 2 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 2 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,820 KB |
testcase_12 | AC | 2 ms
6,820 KB |
testcase_13 | AC | 2 ms
6,816 KB |
testcase_14 | AC | 2 ms
6,820 KB |
testcase_15 | AC | 2 ms
6,820 KB |
testcase_16 | AC | 2 ms
6,816 KB |
testcase_17 | AC | 2 ms
6,816 KB |
testcase_18 | AC | 2 ms
6,816 KB |
testcase_19 | AC | 2 ms
6,816 KB |
testcase_20 | AC | 2 ms
6,820 KB |
testcase_21 | AC | 2 ms
6,820 KB |
testcase_22 | AC | 2 ms
6,820 KB |
testcase_23 | AC | 2 ms
6,820 KB |
testcase_24 | AC | 2 ms
6,816 KB |
testcase_25 | AC | 2 ms
6,820 KB |
testcase_26 | AC | 2 ms
6,820 KB |
testcase_27 | AC | 2 ms
6,820 KB |
testcase_28 | AC | 2 ms
6,816 KB |
testcase_29 | AC | 2 ms
6,820 KB |
testcase_30 | AC | 2 ms
6,816 KB |
testcase_31 | AC | 2 ms
6,820 KB |
testcase_32 | AC | 2 ms
6,816 KB |
testcase_33 | AC | 2 ms
6,820 KB |
testcase_34 | AC | 2 ms
6,816 KB |
testcase_35 | AC | 2 ms
6,816 KB |
testcase_36 | AC | 2 ms
6,816 KB |
testcase_37 | AC | 2 ms
6,820 KB |
testcase_38 | AC | 2 ms
6,816 KB |
testcase_39 | AC | 2 ms
6,820 KB |
testcase_40 | AC | 2 ms
6,816 KB |
testcase_41 | AC | 2 ms
6,816 KB |
testcase_42 | AC | 2 ms
6,820 KB |
testcase_43 | AC | 3 ms
6,816 KB |
testcase_44 | AC | 2 ms
6,820 KB |
testcase_45 | AC | 2 ms
6,816 KB |
testcase_46 | AC | 3 ms
6,820 KB |
testcase_47 | AC | 2 ms
6,820 KB |
testcase_48 | AC | 2 ms
6,816 KB |
testcase_49 | AC | 3 ms
6,820 KB |
testcase_50 | AC | 3 ms
6,816 KB |
testcase_51 | AC | 3 ms
6,820 KB |
testcase_52 | AC | 3 ms
6,816 KB |
testcase_53 | AC | 3 ms
6,820 KB |
testcase_54 | AC | 3 ms
6,816 KB |
testcase_55 | AC | 3 ms
6,820 KB |
testcase_56 | AC | 2 ms
6,816 KB |
testcase_57 | AC | 3 ms
6,816 KB |
testcase_58 | AC | 3 ms
6,816 KB |
testcase_59 | AC | 2 ms
6,820 KB |
testcase_60 | AC | 2 ms
6,816 KB |
testcase_61 | AC | 3 ms
6,816 KB |
testcase_62 | AC | 2 ms
6,820 KB |
testcase_63 | AC | 16 ms
6,820 KB |
testcase_64 | AC | 5 ms
6,820 KB |
testcase_65 | AC | 11 ms
6,816 KB |
testcase_66 | AC | 9 ms
6,820 KB |
testcase_67 | AC | 5 ms
6,816 KB |
testcase_68 | AC | 9 ms
6,816 KB |
testcase_69 | AC | 12 ms
6,816 KB |
testcase_70 | AC | 6 ms
6,816 KB |
testcase_71 | AC | 5 ms
6,816 KB |
testcase_72 | AC | 13 ms
6,816 KB |
testcase_73 | AC | 6 ms
6,816 KB |
testcase_74 | AC | 13 ms
6,820 KB |
testcase_75 | AC | 9 ms
6,820 KB |
testcase_76 | AC | 4 ms
6,820 KB |
testcase_77 | AC | 8 ms
6,816 KB |
testcase_78 | AC | 15 ms
6,816 KB |
testcase_79 | AC | 15 ms
6,820 KB |
testcase_80 | AC | 14 ms
6,816 KB |
testcase_81 | AC | 15 ms
6,820 KB |
testcase_82 | AC | 14 ms
6,816 KB |
testcase_83 | AC | 202 ms
20,480 KB |
testcase_84 | AC | 207 ms
20,096 KB |
testcase_85 | AC | 110 ms
13,824 KB |
testcase_86 | AC | 171 ms
17,920 KB |
testcase_87 | AC | 177 ms
19,328 KB |
testcase_88 | AC | 25 ms
6,820 KB |
testcase_89 | AC | 210 ms
20,352 KB |
testcase_90 | AC | 118 ms
14,336 KB |
testcase_91 | AC | 92 ms
12,032 KB |
testcase_92 | AC | 46 ms
7,936 KB |
testcase_93 | AC | 150 ms
17,152 KB |
testcase_94 | AC | 140 ms
15,744 KB |
testcase_95 | AC | 135 ms
15,872 KB |
testcase_96 | AC | 191 ms
19,584 KB |
testcase_97 | AC | 79 ms
10,752 KB |
testcase_98 | AC | 189 ms
19,688 KB |
testcase_99 | AC | 104 ms
13,312 KB |
testcase_100 | AC | 206 ms
20,992 KB |
testcase_101 | AC | 39 ms
7,296 KB |
testcase_102 | AC | 20 ms
6,820 KB |
testcase_103 | AC | 44 ms
7,936 KB |
testcase_104 | AC | 62 ms
9,600 KB |
testcase_105 | AC | 159 ms
17,024 KB |
testcase_106 | AC | 84 ms
11,392 KB |
testcase_107 | AC | 199 ms
20,352 KB |
testcase_108 | AC | 213 ms
20,096 KB |
testcase_109 | AC | 151 ms
17,024 KB |
testcase_110 | AC | 131 ms
15,616 KB |
testcase_111 | AC | 148 ms
16,512 KB |
testcase_112 | AC | 58 ms
9,216 KB |
testcase_113 | AC | 130 ms
15,360 KB |
testcase_114 | AC | 86 ms
11,136 KB |
testcase_115 | AC | 26 ms
6,820 KB |
testcase_116 | AC | 96 ms
12,544 KB |
testcase_117 | AC | 59 ms
9,344 KB |
testcase_118 | AC | 182 ms
19,456 KB |
testcase_119 | AC | 102 ms
13,184 KB |
testcase_120 | AC | 193 ms
18,944 KB |
testcase_121 | AC | 50 ms
8,448 KB |
testcase_122 | AC | 92 ms
12,288 KB |
testcase_123 | AC | 2 ms
6,820 KB |
testcase_124 | AC | 306 ms
28,164 KB |
testcase_125 | AC | 315 ms
28,116 KB |
ソースコード
#line 1 "main.cpp" #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) using namespace std; using ll = long long; constexpr int INF = 1e9; constexpr ll LINF = 1e18; string YesNo(bool cond) { return cond ? "Yes" : "No"; } string YESNO(bool cond) { return cond ? "YES" : "NO"; } template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; } template <typename T, class F> T bisect(T ok, T ng, const F& f) { while (abs(ok - ng) > 1) { T mid = min(ok, ng) + (abs(ok - ng) >> 1); (f(mid) ? ok : ng) = mid; } return ok; } template <typename T, class F> T bisect_double(T ok, T ng, const F& f, int iter = 100) { while (iter--) { T mid = (ok + ng) / 2; (f(mid) ? ok : ng) = mid; } return ok; } template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } template <typename T> istream& operator>>(istream& is, vector<T>& v) { for (int i = 0; i < int(v.size()); i++) { is >> v[i]; } return is; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { for (int i = 0; i < int(v.size()); i++) { os << v[i]; if (i < sz(v) - 1) os << ' '; } return os; } #line 2 "/Users/gyouzasushi/kyopro/library/graph/functional_graph.hpp" #line 5 "/Users/gyouzasushi/kyopro/library/graph/functional_graph.hpp" struct functional_graph { public: functional_graph(int n) : _n(n), graph(n) { } void add_edge(int u, int v) { graph[u].push_back(v); graph[v].push_back(u); } void add_directed_edge(int from, int to) { graph[from].push_back(to); } std::vector<int> loop() { std::vector<int> path; std::vector<int> check(_n, 0); auto dfs = [&](auto dfs, int u, int p) -> int { check[u]++; path.push_back(u); for (int v : graph[u]) { if (v == p) continue; if (check[v] == 0) { int ret = dfs(dfs, v, u); if (ret != -1) return ret; } else if (check[v] == 1) { return v; } } path.pop_back(); check[u]++; return -1; }; std::vector<int>::iterator it = std::find(path.begin(), path.end(), dfs(dfs, 0, -1)); return std::vector(it, path.end()); } std::vector<std::vector<std::vector<int>>> tree() { return {}; } private: int _n; std::vector<std::vector<int>> graph; }; #line 73 "main.cpp" int main() { int n; cin >> n; functional_graph g(n); map<pair<int, int>, int> id; rep(i, n) { int a, b; cin >> a >> b; g.add_edge(--a, --b); id[{a, b}] = id[{b, a}] = i; } vector loop = g.loop(); int k = sz(loop); cout << k << '\n'; rep(i, k) { int u = loop[i]; int v = loop[(i + 1) % k]; cout << id[{u, v}] + 1 << " \n"[i == k - 1]; } }