Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不知何故wa 求指教 万分感谢#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator