Advertisement
pasholnahuy

Untitled

Oct 18th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <vector>
  2. #include <string>
  3. #include <cmath>
  4. #include <iostream>
  5. #include <unordered_set>
  6.  
  7. using namespace std;
  8.  
  9. //ax + by + c = 0
  10. //x = (-by - c)/a
  11. // y = (-ax - c)/b
  12.  
  13. struct Point {
  14. double x;
  15. double y;
  16. unordered_set<int> h;
  17. int h_sum = 0;
  18. };
  19. struct Line {
  20. double a, b, c;
  21. };
  22.  
  23. double scalar_product(const Point &p1, Point &p2) {
  24. return p1.x * p2.y - p2.x * p1.y;
  25. }
  26.  
  27. double check_line_point(Line line, Point point) {
  28. return line.a * point.x + line.b * point.y + line.c;
  29. }
  30.  
  31. int main() {
  32. int n, m, r;
  33. cin >> n >> m >> r;
  34. vector<Point> points(n);
  35. vector<Line> lines(m);
  36. for (int i = 0; i < n; ++i){
  37. double x, y;
  38. cin >> x >> y;
  39. points[i] = {x, y};
  40. }
  41. for (int i = 0; i < m; ++i){
  42. double a, b, c;
  43. cin >> a >> b >> c;
  44. lines[i] = {a, b, c};
  45. }
  46. for (int k = 0; k < n; ++k){
  47. auto& point = points[k];
  48. for (int i = 0; i < m; ++i){
  49. if (check_line_point(lines[i], point) > 0){
  50. point.h.insert(i);
  51. point.h_sum += i;
  52. }
  53. }
  54. for (int i = 0; i < k; ++i){
  55. if (points[i].h.size() == point.h.size() && points[i].h_sum == point.h_sum && points[i].h == point.h){
  56. cout << "YES";
  57. return 0;
  58. }
  59. }
  60. }
  61. cout << "NO";
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement