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

最笨的方法 总是 RE ????????????????

Posted by Debugcool at 2009-05-18 20:49:31 on Problem 1611
#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:
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