/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N = 3e5 + 5;
const long long INF = 1e18 + 7;
const int MAXA = 1e9;
const int B = sqrt(N) + 5;
array<int, 3> a[N];
set <array<int, 3>> s;
int ans[N];
bool f[N];
int dist(pair<int, int> a, pair<int, int> b){
int h1 = a.first - b.first;
int h2 = a.second - b.second;
return h1 * h1 + h2 * h2;
}
bool isintersect(array<int, 3> a, array<int, 3> b){
pair<int, int> a1 = {a[0], a[1]};
pair<int, int> b1 = {b[0], b[1]};
return dist(a1, b1) <= (a[2] + b[2]) * (a[2] + b[2]);
}
void solve()
{
int n; cin >> n;
for(int i = 1; i <= n; ++i){
int x, y, r; cin >> x >> y >> r;
a[i] = {x, y, r};
s.insert({-r, r, i});
}
while (!s.empty()){
array<int, 3> state = *s.begin();
int id = state[2];
s.erase(state);
ans[id] = id;
for(int i = 1; i <= n; ++i){
if (!ans[i]){
if (isintersect(a[i], a[id])){
ans[i] = id;
s.erase({-a[i][2], a[i][2], i});
}
}
}
}
for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("codeforces.inp","r",stdin);
// freopen("codeforces.out","w",stdout);
int t = 1; // cin >> t;
while (t--)
{
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
516 KB |
Output is correct |
17 |
Correct |
1 ms |
480 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
980 KB |
Output is correct |
20 |
Correct |
4 ms |
980 KB |
Output is correct |
21 |
Correct |
6 ms |
980 KB |
Output is correct |
22 |
Correct |
49 ms |
924 KB |
Output is correct |
23 |
Correct |
49 ms |
940 KB |
Output is correct |
24 |
Correct |
48 ms |
940 KB |
Output is correct |
25 |
Correct |
62 ms |
916 KB |
Output is correct |
26 |
Correct |
61 ms |
928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
430 ms |
37248 KB |
Output is correct |
2 |
Correct |
489 ms |
37176 KB |
Output is correct |
3 |
Correct |
493 ms |
37008 KB |
Output is correct |
4 |
Correct |
465 ms |
37336 KB |
Output is correct |
5 |
Execution timed out |
3052 ms |
33096 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Execution timed out |
3041 ms |
12504 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3041 ms |
34448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
516 KB |
Output is correct |
17 |
Correct |
1 ms |
480 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
980 KB |
Output is correct |
20 |
Correct |
4 ms |
980 KB |
Output is correct |
21 |
Correct |
6 ms |
980 KB |
Output is correct |
22 |
Correct |
49 ms |
924 KB |
Output is correct |
23 |
Correct |
49 ms |
940 KB |
Output is correct |
24 |
Correct |
48 ms |
940 KB |
Output is correct |
25 |
Correct |
62 ms |
916 KB |
Output is correct |
26 |
Correct |
61 ms |
928 KB |
Output is correct |
27 |
Correct |
9 ms |
1628 KB |
Output is correct |
28 |
Correct |
11 ms |
1580 KB |
Output is correct |
29 |
Correct |
12 ms |
1636 KB |
Output is correct |
30 |
Correct |
220 ms |
1544 KB |
Output is correct |
31 |
Correct |
226 ms |
1524 KB |
Output is correct |
32 |
Correct |
236 ms |
1540 KB |
Output is correct |
33 |
Correct |
105 ms |
13388 KB |
Output is correct |
34 |
Correct |
96 ms |
13344 KB |
Output is correct |
35 |
Correct |
110 ms |
13276 KB |
Output is correct |
36 |
Execution timed out |
3078 ms |
12312 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
516 KB |
Output is correct |
17 |
Correct |
1 ms |
480 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
980 KB |
Output is correct |
20 |
Correct |
4 ms |
980 KB |
Output is correct |
21 |
Correct |
6 ms |
980 KB |
Output is correct |
22 |
Correct |
49 ms |
924 KB |
Output is correct |
23 |
Correct |
49 ms |
940 KB |
Output is correct |
24 |
Correct |
48 ms |
940 KB |
Output is correct |
25 |
Correct |
62 ms |
916 KB |
Output is correct |
26 |
Correct |
61 ms |
928 KB |
Output is correct |
27 |
Correct |
430 ms |
37248 KB |
Output is correct |
28 |
Correct |
489 ms |
37176 KB |
Output is correct |
29 |
Correct |
493 ms |
37008 KB |
Output is correct |
30 |
Correct |
465 ms |
37336 KB |
Output is correct |
31 |
Execution timed out |
3052 ms |
33096 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |