# include <bits/stdc++.h>
# define f first
# define s second
using namespace std;
const int N = 3e5 + 2;
struct st{
int x, y, r, id;
} a[N];
int n, fl = 1, ans[N];
bool cmp(st a, st b){
if(a.r == b.r)
return a.id < b.id;
return a.r > b.r;
}
int main(){
cin >> n;
for(int i = 1; i <= n; i ++){
cin >> a[i].x >> a[i].y >> a[i].r;
a[i].id = i;
if(a[i].y) fl = 0;
}
if(fl){
sort(a + 1, a + n + 1, cmp);
set < pair <int, int> > st;
for(int i = 1; i <= n; i ++){
st.insert({a[i].x, a[i].id});
}
for(int i = 1; i <= n; i ++){
if(ans[a[i].id]) continue;
vector < pair <int, int> > v;
for(auto j = st.lower_bound({a[i].x - a[i].r, 0}); j != st.end() && j->first <= a[i].x + a[i].r; j ++){
ans[j->s] = a[i].id;
v.push_back({j->f, j->s});
}
while(v.size()){
st.erase(v.back());
v.pop_back();
}
}
for(int i = 1; i <= n; i ++){
cout << ans[i] << " ";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
854 ms |
22568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
22568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
458 ms |
22568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |