Advertisement
a53

episodul2

a53
May 27th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <fstream>
  2. #define LL long long
  3. using namespace std;
  4. ifstream f("episodul2.in");
  5. ofstream g("episodul2.out");
  6. typedef struct
  7. {
  8. int x,y;
  9. } PUNCT;
  10. PUNCT p[200001];
  11. int vf;
  12.  
  13. bool cp(PUNCT A,PUNCT B,PUNCT C)
  14. {
  15. LL v=1LL*(B.y-A.y)*(C.x-A.x)-1LL*(B.x-A.x)*(C.y-A.y);
  16. return v<0;
  17. }
  18.  
  19. int main()
  20. {
  21. int m,ev;
  22. PUNCT pc;
  23. LL aria;
  24. f>>m;
  25. while(m--)
  26. {
  27. f>>ev;
  28. if(ev==1)
  29. {
  30. f>>pc.x>>pc.y;
  31. while(cp(p[vf-1],p[vf],pc))
  32. --vf;
  33. ++vf,p[vf].x=pc.x,p[vf].y=pc.y;
  34. }
  35. else
  36. {
  37. /*
  38. for(int i=1;i<=vf;++i)
  39. g<<p[i].x<<" "<<p[i].y<<endl;
  40. */
  41. aria=0;
  42. for(int i=2;i<=vf;++i)
  43. aria+=(unsigned long long)(p[i].y+p[i-1].y)*(unsigned long long)(p[i].x-p[i-1].x);
  44. int rest=aria%2;
  45. g<<aria/2;
  46. if(rest==1)
  47. g<<".5\n";
  48. else
  49. g<<'\n';
  50. }
  51. }
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement