結果
問題 | No.1254 補強への架け橋 |
ユーザー | yuto1115 |
提出日時 | 2020-10-09 22:49:31 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 224 ms / 2,000 ms |
コード長 | 3,120 bytes |
コンパイル時間 | 2,504 ms |
コンパイル使用メモリ | 221,180 KB |
実行使用メモリ | 33,664 KB |
最終ジャッジ日時 | 2024-07-20 13:16:37 |
合計ジャッジ時間 | 16,817 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 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,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 3 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,944 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,944 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,944 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 2 ms
6,940 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,944 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,940 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,944 KB |
testcase_42 | AC | 2 ms
6,944 KB |
testcase_43 | AC | 3 ms
6,944 KB |
testcase_44 | AC | 3 ms
6,940 KB |
testcase_45 | AC | 2 ms
6,944 KB |
testcase_46 | AC | 3 ms
6,944 KB |
testcase_47 | AC | 2 ms
6,948 KB |
testcase_48 | AC | 3 ms
6,940 KB |
testcase_49 | AC | 2 ms
6,940 KB |
testcase_50 | AC | 3 ms
6,944 KB |
testcase_51 | AC | 3 ms
6,940 KB |
testcase_52 | AC | 3 ms
6,944 KB |
testcase_53 | AC | 2 ms
6,940 KB |
testcase_54 | AC | 3 ms
6,940 KB |
testcase_55 | AC | 3 ms
6,944 KB |
testcase_56 | AC | 3 ms
6,944 KB |
testcase_57 | AC | 2 ms
6,944 KB |
testcase_58 | AC | 2 ms
6,944 KB |
testcase_59 | AC | 2 ms
6,944 KB |
testcase_60 | AC | 2 ms
6,944 KB |
testcase_61 | AC | 3 ms
6,944 KB |
testcase_62 | AC | 2 ms
6,944 KB |
testcase_63 | AC | 15 ms
6,944 KB |
testcase_64 | AC | 5 ms
6,944 KB |
testcase_65 | AC | 9 ms
6,944 KB |
testcase_66 | AC | 8 ms
6,940 KB |
testcase_67 | AC | 5 ms
6,940 KB |
testcase_68 | AC | 8 ms
6,940 KB |
testcase_69 | AC | 10 ms
6,940 KB |
testcase_70 | AC | 6 ms
6,944 KB |
testcase_71 | AC | 4 ms
6,940 KB |
testcase_72 | AC | 11 ms
6,940 KB |
testcase_73 | AC | 5 ms
6,940 KB |
testcase_74 | AC | 10 ms
6,944 KB |
testcase_75 | AC | 8 ms
6,940 KB |
testcase_76 | AC | 3 ms
6,944 KB |
testcase_77 | AC | 7 ms
6,940 KB |
testcase_78 | AC | 13 ms
6,940 KB |
testcase_79 | AC | 14 ms
6,940 KB |
testcase_80 | AC | 12 ms
6,940 KB |
testcase_81 | AC | 13 ms
6,944 KB |
testcase_82 | AC | 13 ms
6,944 KB |
testcase_83 | AC | 212 ms
21,496 KB |
testcase_84 | AC | 209 ms
20,884 KB |
testcase_85 | AC | 109 ms
14,296 KB |
testcase_86 | AC | 171 ms
18,720 KB |
testcase_87 | AC | 183 ms
20,204 KB |
testcase_88 | AC | 20 ms
6,940 KB |
testcase_89 | AC | 209 ms
21,544 KB |
testcase_90 | AC | 116 ms
14,720 KB |
testcase_91 | AC | 89 ms
12,544 KB |
testcase_92 | AC | 41 ms
8,192 KB |
testcase_93 | AC | 152 ms
18,216 KB |
testcase_94 | AC | 134 ms
16,960 KB |
testcase_95 | AC | 131 ms
16,664 KB |
testcase_96 | AC | 195 ms
20,460 KB |
testcase_97 | AC | 71 ms
11,264 KB |
testcase_98 | AC | 192 ms
20,688 KB |
testcase_99 | AC | 97 ms
13,888 KB |
testcase_100 | AC | 209 ms
21,820 KB |
testcase_101 | AC | 34 ms
7,808 KB |
testcase_102 | AC | 18 ms
6,944 KB |
testcase_103 | AC | 38 ms
8,192 KB |
testcase_104 | AC | 57 ms
10,240 KB |
testcase_105 | AC | 155 ms
18,172 KB |
testcase_106 | AC | 84 ms
11,900 KB |
testcase_107 | AC | 224 ms
21,444 KB |
testcase_108 | AC | 203 ms
21,012 KB |
testcase_109 | AC | 156 ms
17,808 KB |
testcase_110 | AC | 137 ms
16,800 KB |
testcase_111 | AC | 150 ms
17,532 KB |
testcase_112 | AC | 52 ms
9,600 KB |
testcase_113 | AC | 128 ms
15,828 KB |
testcase_114 | AC | 76 ms
11,644 KB |
testcase_115 | AC | 23 ms
6,940 KB |
testcase_116 | AC | 85 ms
12,928 KB |
testcase_117 | AC | 51 ms
9,856 KB |
testcase_118 | AC | 190 ms
20,464 KB |
testcase_119 | AC | 98 ms
13,696 KB |
testcase_120 | AC | 191 ms
19,772 KB |
testcase_121 | AC | 46 ms
8,704 KB |
testcase_122 | AC | 87 ms
12,800 KB |
testcase_123 | AC | 2 ms
6,940 KB |
testcase_124 | AC | 193 ms
33,536 KB |
testcase_125 | AC | 194 ms
33,664 KB |
ソースコード
//@formatter:off #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 rep2(i,s,n) for (int i = int(s); i < int(n); ++i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back #define vi vector<int> #define vvi vector<vector<int>> #define vl vector<ll> #define vvl vector<vector<ll>> #define vd vector<double> #define vvd vector<vector<double>> #define vs vector<string> #define vc vector<char> #define vvc vector<vector<char>> #define vb vector<bool> #define vvb vector<vector<bool>> #define vp vector<P> #define vvp vector<vector<P>> using namespace std; using ll = long long; using P = pair<int,int>; using LP = pair<ll,ll>; template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; } template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; } template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; } template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; } void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; } void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; } template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;} template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;} const int inf = 1001001001; const ll linf = 1001001001001001001; //@formatter:on class lowlink { vvi G; vi ord, low; int dfs(int v, int p, int k) { ord[v] = low[v] = k++; bool flag = false; int cnt = 0; for (int u : G[v]) { if (ord[u] < 0) { cnt++; k = dfs(u, v, k); chmin(low[v], low[u]); flag |= p >= 0 and ord[v] <= low[u]; if (ord[v] < low[u]) bridge.eb(v, u); } else if (u != p) { chmin(low[v], ord[u]); } } flag |= p < 0 and cnt > 1; if (flag) articulation.pb(v); return k; } void init() { ord.assign(G.size(), -1); low.assign(G.size(), -1); int k = 0; rep(i, G.size()) { if (ord[i] < 0) k = dfs(i, -1, k); } } public: vi articulation; vp bridge; lowlink(vvi &G) : G(G) { init(); } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vvi G(n); map<P, int> mp; rep(i, n) { int a, b; cin >> a >> b; a--; b--; mp[{a, b}] = i+1; G[a].pb(b); G[b].pb(a); } lowlink lk(G); for (auto p : lk.bridge) { if (mp.count(p)) mp.erase(p); swap(p.first, p.second); if (mp.count(p)) mp.erase(p); } cout << mp.size() << '\n'; for (auto p : mp) { cout << p.second << ' '; } cout << endl; }