This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In the name of God
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll MXN = 3e5 + 10;
ll n;
ll X[MXN], R[MXN], A[MXN];
set<pll> st, stR, stL;
void Rm(ll i){
auto itr = st.find({-R[i], i});
st.erase(itr);
itr = stR.find({X[i] + R[i], i});
stR.erase(itr);
itr = stL.find({X[i] - R[i], i});
stL.erase(itr);
}
int main(){
ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i ++){
ll y; cin >> X[i] >> y >> R[i];
assert(y == 0);
}
for(int i = 1; i <= n; i ++){
st.insert({-R[i], i});
stL.insert({X[i] - R[i], i});
stR.insert({X[i] + R[i], i});
}
while(!st.empty()){
ll i = st.begin() -> second;
Rm(i), A[i] = i;
ll l = X[i] - R[i], r = X[i] + R[i];
auto itr = stL.lower_bound({l, -1});
while(itr != stL.end() && itr -> first <= r){
ll id = itr -> second;
A[id] = i; Rm(id);
itr = stL.lower_bound({l, -1});
}
itr = stR.lower_bound({l, -1});
while(itr != stR.end() && itr -> first <= r){
ll id = itr -> second;
A[id] = i; Rm(id);
itr = stR.lower_bound({l, -1});
}
}
for(int i = 1; i <= n; i ++) cout << A[i] << ' '; cout << '\n';
return 0;
}
//! N.N
Compilation message (stderr)
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:49:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
49 | for(int i = 1; i <= n; i ++) cout << A[i] << ' '; cout << '\n';
| ^~~
circle_selection.cpp:49:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
49 | for(int i = 1; i <= n; i ++) cout << A[i] << ' '; cout << '\n';
| ^~~~
# | 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... |