Advertisement
Brick99

CCC07 stage 2 Cows

May 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <utility>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <iomanip>
  7. #include <stack>
  8.  
  9. using namespace std;
  10.  
  11. struct point{ int x,y; };
  12.  
  13. bool orjentacija(point a, point b, point c)
  14. {
  15.     if ( ((b.y-a.y)*(c.x-b.x) - (b.x-a.x)*(c.y-b.y)) < 0 ) return true;
  16.     return false;
  17. }
  18.  
  19. int main()
  20. {
  21.     int n;
  22.     cin>>n;
  23.  
  24.     point ko[n];
  25.     for (int i=0;i<n;i++) cin>>ko[i].x>>ko[i].y;
  26.  
  27.     int left = 0;
  28.     for (int i=1;i<n;i++)
  29.         if ( ko[left].x > ko[i].x ) left=i;
  30.     int p = left,q;
  31.     vector <point> w;
  32.  
  33.     do
  34.     {
  35.         q=(p+1)%n;
  36.         for (int i=0;i<n;i++)
  37.             if (orjentacija(ko[p],ko[i],ko[q])) q=i;
  38.  
  39.         w.push_back({ko[p].x,ko[p].y});
  40.         p=q;
  41.     }while (p!=left);
  42.  
  43.     int pov = 0;
  44.     int j=w.size()-1;
  45.     for (int i=0;i<w.size();i++)
  46.     {
  47.         pov+=(w[j].x + w[i].x)*(w[j].y - w[i].y);
  48.         j=i;
  49.     }
  50.  
  51.     cout<<abs(pov/100)<<endl;
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement