結果
問題 | No.1254 補強への架け橋 |
ユーザー | kenta255 |
提出日時 | 2020-10-10 11:08:58 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 185 ms / 2,000 ms |
コード長 | 2,563 bytes |
コンパイル時間 | 2,632 ms |
コンパイル使用メモリ | 221,312 KB |
実行使用メモリ | 21,208 KB |
最終ジャッジ日時 | 2024-07-20 15:44:34 |
合計ジャッジ時間 | 15,948 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 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 | 2 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 | 3 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 | 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 | 2 ms
5,376 KB |
testcase_32 | AC | 3 ms
5,376 KB |
testcase_33 | AC | 3 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 | 3 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 3 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 3 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 3 ms
5,376 KB |
testcase_51 | AC | 3 ms
5,376 KB |
testcase_52 | AC | 3 ms
5,376 KB |
testcase_53 | AC | 3 ms
5,376 KB |
testcase_54 | AC | 3 ms
5,376 KB |
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 | 3 ms
5,376 KB |
testcase_59 | AC | 2 ms
5,376 KB |
testcase_60 | AC | 3 ms
5,376 KB |
testcase_61 | AC | 2 ms
5,376 KB |
testcase_62 | AC | 2 ms
5,376 KB |
testcase_63 | AC | 13 ms
5,376 KB |
testcase_64 | AC | 5 ms
5,376 KB |
testcase_65 | AC | 9 ms
5,376 KB |
testcase_66 | AC | 8 ms
5,376 KB |
testcase_67 | AC | 4 ms
5,376 KB |
testcase_68 | AC | 8 ms
5,376 KB |
testcase_69 | AC | 10 ms
5,376 KB |
testcase_70 | AC | 5 ms
5,376 KB |
testcase_71 | AC | 5 ms
5,376 KB |
testcase_72 | AC | 10 ms
5,376 KB |
testcase_73 | AC | 5 ms
5,376 KB |
testcase_74 | AC | 10 ms
5,376 KB |
testcase_75 | AC | 8 ms
5,376 KB |
testcase_76 | AC | 4 ms
5,376 KB |
testcase_77 | AC | 7 ms
5,376 KB |
testcase_78 | AC | 12 ms
5,376 KB |
testcase_79 | AC | 13 ms
5,376 KB |
testcase_80 | AC | 10 ms
5,376 KB |
testcase_81 | AC | 12 ms
5,376 KB |
testcase_82 | AC | 11 ms
5,376 KB |
testcase_83 | AC | 170 ms
15,328 KB |
testcase_84 | AC | 164 ms
14,960 KB |
testcase_85 | AC | 92 ms
10,612 KB |
testcase_86 | AC | 136 ms
13,568 KB |
testcase_87 | AC | 150 ms
14,384 KB |
testcase_88 | AC | 19 ms
5,376 KB |
testcase_89 | AC | 161 ms
15,164 KB |
testcase_90 | AC | 98 ms
10,984 KB |
testcase_91 | AC | 78 ms
9,340 KB |
testcase_92 | AC | 37 ms
6,528 KB |
testcase_93 | AC | 127 ms
13,056 KB |
testcase_94 | AC | 111 ms
12,056 KB |
testcase_95 | AC | 110 ms
12,044 KB |
testcase_96 | AC | 159 ms
14,592 KB |
testcase_97 | AC | 64 ms
8,540 KB |
testcase_98 | AC | 158 ms
14,716 KB |
testcase_99 | AC | 85 ms
10,276 KB |
testcase_100 | AC | 185 ms
15,536 KB |
testcase_101 | AC | 32 ms
6,272 KB |
testcase_102 | AC | 17 ms
5,376 KB |
testcase_103 | AC | 35 ms
6,528 KB |
testcase_104 | AC | 52 ms
7,756 KB |
testcase_105 | AC | 131 ms
13,000 KB |
testcase_106 | AC | 67 ms
8,960 KB |
testcase_107 | AC | 168 ms
15,172 KB |
testcase_108 | AC | 158 ms
15,116 KB |
testcase_109 | AC | 124 ms
12,832 KB |
testcase_110 | AC | 109 ms
12,012 KB |
testcase_111 | AC | 121 ms
12,736 KB |
testcase_112 | AC | 46 ms
7,420 KB |
testcase_113 | AC | 105 ms
11,572 KB |
testcase_114 | AC | 63 ms
8,900 KB |
testcase_115 | AC | 20 ms
5,376 KB |
testcase_116 | AC | 76 ms
9,680 KB |
testcase_117 | AC | 47 ms
7,684 KB |
testcase_118 | AC | 149 ms
14,508 KB |
testcase_119 | AC | 85 ms
10,240 KB |
testcase_120 | AC | 145 ms
14,188 KB |
testcase_121 | AC | 40 ms
6,784 KB |
testcase_122 | AC | 75 ms
9,644 KB |
testcase_123 | AC | 2 ms
5,376 KB |
testcase_124 | AC | 135 ms
21,208 KB |
testcase_125 | AC | 137 ms
21,204 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll,ll> #define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I) #define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I) #define TO(x,t,f) ((x)?(t):(f)) #define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v x is sorted #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v x is sorted #define NUM(x,v) (POSU(x,v)-POSL(x,v)) //x is sorted #define REV(x) (reverse(x.begin(),x.end())) //reverse ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);} ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);} #define NEXTP(x) next_permutation(x.begin(),x.end()) const ll INF=ll(1e16)+ll(7); const ll MOD=1000000007LL; #define out(a) cout<<fixed<<setprecision((a)) //tie(a,b,c) = make_tuple(10,9,87); #define pop_(a) __builtin_popcount((a)) ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;} struct Articulation_point_and_Bridge{ int V,E=0; vector< vector<int> > G; vector<int> ord,low; vector<bool> vis; vector< pair<int, int> > bridge; vector<int> articulation; Articulation_point_and_Bridge(int V_){ V=V_; G.resize(V); ord.resize(V,0); low.resize(V,0); vis.resize(V,false); } void dfs(int v, int p, int &k){ vis[v] = true; ord[v] = k++; low[v] = ord[v]; bool isArticulation = false; int ct = 0; for (int i = 0; i < G[v].size(); i++){ if (!vis[G[v][i]]){ ct++; dfs(G[v][i], v, k); low[v] = min(low[v], low[G[v][i]]); if (~p && ord[v] <= low[G[v][i]]) isArticulation = true; if (ord[v] < low[G[v][i]]) bridge.push_back(make_pair(min(v, G[v][i]), max(v, G[v][i]))); } else if (G[v][i] != p){ low[v] = min(low[v], ord[G[v][i]]); } } if (p == -1 && ct > 1) isArticulation = true; if (isArticulation) articulation.push_back(v); } void add_edge(int v1,int v2){ G[v1].push_back(v2); G[v2].push_back(v1); E++; } void calc(){ int k=0; for(int i=0;i<V;i++){ if(!vis[i])dfs(i,-1,k); } //sort(bridge.begin(), bridge.end()); //sort(articulation.begin(), articulation.end()); } }; int main(){ ll N; cin >> N; Articulation_point_and_Bridge g(N); vector<pair<int,int>> all_b; FOR(i,0,N){ ll a,b; cin >> a >> b; if(a>b)swap(a,b); g.add_edge(a-1,b-1); all_b.push_back({a-1,b-1}); } g.calc(); set<pair<int,int>> br; FOR(i,0,g.bridge.size()){ br.insert(g.bridge[i]); } cout << N-g.bridge.size() << endl; bool s = false; FOR(i,0,N){ if(not br.count(all_b[i])){ if(s)cout << " "; cout << i+1; s = true; } } }