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 B10380207 at 2011-07-21 10:18:28 on Problem 1083
#include <stdio.h>
struct
{
 int x,y;
}a[205];
int main(int argc, char *argv[])
{
    int m,n,i,j,max,k;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&m);
        for(i=0;i<m;i++)
        {
            scanf("%d",&a[i].x);
            if(a[i].x%2)
                a[i].x++;
            scanf("%d",&a[i].y);
            if(a[i].y%2)
                a[i].y++;
            if(a[i].x>a[i].y)
            {
                 k=a[i].x;
                 a[i].x=a[i].y;
                 a[i].y=k;
            }
            
        }
        for(i=1;i<m;i++)
            for(j=0;j<m-i;j++)
                if(a[j].y>a[j+1].y)
                {
                    k=a[j].x;
                    a[j].x=a[j+1].x;
                    a[j+1].x=k;
                    k=a[j].y;
                    a[j].y=a[j+1].y;
                    a[j+1].y=k;
                }
        max=1;
        for(i=0;i<m;i++)
        {
            k=1;
            for(j=i+1;j<m;j++)
                if(a[j].x>a[i].x&&a[j].x<a[i].y)
                {
                    a[i].x=a[j].y;
                    k++;
                    if(k>max)
                        max=k;
                 }
                 else if(a[j].x<=a[i].x||a[j].x==a[i].y)
                {
                  k++;
                  if(k>max)
                        max=k;
                }
        }
        printf("%d\n",max*10);


    }
    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