Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

不知何故wa 求指教 万分感谢

Posted by mimichess at 2011-12-26 16:40:17 on Problem 1139
#include<iostream>
using namespace std;

struct ROOM
{
	int cat,mouse;
};
ROOM room[101][101];
int cr,mr,n,tag1,tag2;

void floy()
{
	int i,j,k;
	for(k=1;k<=n;k++)
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
				if(!room[i][j].cat&&room[i][k].cat&&room[k][j].cat)
					room[i][j].cat=1;
			}
			for(i=1;i<=n;i++)
				cout<<room[cr][i].cat;
			    cout<<endl;
	for(k=1;k<=n;k++)
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
				if(!room[i][j].mouse&&room[i][k].mouse&&room[k][j].mouse)
				{
					if(room[cr][k].cat==1||room[cr][j].cat==1)
						tag1=1;
					else room[i][j].mouse=1;
				}
				
			}
	for(i=1;i<=n;i++)
		cout<<room[mr][i].mouse;
	cout<<endl;
	if(room[mr][mr].mouse)tag2=1;
	
}
int main()
{
	int N;
	cin>>N;
	while(N--)
	{
		tag1=0;tag2=0;
		memset(room,0,sizeof(room));
		int a,b;
		cin>>n>>cr>>mr;
		while(cin>>a>>b&&a!=-1)
			room[a][b].cat=1;
		while(cin>>a>>b&&a!=-1)
			room[a][b].mouse=1;
		floy();
		if(tag1)cout<<"Y ";
		else cout<<"N ";
		if(tag2)cout<<"Y"<<endl;
		else cout<<"N"<<endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator