#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]<<' ';
}
Compilation message
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;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
564 KB |
Output is correct |
21 |
Correct |
6 ms |
468 KB |
Output is correct |
22 |
Correct |
95 ms |
516 KB |
Output is correct |
23 |
Correct |
95 ms |
500 KB |
Output is correct |
24 |
Correct |
97 ms |
524 KB |
Output is correct |
25 |
Correct |
95 ms |
468 KB |
Output is correct |
26 |
Correct |
98 ms |
520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
794 ms |
52180 KB |
Output is correct |
2 |
Correct |
820 ms |
52300 KB |
Output is correct |
3 |
Correct |
801 ms |
51920 KB |
Output is correct |
4 |
Correct |
809 ms |
52156 KB |
Output is correct |
5 |
Correct |
752 ms |
51900 KB |
Output is correct |
6 |
Correct |
777 ms |
52212 KB |
Output is correct |
7 |
Correct |
750 ms |
52028 KB |
Output is correct |
8 |
Correct |
733 ms |
52024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
180 ms |
17408 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
758 ms |
51908 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
564 KB |
Output is correct |
21 |
Correct |
6 ms |
468 KB |
Output is correct |
22 |
Correct |
95 ms |
516 KB |
Output is correct |
23 |
Correct |
95 ms |
500 KB |
Output is correct |
24 |
Correct |
97 ms |
524 KB |
Output is correct |
25 |
Correct |
95 ms |
468 KB |
Output is correct |
26 |
Correct |
98 ms |
520 KB |
Output is correct |
27 |
Incorrect |
12 ms |
1876 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
564 KB |
Output is correct |
21 |
Correct |
6 ms |
468 KB |
Output is correct |
22 |
Correct |
95 ms |
516 KB |
Output is correct |
23 |
Correct |
95 ms |
500 KB |
Output is correct |
24 |
Correct |
97 ms |
524 KB |
Output is correct |
25 |
Correct |
95 ms |
468 KB |
Output is correct |
26 |
Correct |
98 ms |
520 KB |
Output is correct |
27 |
Correct |
794 ms |
52180 KB |
Output is correct |
28 |
Correct |
820 ms |
52300 KB |
Output is correct |
29 |
Correct |
801 ms |
51920 KB |
Output is correct |
30 |
Correct |
809 ms |
52156 KB |
Output is correct |
31 |
Correct |
752 ms |
51900 KB |
Output is correct |
32 |
Correct |
777 ms |
52212 KB |
Output is correct |
33 |
Correct |
750 ms |
52028 KB |
Output is correct |
34 |
Correct |
733 ms |
52024 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Incorrect |
180 ms |
17408 KB |
Output isn't correct |
37 |
Halted |
0 ms |
0 KB |
- |