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 |
最笨的方法 总是 RE ????????????????#include <stdio.h> #include <stdlib.h> int cmp(const void *a,const void *b) { return *(int *)a - *(int *)b; } int main() { char board[30001][30001]; int allp[30001]; int i,j,k,qh,qe,pnum,gnum,all,allmen[30001]; while (scanf("%d %d",&pnum,&gnum) != EOF) { if (pnum == 0 && gnum == 0) break; for (i = 0;i < pnum;i++) for (j = 0;j < pnum;j++) board[i][j] = '#'; for (i = 1;i <= gnum;i++) { scanf("%d",&all); for (j = 0;j < all;j++) scanf("%d",&allmen[j]); qsort(allmen,all,sizeof(int),cmp); for (j = 0;j < all - 1;j++) for (k = j + 1;k < all;k++) board[allmen[j]][allmen[k]] = '!'; } for (i = 0;i < pnum;i++) allmen[i] = 0; qh = -1; qe = 0; allp[0] = 0; allmen[0] = 1; while (qh != qe) { qh++; for (i = allp[qh] + 1;i < pnum;i++) if (board[allp[qh]][i] == '!' && allmen[i] == 0) { qe++; allp[qe] = i; allmen[i] = 1; } } printf("%d\n",qe+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