// Saarland University: <(OvO)> #include #define sz(a) ((int)(a).size()) #define divceil(a, b) ((a) + (b) - 1) / (b) using namespace std; #define int long long #ifdef ONPC string to_string(const char* s) { return s; } template string to_string(const T& cont) { string ans = ""; for (bool fst = true; const auto& val: cont) { if (!fst) { ans += ", "; } ans += to_string(val); fst = false; } return ans + "}"; } void debug_print_collection() { cerr << endl; } template void debug_print_collection(First val, Args... args) { cerr << " " << to_string(val); debug_print_collection(args...); } #define debug(...) { cerr << "@@@ [" << #__VA_ARGS__ << "] ="; debug_print_collection(__VA_ARGS__);} #else #define debug(...) ; #define NDEBUG #endif mt19937 rnd(123); typedef long long ll; typedef long double ld; pair dfs(int node, vector& vis, vector >& adj, int col){ vis[node] = col; int num = 1; bool poss = true; for(int ne: adj[node]){ if(vis[ne] == vis[node]){ return {0, 0}; } if(vis[ne] == -1){ auto res = dfs(ne, vis, adj, !col); poss = poss && res.second; num += res.first; } } return {num, poss}; } int solve() { int n; if (!(cin >> n)) { return 1; } vector > disks(n); vector rad(n); for(int i = 0; i < n; i++){ int xi, yi; cin >> xi >> yi; disks[i] = {xi, yi}; cin >> rad[i]; } vector > adj(n); for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ int x1, y1, x2, y2; tie(x1, y1) = disks[i]; tie(x2, y2) = disks[j]; int dist2 = (x1 - x2)* (x1 - x2) + (y1 - y2) * (y1 - y2); if(dist2 == (rad[i] + rad[j]) * (rad[i] + rad[j])){ adj[i].push_back(j); adj[j].push_back(i); } } } vector vis(n, -1); bool sol = false; for(int i = 0; i < n; i++){ if(vis[i] == -1){ auto res = dfs(i, vis, adj, 0); if(res.second && res.first % 2 != 0){ sol = true; } } } cout << (sol ? "YES" : "NO"); return 0; } int32_t main() { #ifdef ONPC assert(freopen("inI.txt", "r", stdin)); #endif int TET = 1e9; // cin >> TET; for (int i = 1; i <= TET; i ++) { if (solve()) { break; } #ifdef ONPC cout << "__________________" << endl; #endif } #ifdef ONPC cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; #endif } /* g++ -std=c++20 -Wall -Wextra -Wshadow -D_GLIBCXX_DEBUG -DONPC -O2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -o ex template.cpp && ./ex */