记录编号 |
367678 |
评测结果 |
AAAAAAAAAA |
题目名称 |
备用交换机 |
最终得分 |
100 |
用户昵称 |
sxysxy |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.002 s |
提交时间 |
2017-02-01 13:03:13 |
内存使用 |
0.50 MiB |
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#include <cctype>
using namespace std;
namespace IO{
char buf[1<<18], *fs, *ft;
inline char readc(){
return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<18,stdin)),fs==ft)?EOF:*fs++;
}
inline int readint(){
int r;char c;
while(c = readc()){
if(c >= '0' && c <= '9'){
r = c^0x30;break;
}else if(!(~c))return EOF;
}
while(isdigit(c = readc()))r = (r<<3)+(r<<1)+(c^0x30);
return r;
}
};using IO::readint;
vector<int> G[102];
int dfn[102], low[102], fa[102], cd[102], tim;
bool cut[102];
inline void addedge(int u, int v){
G[u].push_back(v); G[v].push_back(u);
}
void tarjan(int u){
dfn[u] = low[u] = ++tim;
for(int i = 0; i < G[u].size(); i++){
int v = G[u][i];
if(!dfn[v]){
fa[v] = u;
cd[u]++;
tarjan(v);
low[u] = min(low[u], low[v]);
}else{
low[u] = min(low[u], dfn[v]);
}
}
if(!fa[u] && cd[u] >= 2)cut[u] = true;
if(fa[fa[u]] && low[u] >= dfn[fa[u]])cut[fa[u]] = true;
}
int main(){
freopen("gd.in", "r", stdin);
freopen("gd.out", "w", stdout);
int n = readint();
while(true){
int x = readint();
int y = readint();
if(x == EOF || y == EOF)break;
addedge(x, y);
}
vector<int> ans;
for(int i = 1; i <= n; i++)if(!dfn[i])tarjan(i);
for(int i = 1; i <= n; i++)if(cut[i])ans.push_back(i);
printf("%d\n", ans.size());
for(int i = 0; i < ans.size(); i++)printf("%d\n", ans[i]);
return 0;
}