记录编号 381071 评测结果 AAAAAAAAAA
题目名称 备用交换机 最终得分 100
用户昵称 GravatarkZime 是否通过 通过
代码语言 C++ 运行时间 0.004 s
提交时间 2017-03-10 20:10:38 内存使用 0.32 MiB
显示代码纯文本
/*kZime*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#define MAXN 233
using namespace std;

vector<int>ed[MAXN];
int n, m, low[MAXN], dfn[MAXN],fa[MAXN] , tt;
vector<int> f;
bool is_cut[MAXN];

inline int read() {
	int k = 0;
	char c = getchar();
	for(; !isdigit(c); c = getchar());
	for(; isdigit(c); c = getchar())k = k * 10 + c -'0';
	return k;
}

void tarjan(int a, int father) {
	fa[a] = father;
	low[a] = dfn[a] = ++tt;
	for(int i = 0; i < ed[a].size(); i++) {
		int b = ed[a][i];
		if(!dfn[b]) {
			tarjan(b, a);
			low[a] = min(low[a], low[b]);
		}
		else if(b != fa[a]) {
			low[a] = min (low[a], dfn[b]);
		}
	}
}

int main() {
	freopen("gd.in", "r", stdin);
	freopen("gd.out", "w", stdout);
	n = read();
	int x, y;
	while(scanf("%d%d",&x,&y) == 2) {
		m++;
		ed[x].push_back(y);
		ed[y].push_back(x);
	}
	
	tarjan(1 ,0);
	
	
	for(int i = 1; i <= n; i++) {
		if(low[i] >= dfn[fa[i]]) is_cut[fa[i]] = 1; 
	}
	
	is_cut[1] = 0;
	
	tarjan(2, 0);
	
	for(int i = 1; i <= n; i++) {
		if(fa[i] == 1 && low[i] >= dfn[fa[i]]) {
			is_cut[fa[i]] = 1;
			break;
		}
	}
	
	for(int i = 1; i <= n; i++) {
		if(is_cut[i])f.push_back(i);
	}
	
	printf("%d\n",f.size());
	
	for(int i = 0; i < f.size(); i++) {
		printf("%d\n",f[i]);
	}
	
	return 0;
	
}