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 2010310200722 at 2012-08-04 17:31:25 on Problem 1029
In Reply To:-- 总结了前人几组易出错的数据 -- Posted by:MIRKING at 2008-05-23 10:01:26
> 5 2
> 1 1 4
> =
> 1 2 5
> =
> ---- 答案是 3 ----
> 2 1
> 1 1 2
> >
> ---- 答案是 0 ----
> 5 3
> 2 1 3 2 4
> >
> 2 3 5 2 4
> >
> 1 1 4
> >
> ---- 答案是 4 ----
> 5 3
> 1 2 3
> <
> 1 1 2
> >
> 1 3 4
> =
> ---- 答案是 2 ----
> 3 2
> 1 1 2
> <
> 1 1 3
> <
> ---- 答案是 1 ----
> 5 1
> 2 1 2 3 4
> =
> ---- 答案是 5 ----
> 3 2
> 1 1 2
> <
> 1 2 3
> >
> ---- 答案是 2 ----
我感觉这数据有点坑人,我的代码这几个数据都过了,但还是wa,不知道为什么,请指教


#include <iostream>
#include <stdlib.h>
using namespace std;

int flag[1005];
int main()
{
    int n,k;
    cin>>n>>k;
    int i,j,p;
    
    int left[505];
    int right[505];
    char c[3];
    for(i=0;i<k;i++)
    {
        cin>>p;
        for(j=0;j<p;j++)
        {
            cin>>left[j];
        }
        for(j=0;j<p;j++)
        {
            cin>>right[j];
        }
        cin>>c;
        if(c[0]=='=')
        {
            for(j=0;j<p;j++)
            {
                flag[left[j]]=100;
            }
            for(j=0;j<p;j++)
            {
                flag[right[j]]=100;
            }

        }
        if(c[0]=='>')
        {
            for(j=0;j<p;j++)
            {
                if(flag[left[j]]!=100)
                {
                    flag[left[j]]++;
                }
            }
            for(j=0;j<p;j++)
            {
                if(flag[right[j]]!=100)
                {
                    flag[right[j]]--;
                }
            }
        }
        if(c[0]=='<')
        {
            for(j=0;j<p;j++)
            {
                if(flag[left[j]]!=100)
                {
                    flag[left[j]]--;
                }
            }
            for(j=0;j<p;j++)
            {
                if(flag[right[j]]!=100)
                {
                    flag[right[j]]++;
                }
            }
        }
    }
    int max=-1;
    int ans;
    int mount=1;
    /*for(i=1;i<=n;i++)
    {
        cout<<flag[i]<<endl;
    }*/
    for(i=1;i<=n;i++)
    {
        if(flag[i]!=100 && abs(flag[i])>=max)
        {
            if(abs(flag[i])>max)
            {
                max=abs(flag[i]);
                ans=i;
                mount=1;
            }
            else if(abs(flag[i])==max)
            {
                mount++;
            }
        }

    }
    if(mount==1) cout<<ans<<endl;
    else cout<<0<<endl;
    //cout<<ans<<endl;
    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