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 1910705245 at 2020-01-21 19:50:24 on Problem 1065
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        int j,k;
        scanf("%d",&j);
        int l[5000],w[5000];
        for(k=0;k<j;k++)
        {
            scanf("%d%d",&l[k],&w[k]);
        }
        int a,b,t;
        for(a=0;a<k-1;a++)
        {
            for(b=0;b<k-i-1;b++)
            {
                if(l[b]>l[b+1])
                {
                    t=l[b];
                    l[b]=l[b+1];
                    l[b+1]=t;
                    t=w[b];
                    w[b]=w[b+1];
                    w[b+1]=t;
                }
                if(l[b]==l[b+1]&&w[b]>w[b+1])
                {
                    t=w[b];
                    w[b]=w[b+1];
                    w[b+1]=t;
                }
            }
        }
        int x=0,c=j,m;
        while(c)
        {
            for(m=0;m<j;m++)
            {
                if(l[m]!=0&&w[m]!=0)
                    break;
            }
            a=l[m];
            b=w[m];
            l[m]=0;
            w[m]=0;
            c--;
            for(m=m+1;m<j;m++)
            {
                if(l[m]>=a&&w[m]>=b)
                {
                    a=l[m];
                    b=w[m];
                    l[m]=0;
                    w[m]=0;
                    c--;
                }
            }
            x++;
        }
        cout<<x<<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