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

感谢所有出数据的牛人们

Posted by SCSE10_Candybox at 2011-07-17 22:17:22 on Problem 1029
WA得热泪盈眶,就用大家给的数据就过了。。好感动。。谢谢各位。。。
再次转载
input:
3 2
1 1 2
<
1 2 3
<


3 2
1 1 2
>
1 1 3
>


5 1
2 1 2 3 4
=


4 3
2 1 2 3 4
<
2 1 3 2 4
<
1 2 4
=


5 3
2 1 3 2 4
>
2 3 5 2 4
>
1 1 4
>


5 3
2 1 3 2 4
>
2 3 5 2 4
>
1 1 4
=

output:


0
1
5
1
4
0

我的代码:
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
const int NN=10100;
const int MM=310;
bool havel[NN][MM],haver[NN][MM];
short judge[MM];
int n,m,p;
bool check(int x,bool light)
{
     bool nicel,nicer;
     for (int i=0;i<m;++i)
     {
         if (havel[i][x]) nicel=true;
         else nicel=false;
         if (haver[i][x]) nicer=true;
         else nicer=false;
         if (judge[i]==0 && ((nicel&&nicer)||(!nicel && !nicer))) continue;
         else if (judge[i]==-1 && ( (light && nicel && !nicer) || (!light && !nicel && nicer))) continue;
         else if (judge[i]==1 && ((light && !nicel && nicer) || (!light && nicel && !nicer))) continue;
         else return false;
     }
     return true;
}
int main()
{
    while (scanf("%d%d",&n,&m)!=EOF)
    //scanf("%d%d",&n,&m);
    {
          char pp;
          memset(havel,0,sizeof(havel));memset(haver,0,sizeof(haver));
          for (int i=0;i<m;++i)
          {
              scanf("%d",&p);
              for (int j=0;j<p;++j)
              {
                  int tmp;
                  scanf("%d",&tmp);
                  havel[i][tmp]=1;
              }
              for (int j=0;j<p;++j)
              {
                  int tmp;
                  scanf("%d",&tmp);
                  haver[i][tmp]=1;
              }
              scanf("\n%c",&pp);
              if (pp=='=') judge[i]=0;
              else if (pp=='<') judge[i]=-1;
              else judge[i]=1;
          }
          int ans=-1;
          for (int q=0;q<2;++q)
          {
              if (ans==-2) break;
              for (int i=1;i<=n;++i)
              {
                  if (check(i,q))
                  {
                     if (ans>0 && ans!=i)
                     {
                        ans=-2;
                        break;
                     }
                     else ans=i;
                  }
              }
          }
          if (ans==-2 || ans==-1) printf("0\n");
          else printf("%d\n",ans);
    }
    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