// Saarland University: <(OvO)> #include #define sz(a) ((int)(a).size()) #define divceil(a, b) ((a) + (b) - 1) / (b) using namespace std; #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; int solve() { int n; if (!(cin >> n)) { return 1; } vector> g(n); vector<__int128_t> x(n), y(n), r(n); for (int i = 0; i < n; i++) { ll a, b, c; cin >> a >> b >> c; x[i] = a; y[i] = b; r[i] = c; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { __int128_t dx = x[i] - x[j], dy = y[i] - y[j]; __int128_t r2 = r[i] + r[j]; if (dx * dx + dy * dy == r2 * r2) { g[i].push_back(j); } } } } int bal = 0; vector used(n, 0); function dfs = [&](int v) { if (used[v] == 1) { bal++; } else { bal--; } for (int u : g[v]) { if (!used[u]) { used[u] = 3 - used[v]; bool ok = dfs(u); if (!ok) { return false; } } else if (used[u] == used[v]) { return false; } } return true; }; for (int i = 0; i < n; i++) { if (!used[i]) { used[i] = 1; if (dfs(i) && bal != 0) { cout << "YES\n"; return 1; } } } cout << "NO\n"; return 1; } int32_t main() { #ifdef ONPC assert(freopen("I.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 */