#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
const char nl = '\n';
void fastIO() {
ios::sync_with_stdio(false);
cin.tie(0);
}
int main() {
fastIO();
int N;
cin>>N;
vector<ii> cr(N);
for (int i = 0; i < N; i++) {
int x, y, r;
cin>>x>>y>>r;
cr[i] = {x, r};
}
multiset<ii> lpos; // {lp, id}
multiset<ii> rpos; // {rp, id}
multiset<ii> have; // {r, -id]}
for (int i = 0; i < N; i++) {
int x = cr[i].fi;
int r = cr[i].se;
lpos.insert({x + r, i});
rpos.insert({x - r, i});
have.insert({r, -i});
}
vi par(N, -1);
int rem = N;
while (rem != 0) {
auto it = --have.end();
int id = -(*it).se; // id of current circle
int x = cr[id].fi;
int r = cr[id].se;
int lp = x - r;
int rp = x + r;
// cout<<"at "<<id<<endl;
// cout<<"lp, rp: "<<lp<<" "<<rp<<endl;
// find all circles with lp[i], rp[i] in [lp, rp]
set<int> tr; // id of circles to remove
auto it2 = lpos.lower_bound({lp, -1});
while ((it2 != lpos.end()) && ((*it2).fi <= rp)) {
tr.insert((*it2).se);
it2++;
}
auto it3 = rpos.lower_bound({lp, -1});
while ((it3 != rpos.end()) && ((*it3).fi <= rp)) {
tr.insert((*it3).se);
it3++;
}
for (int x : tr) {
par[x] = id;
rem--;
int xt = cr[x].fi;
int rt = cr[x].se;
lpos.erase({xt - rt, x});
rpos.erase({xt + rt, x});
have.erase({rt, -x});
}
// cout<<id<<": "<<rem<<endl;
}
// cout<<"ANSWER: ";
for (int x : par)
cout<<(x + 1)<<" ";
cout<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1441 ms |
121576 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
855 ms |
47508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |