#include<iostream>
using namespace std;
#define MAX 100
int T,N;
int a[101][101];
bool kt[101]={false};
int ans;
void go(int x)
{
for(int i = 0; i < 100; i++)
{
if(a[x][i]==1 && kt[i]==false)
if(i==99)
ans= 1;
else{
kt[i] = true;
go(i);
}
}
}
int main()
{
freopen("input.txt","r",stdin);
int x, y;
for(int tc = 1; tc <=10; tc++)
{
cin >> T;
cin >> N;
//cout << N << endl;
for(int i = 0; i< 100; i++)
{
for(int j = 0; j<100; j++)
{
a[i][j] = 0;
}
}
for(int i = 0; i< 100; i++)
{
kt[i]= false;
}
for( int i = 0; i< N; i++)
{
cin>>x>>y;
a[x][y]=1;
}
ans = 0;
go(0);
cout <<"#"<<tc<<" "<< ans << endl;
}
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.