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:bobobo按区间排序,有重叠部分的就可以被一个radar覆盖到,贪心

Posted by 0506010237 at 2007-06-12 18:14:15 on Problem 1328
In Reply To:bobobo按区间排序,有重叠部分的就可以被一个radar覆盖到,贪心 Posted by:sza at 2006-08-14 11:47:06
> bobobo按区间排序,有重叠部分的就可以被一个radar覆盖到,贪心
#include<iostream>
#include<math.h>
using namespace std;
int addlist(double p[1000][4],int length,int r)
{
   double min=0;
     for(int i=0;i<length;i++)
     {
        cin>>p[i][0];
        cin>>p[i][1];
        if(p[i][1]>r)
          return -1;
        p[i][2]=p[i][0]-sqrt(r*r-p[i][1]*p[i][1]);
        p[i][3]=p[i][0]+sqrt(r*r-p[i][1]*p[i][1]);
     }
     for(int i=0;i<length-1;i++)
    {
        for(int j=0;j<length-1-i;j++)
        {
           if(p[j][2]<p[j+1][2])
           {
             for(int k=0;k<4;k++)
             {
                double temp=p[j][k];
                p[j][k]=p[j+1][k];
                p[j+1][k]=temp;        
             }
           }
        }
    }
       int count=length;
    int i=0;
    int k=0;
    while(i<length-1)
    {
       while(p[i+1][3]>=p[k][2])
       {  
         if(i>= length-1)
           break;               
          i++;
          count--;
       }
       i++;
       k=i;
    }
    return count;
}
int main()
{
    int t,r;
    int c[1000];
    int count1=0;
    while(true)
    {
       double p[1000][4]; 
       cin>>t;
       cin>>r;
       if(t==0 && r==0)
       {
           break;        
       }
       else
       {
           c[count1]=addlist(p,t,r);
           count1++;
       }
                
    }
    for(int k=0;k<count1;k++)
     cout<<"Case "<<k+1<<": "<<c[k]<<endl;
   system("PAUSE");
   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