sicily 1155. Can I Post the lette
#include <iostream> //求顶点1到n是否可达
#include<stdio.h>
#include<cstring>
using namespace std;
int n,m,edge[200][200];
int seq[50000],vis[50000];
int main()
{
while(scanf("%d",&n),n)
{
memset(edge,0,sizeof(edge));
memset(vis,0,sizeof(vis));
int s,t;
scanf("%d",&m);
while(m--)
{
scanf("%d%d",&s,&t);
edge[s][t]=1;
}
seq[0]=0;
int fro=0,rear=1,suc=0;
while(fro<rear)
{
int v=seq[fro++];
for(int i=0;i<n;++i)
{
if(vis[i]==0&&edge[v][i]==1)
{
vis[i]=1;
seq[rear++]=i;
if(i==n-1)
{
suc=1;
break;
}
}
}
if(suc==1)
break;
}
if(suc==1)
printf("I can post the letter\n");
else
printf("I can't post the letter\n");
}
return 0;
}