Advertisement
Guest User

Untitled

a guest
Jan 17th, 2013
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. #include "testlib.h"
  2. #include <algorithm>
  3. #include <cstdio>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. const double MAXSCORE = 2970.0;
  9.  
  10. const double eps = 1e-5;
  11.  
  12. int n;
  13.  
  14.  
  15. double score(InStream& out,vector<double>& x,vector<double>& y){
  16.   for (int i = 0; i < n; i++){
  17.     x[i] = out.readDouble();
  18.     y[i] = out.readDouble();
  19.     double r = sqrt(x[i] * x[i] + y[i] * y[i]);
  20.     if (r > 1 + eps)
  21.       quitf(_pe, "Point outside circle, r=%.9f", r);
  22.     if (r > 1){
  23.       x[i] = x[i] / r;
  24.       y[i] = y[i] / r;
  25.     }
  26.   }
  27.  
  28.   double minarea = 4;
  29.  
  30.   for (int i = 0; i < n; i++)
  31.   for (int j = i+1; j < n; j++)
  32.   for (int k = j+1; k < n; k++)
  33.   {
  34.     double area = fabs(x[i] * y[j] - x[j] * y[i] + x[j] * y[k] - x[k] * y[j] + x[k] * y[i] - x[i] * y[k]) / 2;
  35.     minarea = min(minarea, area);
  36.   }
  37.   return minarea;
  38. }
  39.  
  40. int main(int argc,char** argv){
  41.   registerTestlibCmd(argc,argv);
  42.   n = inf.readInt(1,365);  
  43.  
  44.  
  45.   vector<double> px(n),py(n),jx(n),jy(n);
  46.  
  47.  
  48.   double ja = score(ans,jx,jy);
  49.   double pa = score(ouf,px,py);
  50.  
  51.   if (ja < pa){
  52.     ans.close();
  53.     FILE* ansf = fopen(argv[3],"w");
  54.     for (int i = 0; i < n; i++)
  55.         fprintf(ansf,"%.10lf %.10lf",px[i],py[i]);
  56.     fclose(ansf);
  57.     printf("%d\n", (int)(MAXSCORE));
  58.     return 0;
  59.   }
  60.   printf("%d\n", (int)max(0.0,pa/ja * MAXSCORE));
  61.   return 1;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement