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

有没有人能帮我看看为什么总是结果错误,谢谢

Posted by 201073609 at 2011-03-31 19:28:48 on Problem 1182
#include <stdio.h>

struct lives
{
    int have;
    char kind;
}
lives[50001];
int main()
{
    int N,K,x,y,i,sum=0;
    int d;
    scanf("%d%d",&N,&K);
    for(i=1;i<=N;i++)
    {
        lives[i].have=0;
        lives[i].kind='n';
    }
    while(1)
    {
        scanf("%d%d%d",&d,&x,&y);
        if(x>N) {sum++; goto L;}
        else
        {if(y>N) {sum++; goto J;}
        else
        {
           lives[x].have=1;lives[y].have=1;
           if(d==1)
           {
               lives[x].kind='X';
               lives[y].kind='X';
               K--;break;
           }
           else
           {
               lives[x].kind='X';
               lives[y].kind='Z';
               K--;break;
           }
        }
        }
        J:
        L:
        K--;
    }
    while(K--)
    {
        scanf("%d%d%d",&d,&x,&y);
        if(x>N) sum++;
        else if(y>N) sum++;
        else if(lives[x].have && lives[y].have)
        {
            if(d == 1)
            {
                if(lives[x].kind!=lives[y].kind) sum++;
            }
            else
            {
                if((lives[x].kind=='X') && (lives[y].kind=='Z')) break;
                else if((lives[x].kind=='Z') && (lives[y].kind=='Y')) break;
                else if((lives[x].kind=='Y') && (lives[y].kind=='X')) break;
                else sum++;
            }
        }
        else
        {
            if(d == 1)
            {
                if(lives[x].have == 1)
                {
                    lives[y].kind=lives[x].kind;
                    lives[y].have=1;
                }
                else
                {
                   lives[x].kind=lives[y].kind;
                   lives[x].have=1;
                }
            }
            else
            {
                if(lives[x].have == 1)
                {
                    lives[y].have=1;
                    if(lives[x].kind == 'X') lives[y].kind='Z';
                    if(lives[x].kind == 'Y') lives[y].kind='X';
                    lives[y].kind='Y';
                }
                else
                {
                    lives[x].have=1;
                    if(lives[y].kind == 'X') lives[x].kind='Y';
                    if(lives[y].kind == 'Y') lives[x].kind='Z';
                    lives[x].kind='X';
                }
            }
        }
    }
    printf("%d",sum);
    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