#include <bits/stdc++.h>
#define ft first
#define sd second
using namespace std;
typedef pair<int, int> pii;
const int MAXN = 300 * 1000 + 23;
int n, x[MAXN], y[MAXN], r[MAXN], par[MAXN];
set<pii> ed, st;
struct cmp { bool operator ()(int a, int b) const { return r[a] > r[b]? true: (r[a] == r[b]? a < b: false); } };
set<int, cmp> s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i] >> r[i];
if (y[i] != 0) return 0;
y[i] = x[i] + r[i];
x[i] -= r[i];
st.insert({x[i], i});
ed.insert({y[i], i});
s.insert(i);
}
while (s.size()) {
int a = *s.begin();
auto b = st.lower_bound({x[a], -1});
while (b != st.end() && b -> ft <= y[a]) {
par[b -> sd] = a;
s.erase(b -> sd);
ed.erase({y[b -> sd], b -> sd});
b = st.erase(b);
}
b = ed.lower_bound({x[a], -1});
while (b != ed.end() && b -> ft <= y[a]) {
par[b -> sd] = a;
s.erase(b -> sd);
st.erase({x[b -> sd], b -> sd});
b = ed.erase(b);
}
}
for (int i = 0; i < n; i++) cout << par[i] + 1 << ' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1809 ms |
49316 KB |
Output is correct |
2 |
Correct |
1774 ms |
56116 KB |
Output is correct |
3 |
Correct |
1644 ms |
55720 KB |
Output is correct |
4 |
Correct |
1775 ms |
56048 KB |
Output is correct |
5 |
Correct |
1403 ms |
53700 KB |
Output is correct |
6 |
Correct |
1264 ms |
53844 KB |
Output is correct |
7 |
Correct |
1280 ms |
54040 KB |
Output is correct |
8 |
Correct |
1246 ms |
53856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |