This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a <<  " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli> 
#define INF (1ll<<60)
#define MAX 300000
#define largo 2000000000
//para el vector de orden
#define id second
struct xx {
    lli x;
    lli y;
    lli r;
};
struct yy {
    lli MIN;
    lli hizq;
    lli hder;
};
lli n,cont;
lli res[MAX+2],new_order[MAX+2];
xx circulo[MAX+2];
vector<pll> orden;
vector<yy> stree;
yy trash;
bool push(lli pos) {
    if (stree[pos].hizq != 0) return true;
    lli a = stree.size();
    stree.push_back(trash);
    stree.push_back(trash);
    stree[pos].hizq = a;
    stree[pos].hder = a+1;
    return false;
}
lli query(lli pos, lli ini, lli fin, lli l, lli r) {
    if (ini > r || fin < l) return 0;
    if (l <= ini && fin <= r) return stree[pos].MIN;
    lli mitad = (ini+fin)/2;
    push(pos);
    lli a = query(stree[pos].hizq, ini,mitad,l,r);
    lli b = query(stree[pos].hder, mitad+1,fin,l,r);
    
    if (new_order[a] < new_order[b]) return a;
    else return b;
}
void update(lli pos, lli ini, lli fin, lli l, lli r, lli val) {
    if (ini > r || fin < l) return;
    if (l <= ini && fin <= r) {
        stree[pos].MIN = val;
        return;
    }
    lli mitad = (ini+fin)/2;
    push(pos);
    update(stree[pos].hizq, ini,mitad,l,r,val);
    update(stree[pos].hder, mitad+1,fin,l,r,val);
    if (new_order[stree[ stree[pos].hizq ].MIN] < new_order[stree[ stree[pos].hder ].MIN]) stree[pos].MIN = stree[ stree[pos].hizq ].MIN;
    else stree[pos].MIN = stree[ stree[pos].hizq ].MIN;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    rep(i,1,n) {
        cin >> circulo[i].x >> circulo[i].y >> circulo[i].r;
        orden.push_back({-circulo[i].r, i});
    }
    sort(orden.begin(), orden.end());
    stree.push_back(trash);
    stree[0].MIN = INF;
    cont = 1;
    new_order[0] = INF;
    for (auto act : orden) {
        new_order[act.id] = cont++;
        lli l = circulo[act.id].x - circulo[act.id].r;
        lli r = circulo[act.id].x + circulo[act.id].r;
        lli a = query(0,-largo,largo,l,r);
        if (a == 0) { //meto mi rango
            res[act.id] = act.id;
            update(0,-largo,largo,l,r,act.id);
        }
        else res[act.id] = a;
    }
    rep(i,1,n) cout << res[i] << ' ';
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |