結果
問題 | No.1254 補強への架け橋 |
ユーザー | tanimani364 |
提出日時 | 2021-03-30 15:14:04 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 126 ms / 2,000 ms |
コード長 | 3,283 bytes |
コンパイル時間 | 2,258 ms |
コンパイル使用メモリ | 219,132 KB |
実行使用メモリ | 27,008 KB |
最終ジャッジ日時 | 2024-05-07 18:36:18 |
合計ジャッジ時間 | 14,849 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 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 | 1 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 1 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 | 1 ms
5,376 KB |
testcase_21 | AC | 2 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 | 1 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 1 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 1 ms
5,376 KB |
testcase_31 | AC | 2 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 | 1 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 | 1 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 | AC | 2 ms
5,376 KB |
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 | 2 ms
5,376 KB |
testcase_52 | AC | 3 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | AC | 3 ms
5,376 KB |
testcase_56 | AC | 2 ms
5,376 KB |
testcase_57 | AC | 2 ms
5,376 KB |
testcase_58 | AC | 3 ms
5,376 KB |
testcase_59 | AC | 2 ms
5,376 KB |
testcase_60 | AC | 2 ms
5,376 KB |
testcase_61 | AC | 2 ms
5,376 KB |
testcase_62 | AC | 2 ms
5,376 KB |
testcase_63 | AC | 10 ms
5,376 KB |
testcase_64 | AC | 4 ms
5,376 KB |
testcase_65 | AC | 7 ms
5,376 KB |
testcase_66 | AC | 6 ms
5,376 KB |
testcase_67 | AC | 3 ms
5,376 KB |
testcase_68 | AC | 6 ms
5,376 KB |
testcase_69 | AC | 7 ms
5,376 KB |
testcase_70 | AC | 4 ms
5,376 KB |
testcase_71 | AC | 4 ms
5,376 KB |
testcase_72 | AC | 7 ms
5,376 KB |
testcase_73 | AC | 4 ms
5,376 KB |
testcase_74 | AC | 7 ms
5,376 KB |
testcase_75 | AC | 5 ms
5,376 KB |
testcase_76 | AC | 3 ms
5,376 KB |
testcase_77 | AC | 5 ms
5,376 KB |
testcase_78 | AC | 8 ms
5,376 KB |
testcase_79 | AC | 9 ms
5,376 KB |
testcase_80 | AC | 9 ms
5,376 KB |
testcase_81 | AC | 9 ms
5,376 KB |
testcase_82 | AC | 9 ms
5,376 KB |
testcase_83 | AC | 124 ms
16,712 KB |
testcase_84 | AC | 114 ms
16,496 KB |
testcase_85 | AC | 61 ms
11,392 KB |
testcase_86 | AC | 94 ms
14,812 KB |
testcase_87 | AC | 106 ms
15,612 KB |
testcase_88 | AC | 13 ms
5,376 KB |
testcase_89 | AC | 121 ms
16,800 KB |
testcase_90 | AC | 65 ms
11,776 KB |
testcase_91 | AC | 49 ms
10,172 KB |
testcase_92 | AC | 26 ms
7,040 KB |
testcase_93 | AC | 91 ms
14,456 KB |
testcase_94 | AC | 77 ms
13,360 KB |
testcase_95 | AC | 76 ms
13,272 KB |
testcase_96 | AC | 110 ms
15,956 KB |
testcase_97 | AC | 42 ms
9,116 KB |
testcase_98 | AC | 111 ms
16,320 KB |
testcase_99 | AC | 58 ms
11,088 KB |
testcase_100 | AC | 121 ms
16,948 KB |
testcase_101 | AC | 22 ms
6,784 KB |
testcase_102 | AC | 11 ms
5,376 KB |
testcase_103 | AC | 23 ms
6,912 KB |
testcase_104 | AC | 33 ms
8,448 KB |
testcase_105 | AC | 86 ms
14,340 KB |
testcase_106 | AC | 46 ms
9,728 KB |
testcase_107 | AC | 119 ms
16,816 KB |
testcase_108 | AC | 116 ms
16,200 KB |
testcase_109 | AC | 90 ms
13,908 KB |
testcase_110 | AC | 78 ms
13,248 KB |
testcase_111 | AC | 81 ms
13,992 KB |
testcase_112 | AC | 32 ms
7,936 KB |
testcase_113 | AC | 70 ms
12,428 KB |
testcase_114 | AC | 42 ms
9,472 KB |
testcase_115 | AC | 14 ms
5,504 KB |
testcase_116 | AC | 51 ms
10,376 KB |
testcase_117 | AC | 33 ms
8,064 KB |
testcase_118 | AC | 110 ms
15,988 KB |
testcase_119 | AC | 55 ms
11,008 KB |
testcase_120 | AC | 101 ms
15,500 KB |
testcase_121 | AC | 27 ms
7,296 KB |
testcase_122 | AC | 50 ms
10,368 KB |
testcase_123 | AC | 1 ms
5,376 KB |
testcase_124 | AC | 126 ms
27,008 KB |
testcase_125 | AC | 114 ms
27,008 KB |
ソースコード
#include <bits/stdc++.h> //#include<boost/multiprecision/cpp_int.hpp> //#include<boost/multiprecision/cpp_dec_float.hpp> //#include <atcoder/all> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i) #define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define popcount __builtin_popcount #define fi first #define se second using ll = long long; constexpr ll mod = 1e9 + 7; constexpr ll mod_998244353 = 998244353; constexpr ll INF = 1LL << 60; // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") //using lll=boost::multiprecision::cpp_int; //using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;//仮数部が1024桁 template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> T mypow(T x, T n, const T &p = -1) { //x^nをmodで割った余り if (p != -1) { x %= p; } T ret = 1; while (n > 0) { if (n & 1) { if (p != -1) ret = (ret * x) % p; else ret *= x; } if (p != -1) x = (x * x) % p; else x *= x; n >>= 1; } return ret; } using namespace std; //using namespace atcoder; template< typename G > struct LowLink { const G &g; vector< int > used, ord, low; vector< int > articulation; vector< pair< int, int > > bridge; LowLink(const G &g) : g(g) {} int dfs(int idx, int k, int par) { used[idx] = true; ord[idx] = k++; low[idx] = ord[idx]; bool is_articulation = false; int cnt = 0; for(auto &to : g[idx]) { if(!used[to]) { ++cnt; k = dfs(to, k, idx); low[idx] = min(low[idx], low[to]); is_articulation |= ~par && low[to] >= ord[idx]; if(ord[idx] < low[to]) bridge.emplace_back(minmax(idx, (int) to)); } else if(to != par) { low[idx] = min(low[idx], ord[to]); } } is_articulation |= par == -1 && cnt > 1; if(is_articulation) articulation.push_back(idx); return k; } virtual void build() { used.assign(g.size(), 0); ord.assign(g.size(), 0); low.assign(g.size(), 0); int k = 0; for(int i = 0; i < g.size(); i++) { if(!used[i]) k = dfs(i, k, -1); } } }; using P=pair<int,int>; void solve() { int n; cin>>n; vector<vector<int>>g(n); map<pair<int,int>,int>mp; rep(i,n){ int a,b; cin>>a>>b; a--;b--; g[a].eb(b); g[b].eb(a); if(a>b)swap(a,b); mp[P{a,b}]=i+1; } LowLink<vector<vector<int>>>lowlink(g); lowlink.build(); for(auto e:lowlink.bridge){ if(e.first>e.second)swap(e.fi,e.se); mp.erase(P(e.first,e.second)); } int ans=mp.size(); cout<<ans<<"\n"; for(auto itr=mp.begin();itr!=mp.end();++itr){ if(itr!=mp.begin())cout<<" "; cout<<itr->second; } cout<<"\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); solve(); return 0; }