Advertisement
VladNitu

checkerAta

Jun 2nd, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. struct Point {
  2.     double x, y;
  3. };
  4. int T, n, width, height;
  5. ordered_set<int> st; // Policy-based DS https://codeforces.com/blog/entry/11080
  6.  
  7. double dist(Point& point, Point& checker) {
  8.     return sqrt((point.x - checker.x) * (point.x - checker.x) + (point.y - checker.y) * (point.y - checker.y));
  9. }
  10.  
  11. int main() {
  12.  
  13.     cin >> width >> height >> n;
  14.     vector<Point> points(n);
  15.     for (int i = 0; i < n; ++i) {
  16.        cin >>  points[i].x >> points[i].y;
  17.     }
  18.  
  19.     Point checker{3.28, 2.35};
  20.     Point expected{4.0, 2.0};
  21.  
  22.     double min_dist = INT_MAX / 10;
  23.     for (auto& point: points)
  24.         min_dist = min(min_dist, dist(point, checker));
  25.  
  26.     cout << "Obtained: " << min_dist << '\n';
  27.  
  28.     double min_exp_dist = INT_MAX / 10;
  29.     for (auto& point: points)
  30.         min_exp_dist = min(min_exp_dist, dist(point, expected));
  31.  
  32.     cout << "But expected: " << min_exp_dist << '\n';
  33.  
  34.     return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement