#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fastIO() ios_base::sync_with_stdio(false), cin.tie(0)
const int INF = 0x7f7f7f7f;
const int maxn = 3E5 + 5;
struct Circle {
int x, y, r, id;
bool operator < (const Circle &rhs) const {
if (r == rhs.r) return id > rhs.id;
return r < rhs.r;
}
};
int32_t main() {
fastIO();
int n;
cin >> n;
Prior<Circle> pq;
vector<Circle> cir(n);
for (int i = 0; i < n; ++i) {
cin >> cir[i].x >> cir[i].y >> cir[i].r;
cir[i].id = i;
pq.push(cir[i]);
}
vector<int> ans(n, -1);
for (int i = 0; i < n; ++i) {
while (!pq.empty() and ans[pq.top().id] != -1) pq.pop();
if (pq.empty()) break;
for (int j = 0; j < n; ++j) {
if (ans[j] != -1) continue;
int dx = abs(cir[pq.top().id].x - cir[j].x);
int dy = abs(cir[pq.top().id].y - cir[j].y);
int dr = cir[pq.top().id].r + cir[j].r;
// cout << dx << " " << dy << " " << dr << "\n";
if (dx*dx + dy*dy <= dr*dr) ans[j] = pq.top().id;
}
}
for (int i = 0; i < n; ++i) cout << ans[i] + 1 << " \n"[i == n-1];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
1024 KB |
Output is correct |
20 |
Correct |
5 ms |
1024 KB |
Output is correct |
21 |
Correct |
5 ms |
1024 KB |
Output is correct |
22 |
Correct |
59 ms |
1024 KB |
Output is correct |
23 |
Correct |
59 ms |
1024 KB |
Output is correct |
24 |
Correct |
60 ms |
1024 KB |
Output is correct |
25 |
Correct |
62 ms |
1024 KB |
Output is correct |
26 |
Correct |
63 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
277 ms |
32348 KB |
Output is correct |
2 |
Correct |
281 ms |
32344 KB |
Output is correct |
3 |
Correct |
293 ms |
32220 KB |
Output is correct |
4 |
Correct |
282 ms |
32472 KB |
Output is correct |
5 |
Execution timed out |
3057 ms |
30552 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
3023 ms |
10216 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3081 ms |
33368 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
1024 KB |
Output is correct |
20 |
Correct |
5 ms |
1024 KB |
Output is correct |
21 |
Correct |
5 ms |
1024 KB |
Output is correct |
22 |
Correct |
59 ms |
1024 KB |
Output is correct |
23 |
Correct |
59 ms |
1024 KB |
Output is correct |
24 |
Correct |
60 ms |
1024 KB |
Output is correct |
25 |
Correct |
62 ms |
1024 KB |
Output is correct |
26 |
Correct |
63 ms |
1024 KB |
Output is correct |
27 |
Correct |
10 ms |
1664 KB |
Output is correct |
28 |
Correct |
9 ms |
1664 KB |
Output is correct |
29 |
Correct |
9 ms |
1656 KB |
Output is correct |
30 |
Correct |
296 ms |
1536 KB |
Output is correct |
31 |
Correct |
268 ms |
1536 KB |
Output is correct |
32 |
Correct |
268 ms |
1536 KB |
Output is correct |
33 |
Correct |
89 ms |
11108 KB |
Output is correct |
34 |
Correct |
85 ms |
11108 KB |
Output is correct |
35 |
Correct |
89 ms |
10980 KB |
Output is correct |
36 |
Execution timed out |
3023 ms |
9992 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
1024 KB |
Output is correct |
20 |
Correct |
5 ms |
1024 KB |
Output is correct |
21 |
Correct |
5 ms |
1024 KB |
Output is correct |
22 |
Correct |
59 ms |
1024 KB |
Output is correct |
23 |
Correct |
59 ms |
1024 KB |
Output is correct |
24 |
Correct |
60 ms |
1024 KB |
Output is correct |
25 |
Correct |
62 ms |
1024 KB |
Output is correct |
26 |
Correct |
63 ms |
1024 KB |
Output is correct |
27 |
Correct |
277 ms |
32348 KB |
Output is correct |
28 |
Correct |
281 ms |
32344 KB |
Output is correct |
29 |
Correct |
293 ms |
32220 KB |
Output is correct |
30 |
Correct |
282 ms |
32472 KB |
Output is correct |
31 |
Execution timed out |
3057 ms |
30552 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |