#include <bits/stdc++.h>
using i64 = long long;
inline i64 sq(int x) { return i64(x) * x; }
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> x(n), y(n), r(n);
for (int i = 0; i < n; i++) {
std::cin >> x[i] >> y[i] >> r[i];
}
std::vector<int> ans(n, -1);
std::vector<int> ind(n);
iota(ind.begin(), ind.end(), 0);
sort(ind.begin(), ind.end(), [&](int i, int j) {
if (r[i] == r[j]) return i < j;
return r[i] > r[j];
});
std::set<std::pair<int, int>> sl, sr;
for (int i = 0; i < n; i++) {
sl.emplace(x[i] + r[i], i);
sr.emplace(x[i] - r[i], i);
}
for (auto i : ind) {
while (sr.size()) {
auto it = sr.lower_bound({x[i] - r[i], -1});
if (it == sr.end())break;
if (it->first <= x[i] + r[i]) {
int j = it->second;
ans[j] = i;
sl.erase({x[j] + r[j], j});
sr.erase(it);
}
}
while (sl.size()) {
auto it = sl.lower_bound({x[i] + r[i], 1e9});
if (it == sr.begin())break;
it--;
if (it->first <= x[i] + r[i]) {
int j = it->second;
ans[j] = i;
sr.erase({x[j] - r[j], j});
sl.erase(it);
}
}
}
for (auto x : ans) std::cout << x + 1 << ' ';
std::cout << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
3075 ms |
204 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3078 ms |
34372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3070 ms |
34420 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
3075 ms |
204 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
3075 ms |
204 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |