Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const double INF = 1e18;
- // closest pair
- class Point {
- public:
- ll x, y;
- Point(ll _x = 0, ll _y = 0){
- x = _x;
- y = _y;
- }
- };
- double dist(const Point& a, const Point& b){
- return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
- }
- double closest(Point* P, int n){
- double best = INF;
- for(int i = 0;i<n;++i){
- for(int j = i+1;j<n;++j){
- best = min(best, dist(P[i], P[j]));
- }
- }
- return best;
- }
- int main(){
- ios::sync_with_stdio(false);
- int n;
- cin>>n;
- double f;
- cin>>f;
- Point points[n];
- for(int i = 0;i<n;++i){
- ll x, y;
- cin>>x>>y;
- points[i] = Point(x, y);
- }
- double best = closest(points, n);
- cout<<(best <= f ? "DA" : "NE")<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement