Advertisement
despotovski01

Macorot Tom

May 7th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const double INF = 1e18;
  5. // closest pair
  6. class Point {
  7. public:
  8.     ll x, y;
  9.     Point(ll _x = 0, ll _y = 0){
  10.         x = _x;
  11.         y = _y;
  12.     }
  13. };
  14.  
  15. double dist(const Point& a, const Point& b){
  16.     return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
  17. }
  18.  
  19. double closest(Point* P, int n){
  20.     double best = INF;
  21.     for(int i = 0;i<n;++i){
  22.         for(int j = i+1;j<n;++j){
  23.             best = min(best, dist(P[i], P[j]));
  24.         }
  25.     }
  26.     return best;
  27. }
  28.  
  29. int main(){
  30.     ios::sync_with_stdio(false);
  31.     int n;
  32.     cin>>n;
  33.     double f;
  34.     cin>>f;
  35.     Point points[n];
  36.     for(int i = 0;i<n;++i){
  37.         ll x, y;
  38.         cin>>x>>y;
  39.         points[i] = Point(x, y);
  40.     }
  41.     double best = closest(points, n);
  42.     cout<<(best <= f ? "DA" : "NE")<<endl;
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement