//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
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';
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1507 ms |
65884 KB |
Output is correct |
2 |
Correct |
1530 ms |
65852 KB |
Output is correct |
3 |
Correct |
1439 ms |
65564 KB |
Output is correct |
4 |
Correct |
1369 ms |
65764 KB |
Output is correct |
5 |
Correct |
1331 ms |
65488 KB |
Output is correct |
6 |
Correct |
1379 ms |
70368 KB |
Output is correct |
7 |
Correct |
1391 ms |
70364 KB |
Output is correct |
8 |
Correct |
1429 ms |
70300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |