結果
問題 | No.1254 補強への架け橋 |
ユーザー | micheeeeell1001 |
提出日時 | 2020-10-09 22:43:58 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,145 bytes |
コンパイル時間 | 2,170 ms |
コンパイル使用メモリ | 217,240 KB |
実行使用メモリ | 24,356 KB |
最終ジャッジ日時 | 2024-07-20 13:09:10 |
合計ジャッジ時間 | 12,690 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 1 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 2 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 2 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | WA | - |
testcase_48 | AC | 2 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 3 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | WA | - |
testcase_55 | AC | 3 ms
5,376 KB |
testcase_56 | AC | 2 ms
5,376 KB |
testcase_57 | AC | 3 ms
5,376 KB |
testcase_58 | AC | 2 ms
5,376 KB |
testcase_59 | AC | 1 ms
5,376 KB |
testcase_60 | AC | 1 ms
5,376 KB |
testcase_61 | AC | 3 ms
5,376 KB |
testcase_62 | WA | - |
testcase_63 | AC | 10 ms
5,376 KB |
testcase_64 | WA | - |
testcase_65 | AC | 6 ms
5,376 KB |
testcase_66 | AC | 5 ms
5,376 KB |
testcase_67 | AC | 3 ms
5,376 KB |
testcase_68 | AC | 5 ms
5,376 KB |
testcase_69 | AC | 7 ms
5,376 KB |
testcase_70 | AC | 4 ms
5,376 KB |
testcase_71 | AC | 3 ms
5,376 KB |
testcase_72 | AC | 6 ms
5,376 KB |
testcase_73 | WA | - |
testcase_74 | AC | 7 ms
5,376 KB |
testcase_75 | WA | - |
testcase_76 | AC | 2 ms
5,376 KB |
testcase_77 | AC | 5 ms
5,376 KB |
testcase_78 | WA | - |
testcase_79 | AC | 9 ms
5,376 KB |
testcase_80 | AC | 7 ms
5,376 KB |
testcase_81 | AC | 9 ms
5,376 KB |
testcase_82 | WA | - |
testcase_83 | AC | 92 ms
15,488 KB |
testcase_84 | WA | - |
testcase_85 | AC | 52 ms
10,752 KB |
testcase_86 | WA | - |
testcase_87 | AC | 89 ms
14,592 KB |
testcase_88 | AC | 12 ms
5,376 KB |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | AC | 44 ms
9,344 KB |
testcase_92 | AC | 23 ms
6,528 KB |
testcase_93 | WA | - |
testcase_94 | AC | 65 ms
12,032 KB |
testcase_95 | AC | 65 ms
12,160 KB |
testcase_96 | AC | 95 ms
14,848 KB |
testcase_97 | AC | 38 ms
8,704 KB |
testcase_98 | WA | - |
testcase_99 | WA | - |
testcase_100 | WA | - |
testcase_101 | AC | 20 ms
6,272 KB |
testcase_102 | AC | 12 ms
5,376 KB |
testcase_103 | WA | - |
testcase_104 | AC | 30 ms
7,680 KB |
testcase_105 | WA | - |
testcase_106 | AC | 39 ms
8,960 KB |
testcase_107 | AC | 97 ms
15,488 KB |
testcase_108 | WA | - |
testcase_109 | AC | 75 ms
12,928 KB |
testcase_110 | WA | - |
testcase_111 | AC | 79 ms
12,544 KB |
testcase_112 | AC | 30 ms
7,552 KB |
testcase_113 | WA | - |
testcase_114 | AC | 40 ms
9,088 KB |
testcase_115 | AC | 14 ms
5,376 KB |
testcase_116 | AC | 46 ms
9,728 KB |
testcase_117 | AC | 29 ms
7,552 KB |
testcase_118 | AC | 94 ms
14,720 KB |
testcase_119 | WA | - |
testcase_120 | AC | 87 ms
14,336 KB |
testcase_121 | AC | 24 ms
6,912 KB |
testcase_122 | WA | - |
testcase_123 | AC | 2 ms
5,376 KB |
testcase_124 | AC | 159 ms
24,356 KB |
testcase_125 | AC | 176 ms
24,224 KB |
ソースコード
#ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include<bits/stdc++.h> using namespace std; #define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++) #define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<ll,ll> Pll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; constexpr ll INF = numeric_limits<ll>::max()/4; constexpr ll n_max = 2e5+10; #define int ll const long double pi = 3.14159265358979323846; template <typename A, typename B> string to_string(pair<A, B> p); string to_string(const string &s) {return '"' + s + '"';} string to_string(const char *c) {return to_string((string) c);} string to_string(bool b) {return (b ? "true" : "false");} template <size_t N> string to_string(bitset<N> v){ string res = ""; for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]); return res; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for(const auto &x : v) { if(!first) res += ", "; first = false; res += to_string(x); } res += "}"; return res; } template <typename A, typename B> string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";} void debug_out() {cerr << endl;} template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif template<class T> bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;} template<class T> bool chmin(T &a, T b){if(a > b){a = b; return true;} return false; } vector<vector<ll>> graph; vector<ll> used; ll pre_dfs(ll now, ll pre = -1) { used[now] = 1; ll ret = -1; for (auto &to : graph[now]) { if (to == pre) continue; if (used[to]) return to; chmax(ret, pre_dfs(to, now)); } return ret; } vector<ll> path; bool dfs(ll s, ll now, ll pre = -1) { used[now] = 1; bool ret = false; for (auto &to : graph[now]) { if (to == pre) continue; if (to == s) { path.emplace_back(now); return true; } if (used[to]) continue; ret |= dfs(s, to, now); if (ret) break; } if (ret) path.emplace_back(now); return ret; } // グラフ中の閉路をpathに入れる // 返り値は閉路があるかどうか // 極小閉路ではないので注意 bool closed_path() { ll n = graph.size(); used.assign(n, 0); ll s = -1; for (int i = 0; i < graph.size(); i++) { if (!used[i]) chmax(s, pre_dfs(i)); } if (s == -1) return false; fill(all(used), 0); dfs(s, s); return true; } void print() { cout << endl; } template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); } template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; } template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll n; cin >> n; graph.resize(n); map<Pll, ll> mp; rep(i, 0, n) { ll u,v; cin >> u >> v; u--; v--; graph[u].emplace_back(v); graph[v].emplace_back(u); if (u > v) swap(u, v); if(mp.count({u, v})){ cout << 2 << "\n"; cout << mp[{u, v}] << " " << i + 1 << "\n"; return 0; } mp[{u, v}] = i + 1; } closed_path(); debug(path); ll m = path.size(); vector<ll> ans; rep(i, 0, m) { ll u = path[i], v = path[(i + 1) % m]; if (u > v) swap(u, v); assert(mp[Pll(u, v)]); ans.emplace_back(mp[{u, v}]); } cout << ans.size() << "\n"; print(ans); }