| ||||||||||
| 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 | |||||||||
此代码错哪了#include<iostream>
using namespace std;
char tleft[1002][1002],tright[1002][1002],re[1002];
bool islight( int c);
bool isheavey(char c);
int find(char c,char a[]);
int K;
int main()
{
freopen("in.txt","r",stdin);
int N,i,a,j;
int c,num(0),no;
cin>>N>>K;
for( i=0; i<K; i++)
{
cin>>a;
for( j=0; j<a; j++)
{
cin>>c;
tleft[i][j]=c+'0';
}
tleft[i][j]='\0';
for( j=0; j<a; j++)
{
cin>>c;
tright[i][j]=c+'0';
}
tright[i][j]='\0';
getchar();
cin>>re[i];
}
for( i=1; i<=N; i++)
{
if(islight(i))
{
num++;
no=i;
}
}
if(num==1)
cout<<no<<endl;
else
cout<<0<<endl;
return 0;
}
bool islight( int c)
{
int i;
for( i=0; i<K; i++)
{
if(re[i]=='=')
if(find(c+'0',tright[i])||find(c+'0',tleft[i]))
return false;
if(re[i]!='=')
if(!find(c+'0',tright[i])&&!find(c+'0',tleft[i]))
return false;
}
return true;
}
int find(char c,char a[])
{
int l=strlen(a),i;
for( i=0; i<l; i++)
if(a[i]==c)
return 1;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator