結果

問題 No.1254 補強への架け橋
ユーザー chocoruskchocorusk
提出日時 2020-10-09 21:51:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 2,097 bytes
コンパイル時間 1,689 ms
コンパイル使用メモリ 145,668 KB
実行使用メモリ 27,620 KB
最終ジャッジ日時 2023-09-27 16:26:22
合計ジャッジ時間 13,368 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 3 ms
4,376 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 2 ms
4,504 KB
testcase_59 AC 2 ms
4,376 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 2 ms
4,380 KB
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 16 ms
5,484 KB
testcase_64 AC 5 ms
4,380 KB
testcase_65 AC 10 ms
4,620 KB
testcase_66 AC 8 ms
4,600 KB
testcase_67 AC 4 ms
4,376 KB
testcase_68 AC 9 ms
4,504 KB
testcase_69 AC 11 ms
4,696 KB
testcase_70 AC 6 ms
4,380 KB
testcase_71 AC 4 ms
4,380 KB
testcase_72 AC 11 ms
4,900 KB
testcase_73 AC 5 ms
4,380 KB
testcase_74 AC 10 ms
4,700 KB
testcase_75 AC 9 ms
4,504 KB
testcase_76 AC 3 ms
4,376 KB
testcase_77 AC 7 ms
4,492 KB
testcase_78 AC 14 ms
5,160 KB
testcase_79 AC 14 ms
5,160 KB
testcase_80 AC 11 ms
4,828 KB
testcase_81 AC 14 ms
5,380 KB
testcase_82 AC 13 ms
4,952 KB
testcase_83 AC 179 ms
24,760 KB
testcase_84 AC 173 ms
24,400 KB
testcase_85 AC 99 ms
16,280 KB
testcase_86 AC 143 ms
21,668 KB
testcase_87 AC 170 ms
23,004 KB
testcase_88 AC 23 ms
6,560 KB
testcase_89 AC 180 ms
24,748 KB
testcase_90 AC 107 ms
16,960 KB
testcase_91 AC 79 ms
13,976 KB
testcase_92 AC 41 ms
8,916 KB
testcase_93 AC 139 ms
20,456 KB
testcase_94 AC 124 ms
18,764 KB
testcase_95 AC 121 ms
18,716 KB
testcase_96 AC 166 ms
23,532 KB
testcase_97 AC 68 ms
12,512 KB
testcase_98 AC 173 ms
23,656 KB
testcase_99 AC 97 ms
15,728 KB
testcase_100 AC 180 ms
25,368 KB
testcase_101 AC 36 ms
8,260 KB
testcase_102 AC 19 ms
5,956 KB
testcase_103 AC 41 ms
8,920 KB
testcase_104 AC 55 ms
11,092 KB
testcase_105 AC 137 ms
20,616 KB
testcase_106 AC 77 ms
13,496 KB
testcase_107 AC 184 ms
24,820 KB
testcase_108 AC 173 ms
24,324 KB
testcase_109 AC 137 ms
20,496 KB
testcase_110 AC 122 ms
18,784 KB
testcase_111 AC 132 ms
19,720 KB
testcase_112 AC 57 ms
10,748 KB
testcase_113 AC 119 ms
18,260 KB
testcase_114 AC 74 ms
13,112 KB
testcase_115 AC 23 ms
6,748 KB
testcase_116 AC 85 ms
14,628 KB
testcase_117 AC 54 ms
10,704 KB
testcase_118 AC 169 ms
23,380 KB
testcase_119 AC 97 ms
15,732 KB
testcase_120 AC 174 ms
22,756 KB
testcase_121 AC 45 ms
9,488 KB
testcase_122 AC 84 ms
14,424 KB
testcase_123 AC 2 ms
4,380 KB
testcase_124 AC 115 ms
27,620 KB
testcase_125 AC 110 ms
27,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct TwoEdgeConnectedComponent{
	int n, k;
	vector<vector<int>> g, t;
	vector<bool> used;
	vector<int> comp, ord, low;
	using edge=pair<int, int>;
	vector<edge> br;
	void dfs(int x, int prev, int &c){
		used[x]=1;
		ord[x]=c++;
		low[x]=n;
		bool mul=0;
		for(auto y:g[x]){
			if(used[y]){
				if(y!=prev || mul) low[x]=min(low[x], ord[y]);
				else mul=1;
				continue;
			}
			dfs(y, x, c);
			low[x]=min(low[x], low[y]);
		}
	}
	void dfs2(int x, int num){
		comp[x]=num;
		for(auto y:g[x]){
			if(comp[y]!=-1) continue;
			if(ord[x]<low[y]){
				br.push_back({x, y});
				k++;
				dfs2(y, k);
			}else dfs2(y, num);
		}
	}
	TwoEdgeConnectedComponent(const vector<vector<int>> &g):g(g), n(g.size()), used(n), comp(n, -1), ord(n), low(n), k(0){
		int c=0;
		for(int i=0; i<n; i++){
			if(used[i]) continue;
			dfs(i, -1, c);
			dfs2(i, k);
			k++;
		}
	}
	void maketree(){
		t.resize(k);
		for(auto e:br){
			int x=comp[e.first], y=comp[e.second];
			t[x].push_back(y);
			t[y].push_back(x);
		}
	}
};
int main()
{
	int n; cin>>n;
	vector<vector<int>> g(n);
	int a[200020], b[200020];
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	TwoEdgeConnectedComponent myon(g);
	set<P> st;
	for(auto p:myon.br){
		st.insert(p);
		st.insert({p.second, p.first});
	}
	vector<int> ans;
	for(int i=0; i<n; i++){
		if(st.find({a[i], b[i]})==st.end()) ans.push_back(i);
	}
	cout<<ans.size()<<endl;
	for(auto x:ans) cout<<x+1<<" ";
	cout<<endl;
	return 0;
}

0