이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//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
컴파일 시 표준 에러 (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... |