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

我了个去,数组大小看到100000无限WA,无奈开到1000000就AC,要求只有50000啊?!

Posted by 201501060326 at 2016-02-20 23:54:24 on Problem 1089
#include <stdio.h>
#define MAX 1000000
typedef struct
{
    int x;
    int y;
} point;
point pt[MAX];
int f[MAX],g[MAX];
int main()
{
    int cases,m,n,i,j,max;
    scanf("%d",&cases);
    for(i=0,max=0; i<cases; i++)
    {
        scanf("%d%d",&pt[i].x,&pt[i].y);
        if(max<pt[i].y)
            max=pt[i].y;
    }
    for(i=0; i<cases; i++)
    {
        m=pt[i].x;
        n=pt[i].y;
        if(m==n)
            g[m]=1;
        else
        {
            for(j=m; j<n; j++)
                f[j]=1;
        }
    }
    for(i=1; i<=max; i++)
    {
        if(f[i]==1)
        {
            printf("%d ",i);
            while(f[++i]==1);
            printf("%d\n",i);
        }
        else if(g[i]==1)
            printf("%d %d\n",i,i);
    }
    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