比赛 |
20120808 |
评测结果 |
AAAAAAAAAA |
题目名称 |
晨跑路径 |
最终得分 |
100 |
用户昵称 |
Truth.Cirno |
运行时间 |
0.210 s |
代码语言 |
C++ |
内存使用 |
15.57 MiB |
提交时间 |
2012-08-08 09:13:37 |
显示代码纯文本
#include <cstdio>
using namespace std;
int n,una,tarnum[2001],tar[2001][2001];
bool found;
void find()
{
int i,tail=0,head=0,que[2001]={1};
bool used[2001]={0,1};
found=false;
while (!found&&tail<=head)
{
for (i=0;i<tarnum[que[tail]];i++)
if (!used[tar[que[tail]][i]]&&tar[que[tail]][i]!=una)
{
if (tar[que[tail]][i]==n)
{
found=true;
break;
}
else
{
que[++head]=tar[que[tail]][i];
used[tar[que[tail]][i]]=true;
}
}
tail++;
}
}
int main(void)
{
freopen("running.in","r",stdin);
freopen("running.out","w",stdout);
int i,e,x,y,recnum=0,rec[2001];
scanf("%d%d",&n,&e);
for (i=1;i<=e;i++)
{
scanf("%d%d",&x,&y);
tar[x][tarnum[x]++]=y;
tar[y][tarnum[y]++]=x;
}
for (una=2;una<n;una++)
{
find();
if (!found)
rec[recnum++]=una;
}
printf("%d\n",recnum);
x=0;
for (i=0;i<recnum;i++)
{
if (x)
printf(" ");
else
x=1;
printf("%d",rec[i]);
}
printf("\n");
return(0);
}