#include #define int long long using namespace std; string to_string(string s) { return s; } template string to_string(T v) { string res = "["; for (const auto &x : v) { res += to_string(x) + ", "; } res += "]"; return res; } void dbg_out() { cout << endl; } template void dbg_out(Head H, Tail... T) { cout << ' ' << to_string(H); dbg_out(T...); } #ifdef DEBUG #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif using ll = long long; using vi = vector; using pii = pair; #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define all(v) (v).begin(), (v).end() #define sz(v) ((int)(v).size()) struct Disk { int x, y, r; }; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int nbDisks; cin >> nbDisks; vector coords(nbDisks); for (auto &[x, y, r] : coords) { cin >> x >> y >> r; } vector> mat(nbDisks, vector(nbDisks)); rep(i, 0, nbDisks) rep(j, 0, nbDisks) if (i != j) { auto &c1 = coords[i], &c2 = coords[j]; int sumRad = c1.r + c2.r; int dx = c1.x - c2.x; int dy = c1.y - c2.y; if (sumRad * sumRad == dx*dx + dy*dy) { mat[i][j] = true; } } vector bipart(nbDisks, -1); vector sum(2); bool okLocal = true; auto dfs = [&] (auto dfs, int node) -> void { dbg(node, bipart[node]); //cout << flush; sum[bipart[node]]++; rep(voisin, 0, nbDisks) if (mat[node][voisin]) { if (bipart[voisin] == -1) { bipart[voisin] = bipart[node] ^ 1; dfs(dfs, voisin); } if (bipart[voisin] == bipart[node]) { okLocal = false; } } }; bool atLeastOneCc = false; rep(i, 0, nbDisks) if (bipart[i] == -1) { sum = {0, 0}; okLocal = true; bipart[i] = 0; dfs(dfs, i); dbg(i, sum[0], sum[1]); okLocal &= (sum[0] != sum[1]); atLeastOneCc |= okLocal; } cout << (atLeastOneCc ? "YES\n" : "NO\n"); }