## 1433: [ZJOI2009]假期的宿舍

Time Limit: 10 Sec  Memory Limit: 162 MB
Submit: 2375  Solved: 1005
[Submit][Status][Discuss]

1
3
1 1 0
0 1 0
0 1 1
1 0 0
1 0 0

ˆ ˆ

## Source

[Submit][Status][Discuss]

-----------------------------------------------------------------


#include<cstdio>
#include<iostream>
#include<cstring>
#define cls(x) memset(x,0,sizeof(x))
#define For(i,x,y) for(int i=x;i<=y;++i)
#define N 55
using namespace std;
int a[N],b[N],map[N][N];
int p[5*N];
int vis[N*5];int n;
bool find(int u)
{
For(i,1,n)
{
if(vis[i]||!map[u][i])continue;
vis[i]=1;
if(!p[i]||find(p[i])){p[i]=u;return 1;}
}
return 0;
}
void work()
{
memset(p,0,sizeof(p));
cin>>n;int ans=0;
For(i,1,n)scanf("%d",&a[i]);
For(i,1,n){scanf("%d",&b[i]);if(!a[i])b[i]=0;}int x;
For(i,1,n)For(j,1,n)scanf("%d",&x),map[i][j]=(x&a[j]);
For(i,1,n)For(j,1,n)if(a[i])map[i][i]=1;
bool can=1;
For(i,1,n)
{
cls(vis);if(b[i])continue;
if(!find(i))can=0;
}
if(can)printf("^_^\n");else printf("T_T\n");
}
int main()
{
int T;cin>>T;
while(T--)work();
return 0;
}

posted on 2016-10-28 15:29  rwy  阅读(91)  评论(0编辑  收藏  举报