SHARE
TWEET

123

a guest Apr 26th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int x[101], y[101], r[101], p[101], n, d;
  5. void dfs(int k) {
  6.     p[k] = 1;
  7.     if (k != n) {
  8.         for (int i = n; i > 0; --i) {
  9.             if(p[i] == 0 && sqrt((x[i] - x[k]) * (x[i] - x[k]) +
  10.                 (y[i] - y[k]) * (y[i] - y[k])) - r[i] - r[k] <= d)
  11.                 dfs(i);
  12.         }
  13.     }
  14. }
  15. int main() {
  16.     int i;
  17.     cin >> n >> d;
  18.     for (i = 1; i <= n; ++i)
  19.         cin >> x[i] >> y[i] >> r[i];
  20.     dfs(1);
  21.     if (p[n])
  22.         cout << "YES";
  23.     else
  24.         cout << "NO";
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top