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的不行了!我的思想是这样的,先按每种药可以检测的病的数目进行排序,然后依次扫描每个集合,如果后面打的集合能被前面的小集合合并得到,则此集合将被去掉。 这种思想对吗? 附代码: Memory:316K Time:484MS Language:G++ Result:Wrong Answer #include <stdio.h> int f[310],n,m; struct node{ int t[310]; int len; }st[300],temp; int main() { int i,j,k,flag,count; while (1) { scanf ("%d%d",&n,&m); if (n==0&&m==0) break; for (i=0;i<=n;i++) f[i]=-1; for (i=1;i<=m;i++) { scanf ("%d",&st[i].len); for (j=1;j<=st[i].len;j++) { scanf ("%d",&st[i].t[j]); f[st[i].t[j]]=0; } } for (i=1;i<=m;i++) for (j=i+1;j<=m;j++) if (st[j].len<st[i].len) { temp=st[i]; st[i]=st[j]; st[j]=temp; } count=0; for (i=1;i<=m;i++) { k=0; for (j=1;j<=st[i].len;j++) if (f[st[i].t[j]]==0) { f[st[i].t[j]]=1; k=1; } if (k==0) count++; } printf ("%d\n",count); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator