| ||||||||||
| 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<stdio.h>
#include<string.h>
int count,N,D,K,max,sum;
int d[1001][16];
bool s[16];
void recur(int p)
{
int i,flag;
if(d[p][0]==0)
{
sum++;
goto loop;
}
flag = 0;
for(i = 1;i <= d[p][0];i++)
{
// flag = 0;
if(!s[d[p][i]])
{
s[d[p][i]] = 1;
count++;
}
if(count>K)
{
count--;
flag = 1;
s[d[p][i]] = 0;
break;
}
}
if(!flag)
sum++;
loop:;
if(p < N)
{
//printf("%d %d\n",p,sum);
recur(p+1);
sum--;
}
else
{
// printf("%d %d\n",p,sum);
if(max < sum)
max = sum;
}
}
int main()
{
int i,j;
while(scanf("%d%d%d",&N,&D,&K)!=EOF){
for(i = 1;i <= N;i++)
{
scanf("%d",&d[i][0]);
for(j = 1;j <= d[i][0];j++)
scanf("%d",&d[i][j]);
}
memset(s,0,sizeof(s));
max = 0;count = 0;sum = 0;
recur(1);
printf("%d\n",max);
}
return 0;
}
/*Sample Input
6 3 2
0
1 1
1 2
1 3
2 2 1
2 2 1
Sample Output
5
*/
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator