結果

問題 No.1254 補強への架け橋
ユーザー kotatsugamekotatsugame
提出日時 2020-10-09 21:45:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 1,336 bytes
コンパイル時間 1,446 ms
コンパイル使用メモリ 80,612 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2023-09-27 16:07:01
合計ジャッジ時間 11,710 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 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 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 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,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 3 ms
4,376 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,376 KB
testcase_53 AC 3 ms
4,376 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 2 ms
4,376 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 2 ms
4,380 KB
testcase_62 AC 2 ms
4,376 KB
testcase_63 AC 9 ms
4,376 KB
testcase_64 AC 3 ms
4,376 KB
testcase_65 AC 6 ms
4,380 KB
testcase_66 AC 5 ms
4,376 KB
testcase_67 AC 3 ms
4,380 KB
testcase_68 AC 6 ms
4,380 KB
testcase_69 AC 7 ms
4,376 KB
testcase_70 AC 4 ms
4,380 KB
testcase_71 AC 3 ms
4,376 KB
testcase_72 AC 6 ms
4,376 KB
testcase_73 AC 4 ms
4,380 KB
testcase_74 AC 6 ms
4,380 KB
testcase_75 AC 5 ms
4,380 KB
testcase_76 AC 2 ms
4,376 KB
testcase_77 AC 4 ms
4,376 KB
testcase_78 AC 8 ms
4,380 KB
testcase_79 AC 8 ms
4,380 KB
testcase_80 AC 8 ms
4,376 KB
testcase_81 AC 8 ms
4,376 KB
testcase_82 AC 7 ms
4,376 KB
testcase_83 AC 87 ms
10,740 KB
testcase_84 AC 89 ms
10,736 KB
testcase_85 AC 55 ms
7,752 KB
testcase_86 AC 72 ms
9,776 KB
testcase_87 AC 79 ms
10,232 KB
testcase_88 AC 12 ms
4,376 KB
testcase_89 AC 93 ms
10,748 KB
testcase_90 AC 54 ms
7,976 KB
testcase_91 AC 42 ms
7,268 KB
testcase_92 AC 22 ms
5,272 KB
testcase_93 AC 65 ms
9,352 KB
testcase_94 AC 59 ms
8,896 KB
testcase_95 AC 58 ms
8,976 KB
testcase_96 AC 86 ms
10,380 KB
testcase_97 AC 35 ms
6,516 KB
testcase_98 AC 81 ms
10,468 KB
testcase_99 AC 48 ms
7,716 KB
testcase_100 AC 90 ms
10,884 KB
testcase_101 AC 20 ms
5,168 KB
testcase_102 AC 10 ms
4,376 KB
testcase_103 AC 21 ms
5,300 KB
testcase_104 AC 28 ms
6,196 KB
testcase_105 AC 66 ms
9,400 KB
testcase_106 AC 38 ms
6,784 KB
testcase_107 AC 88 ms
10,712 KB
testcase_108 AC 84 ms
10,612 KB
testcase_109 AC 65 ms
9,472 KB
testcase_110 AC 61 ms
8,960 KB
testcase_111 AC 64 ms
9,340 KB
testcase_112 AC 28 ms
5,808 KB
testcase_113 AC 55 ms
8,308 KB
testcase_114 AC 37 ms
6,692 KB
testcase_115 AC 13 ms
4,424 KB
testcase_116 AC 46 ms
7,212 KB
testcase_117 AC 28 ms
6,004 KB
testcase_118 AC 80 ms
10,436 KB
testcase_119 AC 47 ms
7,716 KB
testcase_120 AC 79 ms
10,064 KB
testcase_121 AC 24 ms
5,516 KB
testcase_122 AC 42 ms
7,280 KB
testcase_123 AC 2 ms
4,376 KB
testcase_124 AC 119 ms
20,352 KB
testcase_125 AC 125 ms
20,008 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:55:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   55 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
struct bridge{
	vector<int>ord,low;
	vector<bool>art;
	vector<pair<int,int> >bridges;
	vector<vector<int> >G;
	bridge(int n_=0):ord(n_,-1),low(n_),art(n_,false),G(n_){}
	void add_edge(int u,int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bool operator[](int a)const{return art[a];}
	bool is_bridge(int a,int b)const
	{
		if(ord[a]>ord[b])swap(a,b);
		return ord[a]<low[b];
	}
	void dfs(int u,int p,int&k)
	{
		low[u]=ord[u]=k++;
		for(int&v:G[u])
		{
			if(ord[v]==-1)
			{
				dfs(v,u,k);
				low[u]=min(low[u],low[v]);
				art[u]=art[u]|ord[u]<=low[v];
				if(ord[u]<low[v])bridges.push_back(u<v?make_pair(u,v):make_pair(v,u));
			}
			else if(v!=p)
			{
				low[u]=min(low[u],ord[v]);
			}
		}
	}
	void build()
	{
		int k=1,cnt=0;
		low[0]=ord[0]=0;
		for(int&v:G[0])if(ord[v]==-1)
		{
			dfs(v,0,k);
			if(ord[0]<low[v])bridges.push_back(make_pair(0,v));
			cnt++;
		}
		if(cnt>=2)art[0]=true;
	}
};
int N;
int u[1<<17],v[1<<17];
main()
{
	cin>>N;
	bridge P(N);
	for(int i=0;i<N;i++)
	{
		cin>>u[i]>>v[i];
		u[i]--,v[i]--;
		P.add_edge(u[i],v[i]);
	}
	P.build();
	vector<int>ans;
	for(int i=0;i<N;i++)if(!P.is_bridge(u[i],v[i]))ans.push_back(i+1);
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)cout<<ans[i]<<(i+1==ans.size()?"\n":" ");
}
0