이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,c=1;
cin>>n;
vector<int>v(n+1);
deque<pair<pair<int,int>,pair<int,int>>>dq(n);
for(auto &i:dq){
cin>>i.second.first>>i.second.second>>i.first.first;
i.first.first*=-1;
i.first.second=c++;
}
sort(dq.begin(),dq.end());
for(auto &i:dq)i.first.first*=-1;
if(n<=5000){
while(dq.size()){
int a=dq.front().first.first,b=dq.front().first.second,c=dq.front().second.first,d=dq.front().second.second;
dq.pop_front();
v[b]=b;
for(int i=0;i<dq.size();i++){
long double x=sqrtl((c-dq[i].second.first)*(c-dq[i].second.first)+(d-dq[i].second.second)*(d-dq[i].second.second));
if(x<=dq[i].first.first+a){
v[dq[i].first.second]=b;
dq.erase(dq.begin()+i);
i--;
}
}
}
}else{
vector<bool>bl(n+1);
ordered_set st;
for(int i=0;i<n;i++){
st.insert({dq[i].second.first+dq[i].first.first,dq[i].first.second});
st.insert({dq[i].second.first-dq[i].first.first,dq[i].first.second});
}
while(dq.size()){
int a=dq.front().first.first,b=dq.front().first.second,c=dq.front().second.first,d=dq.front().second.second;
dq.pop_front();
if(bl[b])continue;
v[b]=b;
int l=c-a,r=c+a;
auto it=st.find_by_order(st.order_of_key(make_pair(l,0ll)));
while(it!=st.end()&&(*it).first<=r){
pair<int,int>pr=*it;
if(!bl[pr.second]){
bl[pr.second]=1;
v[pr.second]=b;
}
st.erase(it);
it=st.find_by_order(st.order_of_key(make_pair(l,0ll)));
}
}
}
for(int i=1;i<=n;i++)cout<<v[i]<<' ';
}
컴파일 시 표준 에러 (stderr) 메시지
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:27:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i=0;i<dq.size();i++){
| ~^~~~~~~~~~
circle_selection.cpp:44:94: warning: unused variable 'd' [-Wunused-variable]
44 | int a=dq.front().first.first,b=dq.front().first.second,c=dq.front().second.first,d=dq.front().second.second;
| ^
# | 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... |