记录编号 394386 评测结果 AAAAAAAAAA
题目名称 文理分班 最终得分 100
用户昵称 Gravatarsasasas 是否通过 通过
代码语言 C++ 运行时间 0.062 s
提交时间 2017-04-13 13:59:56 内存使用 0.33 MiB
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define for1(a,b,i) for(int i=a;i<=b;i++)
#define sc(a) scanf("%d",&a);
int m,n,bond[55],ans,js=0,pdc[55],pdl[55],seat[55][55];
bool data[55][55],flag[55],leave[55];
bool find(int x)
{
     for1(1,n,i)
     {
        if(!flag[i]&&data[x][i])
        {
            flag[i]=1;
            if(!bond[i]||find(bond[i]))
            {
              bond[i]=x;
              return true;
            }
        }
     }
     return false;
}
int main()
{
    freopen("divideb.in","r",stdin);
    freopen("divideb.out","w",stdout);
    sc(m);
    while(m--)
    {
       memset(pdc,0,sizeof(pdc));
       memset(pdl,0,sizeof(pdl));
       memset(bond,0,sizeof(bond));
       memset(data,0,sizeof(data));
       memset(seat,0,sizeof(seat));
       memset(leave,0,sizeof(leave));
       js=0;
       sc(n);
       for1(1,n,i)
         sc(pdc[i]);
       for1(1,n,i)
       {
         sc(pdl[i]);
         if(pdc[i]&&pdl[i])
         {
            leave[i]=1;
            js+=1;
         }
       }
       for1(1,n,i)
       {
         for1(1,n,j)
         {
           sc(seat[i][j]);
           if(!leave[i]&&pdc[i])
             data[i][i]=1;
           if(seat[i][j]==1)
           {
             if(pdc[j])
               data[i][j]=1;
           }
         }
       }
       /*for1(1,n,i)
       {
          if(pdc[i]&&!pdl[i])
             data[i][i]=1;
       }*/
       /*cout<<endl;
       for1(1,12,i)
       {
         if(pdc[i]&&!leave[i])
           cout<<i<<" ";
       }
       cout<<endl;
       cout<<flag[7]<<endl<<data[3][7]<<endl<<bond[3]<<endl<<find(bond[3])<<endl;
       //while(1);   */                               
       for1(1,n,i)
       {
         memset(flag,0,sizeof(flag));
         //cout<<find(i)<<"  "<<leave[i]<<endl;
         if((!leave[i])&&(find(i)))
           ans+=1;
       }
       if(ans==n-js)
         printf("^_^\n");
       else
         printf("T_T\n");
        //cout<<" js="<<js<<" ans="<<ans<<" "<<n;
       ans=0;
    }
    //while(1);
    return 0;
}