#include using namespace std; using LL=long long; #define FOR(i, l, r)for(int i = (l); i<=(r);++i) #define REP(i, n)FOR(i,0,(n)-1) #define ssize(x)int(x.size()) auto&operator<<(auto&o,pairp) { return o << "(" << p.first << ", " << p.second << ")"; } auto operator<<(auto&o, auto x)->decltype(x.end(),o){ o<<"{";int i=0;for(auto e:x)o<<", "+!i++<> N; vector> kola; for(int i = 0; i < N; i++) { int x, y, r; cin >> x >> y >> r; kola.push_back({x, y, r}); } set left; vector> sasiedzi(N); for(int i = 0; i < N; i++) { for(int j = i + 1; j < N; j++) { auto [x1, y1, r1] = kola[i]; auto [x2, y2, r2] = kola[j]; if((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) == (r1 + r2) * (r1 + r2)) { sasiedzi[i].push_back(j); sasiedzi[j].push_back(i); } } left.insert(i); } vector color(N, -1); while(!left.empty()) { int start = *(left.begin()); left.erase(left.begin()); stack s; s.push(start); color[start] = 0; int color_count[2] = {1, 0}; bool bipart = true; while(!s.empty()) { int curr = s.top(); s.pop(); for(auto neigh : sasiedzi[curr]) { if(color[neigh] == color[curr]) { bipart = false; break; // no } if(color[neigh] == -1) { color[neigh] = (color[curr] + 1) % 2; color_count[color[neigh]]++; s.push(neigh); } } } if(bipart && color_count[0] != color_count[1]) { cout << "YES" << endl; return 0; } } cout << "NO" << endl; }