Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <iomanip>
  4. #include <cmath>
  5. using namespace std;
  6. const double eps=0.000001;
  7. struct point {
  8. double x,y;
  9. };
  10. struct Vector {
  11. long double x,y;
  12. Vector() = default;
  13. Vector (int x,int y): x(x),y(y) {}
  14. Vector operator * (int b) { return Vector(x*b,y*b); }
  15. Vector operator + (Vector v2) {return Vector(x+v2.x,y+v2.y); }
  16. };
  17. struct line {
  18. long double a,b,c;
  19. line (point p1, point p2) {
  20. a = p1.y - p2.y;
  21. b = p2.x - p1.x;
  22. c = -a*p2.x - p1.y*b;
  23. }
  24. };
  25. struct segment {
  26. point a,b;
  27. segment (point q, point w) {
  28. a=q;
  29. b=w;
  30. }
  31. };
  32. void printPoint (point p) {
  33. cout<<p.x<<" "<<p.y<<"\n";
  34. }
  35. void printVector (Vector p) {
  36. cout<<p.x<<" "<<p.y<<"\n";
  37. }
  38. double vectorLength(Vector a) {
  39. return a.x*a.x+a.y*a.y;
  40. }
  41. double pointDist (point a, point b) {
  42. return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
  43. }
  44.  
  45. int dotproduct (Vector a, Vector b) {
  46. return a.x*b.x + a.y*b.y;
  47. }
  48. int crossproduct (Vector a, Vector b) {
  49. return a.x*b.y - a.y*b.x;
  50. }
  51. int main() {
  52.  
  53. int a;
  54. cin>>a;
  55.  
  56. vector <point> points(a+1);
  57. point C;
  58. cin >> C.x >> C.y;
  59. for (int i=0;i<a;i++) {cin >> points[i].x >> points[i].y;
  60. if (points[i].x == C.x && points[i].y == C.y)
  61. {
  62. cout<<"YES"; return 0;
  63. }
  64. }
  65. for (int i=0;i<a;i++) {
  66. points[i].x-= C.x;
  67. points[i].y-= C.y;
  68.  
  69. }
  70. points[a] = points[0];
  71. int ans = 0;
  72. int weight[a];
  73.  
  74. for (int i=0;i<a;i++) weight[i] = 0;
  75. for (int i=0;i<a;i++) {
  76. if (points[i].y > points[i+1].y) weight[i]++;
  77. if (points[i].y < points[i+1].y) weight[(i+1)%a]++;
  78.  
  79. }
  80. for (int i=0;i<a;i++) {
  81. if (points[i].y == 0 && points[i].x >= 0) ans+= weight[i];
  82. if (C.x == points[i].x && C.y == points[i].y) {
  83. cout<<"YES"; return 0;
  84.  
  85. }
  86. }
  87.  
  88. for (int i=0;i<a;i++) {
  89. if (points[i].y * points[i+1].y < 0) {
  90. long double x1,x2,y1,y2;
  91.  
  92. x1 = points[i].x;
  93. x2 = points[i+1].x;
  94. y1 = points[i].y;
  95. y2 = points[i+1].y;
  96. long double inter;
  97. inter= min(x1,x2) + abs(x2-x1) * max(y1,y2) / (abs(y1) + abs(y2));
  98. if (inter >= 0) ans++;
  99.  
  100. }
  101. }
  102. if (ans%2 == 1) cout<<"YES"; else cout<<"NO";
  103.  
  104. return 0;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement