Advertisement
Um_nik

trash

Jan 1st, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double INF = 1e15;
  6. double eps = 1e-12;
  7.  
  8. struct Point
  9. {
  10.     double x, y;
  11.  
  12.     Point () {}
  13.     Point (double a, double b) : x(a), y(b) {}
  14.  
  15.     void Print()
  16.     {
  17.         printf("%.3lf %.3lf\n", x, y);
  18.     }
  19.  
  20.     double operator % (Point a)
  21.     {
  22.         return x * a.x + y * a.y;
  23.     }
  24.  
  25.     double operator * (Point a)
  26.     {
  27.         return x * a.y - y * a.x;
  28.     }
  29.  
  30.     Point operator - (Point a)
  31.     {
  32.         return Point(x - a.x, y - a.y);
  33.     }
  34. };
  35.  
  36. double a[110][3];
  37. double b[110][3];
  38. int n, m, k;
  39. Point p[11000];
  40.  
  41. int main()
  42. {
  43.  
  44. //  freopen("input.txt", "r", stdin);
  45. //  freopen("output.txt", "w", stdout);
  46.  
  47.     scanf("%d", &n);
  48.     for (int i = 0; i < n; i++)
  49.     {
  50.         scanf("%lf%lf%lf", &a[i][0], &a[i][1], &a[i][2]);
  51.         for (int j = 0; j < 3; j++)
  52.             a[i][j] = (double)10000000 / a[i][j];
  53.     }
  54.     for (int h = 0; h < n; h++)
  55.     {
  56.     /*  bool f = true;
  57.         for (int i = 0; i < n; i++)
  58.         {
  59.             if (i == h)
  60.                 continue;
  61.             if (a[i][0] + a[i][1] + a[i][2] <= a[h][0] + a[h][1] + a[h][2])
  62.                 f = false;
  63.         }
  64.         if (f)
  65.         {
  66.             printf("Yes\n");
  67.             continue;
  68.         }*/
  69.         f = false;
  70.         k = 0;
  71.         for (int i = 0; i < n; i++)
  72.         {
  73.             if (i == h)
  74.                 continue;
  75.             if (a[i][0] <= a[h][0] && a[i][1] <= a[h][1] && a[i][2] <= a[h][2])
  76.             {
  77.                 f = true;
  78.                 break;
  79.             }
  80.             if (a[i][0] >= a[h][0] && a[i][1] >= a[h][1] && a[i][2] >= a[h][2])
  81.                 continue;
  82.             for (int j = 0; j < 3; j++)
  83.                 b[k][j] = a[i][j] - a[h][j];
  84.             k++;
  85.         }
  86.         if (f)
  87.         {
  88.             printf("No\n");
  89.             continue;
  90.         }
  91.         //printf("%d %d\n", h, k);
  92.         b[k][0] = 1;
  93.         b[k][1] = 0;
  94.         b[k][2] = 0;
  95.         k++;
  96.         b[k][0] = 0;
  97.         b[k][1] = 1;
  98.         b[k][2] = 0;
  99.         k++;
  100.         b[k][0] = -1;
  101.         b[k][1] = 0;
  102.         b[k][2] = INF;
  103.         k++;
  104.         b[k][0] = 0;
  105.         b[k][1] = -1;
  106.         b[k][2] = INF;
  107.         k++;
  108.         m = 0;
  109.         for (int i = 0; i < k; i++)
  110.         {
  111.             for (int j = i + 1; j < k; j++)
  112.             {
  113.                 double tmp = b[i][0] * b[j][1] - b[i][1] * b[j][0];
  114.                 if (fabs(tmp) < eps)
  115.                     continue;
  116.                 Point S = Point( -(b[i][2] * b[j][1] - b[j][2] * b[i][1]) / tmp, (b[i][2] * b[j][0] - b[j][2] * b[i][0]) / tmp );
  117.                 //S.Print();
  118.                 bool g = false;
  119.                 for (int l = 0; l < k; l++)
  120.                 {
  121.                     if (b[l][0] * S.x + b[l][1] * S.y + b[l][2] < 0)
  122.                         g = true;
  123.                 }
  124.                 if (g)
  125.                     continue;
  126.                 p[m] = S;
  127.                 m++;
  128.             }
  129.         }
  130.  
  131.         //printf("%d %d\n", h, m);
  132.         //for (int i = 0; i < m; i++)
  133.             //p[i].Print();
  134.         //printf("******\n");
  135.         for (int i = 2; i < m; i++)
  136.         {
  137.             if (fabs((p[1] - p[0]) * (p[i] - p[0])) > eps)
  138.                 f = true;
  139.         }
  140.         if (f)
  141.             printf("Yes\n");
  142.         else
  143.             printf("No\n");
  144.     }
  145.     return 0;
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement