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 xcl119xcl at 2007-08-12 14:51:03 on Problem 1151
In Reply To:这道题似乎不用线段树吧? Posted by:farui at 2004-07-15 21:14:36
//网上荡的代码

#include <iostream>
#include <algorithm>
using namespace std;

double a1[202];
double a2[202];
double b1[202];
double b2[202];

double t1[404];
double t2[404];

int main()
{
 int d;
 int t;
 int y = 0;
 cout.precision(2);
 while(cin >> d )
 {
  if ( d == 0)  break;
  t = 0;
  cout << "Test case #" << ++y << endl;
  cout << "Total explored area: ";
  for(int i = 0;i < d;i++)
  {
   cin >> a1[i] >> b1[i] >> a2[i] >> b2[i];
   t1[t] = a1[i];
   t2[t] = b1[i];
   t++;
   t1[t] = a2[i];
   t2[t] = b2[i];
   t++;
  }

  sort(t1,t1+t);
  sort(t2,t2+t);

  double areaa = 0;
  for( int i = 0;i < t-1;i++ )
  {
   for( int j = 0;j < t-1;j++)
   {
    for( int k = 0;k < d;k++)
    {
     if ( (t1[i] >= a1[k]) && (t2[j] >= b1[k]) && (t1[i+1] <= a2[k]) && (t2[j+1] <= b2[k]) )
     {
      areaa += (t1[i+1] - t1[i])*(t2[j+1]-t2[j]);
      break;
     }
    }
   }
  }
  cout << fixed << areaa << endl;
  cout << 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