#include #include #include #include #include struct model{ long long x, y, r; int i; bool reach(const model &m) const { long long dx = x-m.x, dy = y-m.y, td = r+m.r; return dx*dx + dy*dy <= td*td; } }; int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; auto comp1 = [](const std::pair &m1, const std::pair &m2){ long long x1 = m1.first.x + m1.second * m1.first.r, x2 = m2.first.x + m2.second * m2.first.r; return x1 == x2 ? (m1.first.x == m2.first.x ? m1.first.y > m2.first.y : m1.first.x > m2.first.x) : x1 > x2; }; std::priority_queue, std::vector>, decltype(comp1)> q(comp1); for (int i = 0; i < n; ++i){ model m = {0, 0, 0, i}; std::cin >> m.x >> m.y >> m.r; m.x *= 10; m.y *= 10; m.r = m.r * 5 + 254; q.push({m, 1}); q.push({m, -1}); } std::vector> g(n); auto comp2 = [](const model &m1, const model &m2){return m1.y == m2.y ? m1.x < m2.x : m1.y < m2.y;}; std::set bst(comp2); while (!q.empty()){ const std::pair &mp = q.top(); const model &m = mp.first; auto it = bst.lower_bound(m); if (mp.second == -1){ auto it2 = it; while (it != bst.end() && m.reach(*it)){ g[m.i].push_back(it->i); g[it->i].push_back(m.i); ++it; } while (it2 != bst.begin() && m.reach(*(--it2))){ g[m.i].push_back(it2->i); g[it2->i].push_back(m.i); } bst.insert(m); } else{ auto it2 = it; if ((++it2) != bst.end() && it != bst.begin() && (*(--it)).reach(*it2)){ g[it->i].push_back(it2->i); g[it2->i].push_back(it->i); } bst.erase(--it2); } q.pop(); } std::vector leaf(n, true), done(n); int leafs = n, dones = 0; std::vector todo = {0}; while (!todo.empty()){ int i = todo.back(); todo.pop_back(); if (done[i]) continue; for (int j = 0; j < g[i].size(); ++j){ todo.push_back(g[i][j]); if (j > 0 && g[i][j] != g[i][j-1]){ leafs -= leaf[i]; leaf[i] = false; } } done[i] = true; ++dones; } if (dones == n && (n < 7 || leafs == 0)) std::cout << "yes\n"; else std::cout << "no\n"; return 0; }