//#include <bits/stdc++.h>
#include <random>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#define fr first
#define sc second
#define ad push_back
using namespace std;
using ll = long long;
mt19937 rnd(348502);
const int N = 300005;
vector<pair<ll, pair<ll, ll>>> v;
ll color[N];
ll ans[N];
void solve()
{
ll n, i, j, x, y, r;
cin >> n;
/*if (n <= 5000)
{
for (i = 0; i < n; i++)
{
cin >> x >> y >> r;
v.push_back({ r, {x, y} });
}
ll qan = 0;
for (i = 0; i < n; i++)
{
ll ma = 0;
for (j = 0; j < n; j++)
{
if (color[j] == 0)
{
ma = max(v[j].first, ma);
}
}
for (j = 0; j < n; j++)
{
if (color[j] == 0 && v[j].first == ma)
{
color[j] = 1;
ans[j] = j + 1;
qan++;
for (ll h = 0; h < n; h++)
{
if (color[h] == 0 && (v[j].second.first - v[h].second.first) * (v[j].second.first - v[h].second.first) + (v[j].second.second - v[h].second.second) * (v[j].second.second - v[h].second.second) <= (v[j].first + v[h].first) * (v[j].first + v[h].first))
{
color[h] = 1;
ans[h] = j + 1;
qan++;
}
}
break;
}
}
if (qan == n)
break;
}
for (i = 0; i < n; i++)
{
cout << ans[i] << ' ';
}
}
else
{*/
set<pair<pair<ll, ll>, ll>> mar;
set<pair<ll, pair<ll, ll>>> hert;
for (i = 0; i < n; i++)
{
cin >> x >> y >> r;
v.push_back({ r, {x, y} });
mar.insert({ {r, -i}, x});
hert.insert({ x, {r, i} });
}
ll qan = 0;
while (!mar.empty())
{
qan++;
x = (--mar.end())->second;
r = (--mar.end())->first.first;
ll ind = -(--mar.end())->first.second;
color[ind] = 1;
ans[ind] = ind + 1;
auto it = hert.lower_bound({ x, {r, ind} });
auto gn = it;
vector<pair<ll, pair<ll, ll>>> herthan;
while (1)
{
ll xx = gn->first;
ll rr = gn->second.first;
ll indind = gn->second.second;
if (abs(xx - x) <= rr + r)
{
color[indind] = 1;
ans[indind] = ind + 1;
herthan.push_back({ xx, {rr, indind} });
}
else
break;
if (gn == hert.begin())
break;
else
gn--;
}
gn = it;
while (1)
{
gn++;
if (gn == hert.end())
break;
ll xx = gn->first;
ll rr = gn->second.first;
ll indind = gn->second.second;
if (abs(xx - x) <= rr + r)
{
color[indind] = 1;
ans[indind] = ind + 1;
herthan.push_back({ xx, {rr, indind} });
}
else
break;
}
for ( i = 0; i < herthan.size(); i++)
{
hert.erase(herthan[i]);
mar.erase({ {herthan[i].second.first, -herthan[i].second.second}, herthan[i].first });
}
}
for ( i = 0; i < n; i++)
{
cout << ans[i] << ' ';
}
//}
}
ll main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
ll tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
return 0;
}
Compilation message
circle_selection.cpp: In function 'void solve()':
circle_selection.cpp:140:28: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
140 | for ( i = 0; i < herthan.size(); i++)
| ~~^~~~~~~~~~~~~~~~
circle_selection.cpp:34:14: warning: unused variable 'j' [-Wunused-variable]
34 | ll n, i, j, x, y, r;
| ^
circle_selection.cpp: At global scope:
circle_selection.cpp:154:1: error: '::main' must return 'int'
154 | ll main() {
| ^~