#include #define pii pair using namespace std; const long double eps = 1e-9; int x[1001], y[1001]; int r[1001]; int viz[1001]; vector v[1001]; bool ok; long long dist(int i, int j) { return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]); } int cnt1, cnt2; void dfs(int nod) { for(auto it:v[nod]) { if(!viz[it]) { viz[it] = 3 - viz[nod]; if(viz[it] == 1) cnt1++; else cnt2++; dfs(it); } else if(viz[it] == viz[nod]) ok = 0; } } void solve() { int n; cin >> n; for(int i = 1; i <= n; i++){ cin >> x[i] >> y[i] >> r[i]; } for(int i = 1; i <= n; i++) for(int j = i + 1; j <= n; j++) if(dist(i, j) == 1LL * (r[i] + r[j]) * (r[i] + r[j])) { v[i].push_back(j); v[j].push_back(i); } for(int i = 1; i <= n; i++) if(!viz[i]) { ok = 1; cnt2 = 0; cnt1 = 1; viz[i] = 1; dfs(i); if(ok == 1 && cnt1 != cnt2) { cout << "YES"; return; } } cout << "NO"; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("test.in", "r", stdin); freopen("test.out", "w", stdout); #else #endif int T = 1; //cin >> T; while(T--) { solve(); } return 0; }