#include <bits/stdc++.h>
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 300005
#define M ll(998244353)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
int ans[N];
set <pair <int, int> > se, sl, sr;
bool cmp(pair <int, int> x, pair <int, int> y)
{
if (x.F != y.F) return x.F > y.F;
return x.S < y.S;
}
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) ans[i] = -1;
ld x[n], y[n], r[n];
bool f = 1;
for (int i = 0; i < n; i++) {int X, Y, R; cin >> X >> Y >> R; if (Y != 0) f = 0; x[i] = X; y[i] = Y; r[i] = R;}
if (f)
{
vector <pair <int, int> > vr; vr.clear();
for (int i = 0; i < n; i++) {vr.pb({r[i], i}); se.insert({x[i], i}); sl.insert({x[i] - r[i], i}); sr.insert({x[i] + r[i], i});}
sort(vr.begin(), vr.end(), cmp);
int j = 0;
while (j < sz(vr))
{
pair <int, int> pt = vr[j];
j++;
if (ans[pt.S] != -1) continue;
auto it = sl.upper_bound({x[pt.S] + r[pt.S], 1e9});
vector <int> del; del.clear();
if (it != sl.begin())
{
it--;
while (it != sl.begin())
{
if ((*it).F < x[pt.S] - r[pt.S]) break;
del.pb((*it).S);
it--;
}
}
auto itr = sr.lower_bound({x[pt.S] - r[pt.S], 1e9});
while (itr != sr.end())
{
if ((*itr).F > x[pt.S] + r[pt.S]) break;
del.pb((*itr).S);
itr++;
}
auto itp = se.lower_bound({x[pt.S] - r[pt.S], 1e9});
while (itp != se.end())
{
if ((*itp).F > x[pt.S] + r[pt.S]) break;
del.pb((*itp).S);
itp++;
}
for (auto it : del)
{
ans[it] = pt.S + 1;
sl.erase({x[it] - r[it], it});
se.erase({x[it], it});
sr.erase({x[it] + r[it], it});
}
}
for (int i = 0; i < n; i++) cout << ans[i] << " ";
exit(0);
}
int s = n;
while (s > 0)
{
int nm = -1;
for (int i = 0; i < n; i++)
{
if (ans[i] != -1) continue;
if (nm == -1 || r[nm] < r[i]) nm = i;
}
for (int i = 0; i < n; i++)
{
if (ans[i] != -1) continue;
ld rst = sqrt(pow(abs(x[nm] - x[i]), 2) + pow(abs(y[nm] - y[i]), 2));
if (r[nm] + r[i] >= rst) {ans[i] = nm + 1; s--;}
}
}
for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
7 ms |
640 KB |
Output is correct |
22 |
Correct |
320 ms |
760 KB |
Output is correct |
23 |
Correct |
318 ms |
640 KB |
Output is correct |
24 |
Correct |
319 ms |
764 KB |
Output is correct |
25 |
Correct |
303 ms |
640 KB |
Output is correct |
26 |
Correct |
299 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1785 ms |
66588 KB |
Output is correct |
2 |
Correct |
1716 ms |
63828 KB |
Output is correct |
3 |
Correct |
1758 ms |
66524 KB |
Output is correct |
4 |
Correct |
1810 ms |
66396 KB |
Output is correct |
5 |
Incorrect |
1205 ms |
62172 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
3090 ms |
5368 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3083 ms |
15608 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
7 ms |
640 KB |
Output is correct |
22 |
Correct |
320 ms |
760 KB |
Output is correct |
23 |
Correct |
318 ms |
640 KB |
Output is correct |
24 |
Correct |
319 ms |
764 KB |
Output is correct |
25 |
Correct |
303 ms |
640 KB |
Output is correct |
26 |
Correct |
299 ms |
640 KB |
Output is correct |
27 |
Correct |
10 ms |
896 KB |
Output is correct |
28 |
Correct |
10 ms |
896 KB |
Output is correct |
29 |
Correct |
10 ms |
896 KB |
Output is correct |
30 |
Correct |
1340 ms |
1016 KB |
Output is correct |
31 |
Correct |
1309 ms |
1016 KB |
Output is correct |
32 |
Correct |
1300 ms |
1016 KB |
Output is correct |
33 |
Correct |
66 ms |
6008 KB |
Output is correct |
34 |
Correct |
62 ms |
6008 KB |
Output is correct |
35 |
Correct |
71 ms |
6008 KB |
Output is correct |
36 |
Execution timed out |
3081 ms |
5376 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
7 ms |
640 KB |
Output is correct |
22 |
Correct |
320 ms |
760 KB |
Output is correct |
23 |
Correct |
318 ms |
640 KB |
Output is correct |
24 |
Correct |
319 ms |
764 KB |
Output is correct |
25 |
Correct |
303 ms |
640 KB |
Output is correct |
26 |
Correct |
299 ms |
640 KB |
Output is correct |
27 |
Correct |
1785 ms |
66588 KB |
Output is correct |
28 |
Correct |
1716 ms |
63828 KB |
Output is correct |
29 |
Correct |
1758 ms |
66524 KB |
Output is correct |
30 |
Correct |
1810 ms |
66396 KB |
Output is correct |
31 |
Incorrect |
1205 ms |
62172 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |