#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
const char nl = '\n';
void fastIO() {
ios::sync_with_stdio(false);
cin.tie(0);
}
bool intersect(pair<ii, int> c1, pair<ii, int> c2) {
ll dx = abs(c1.fi.fi - c2.fi.fi);
ll dy = abs(c1.fi.se - c2.fi.se);
ll dt = c1.se + c2.se;
if (dt * dt >= dx * dx + dy * dy)
return true;
return false;
}
int main() {
fastIO();
int N;
cin>>N;
vector<pair<ii, int>> cr(N);
// {{x, y}, r}
for (int i = 0; i < N; i++) {
cin>>cr[i].fi.fi>>cr[i].fi.se>>cr[i].se;
}
vector<bool> used(N, false);
vi par(N, -1);
int rem = N;
while (rem != 0) {
int pos = -1; // circle to use
for (int i = 0; i < N; i++) {
if (used[i])
continue;
if (pos == -1 || cr[i].se > cr[pos].se)
pos = i;
}
// cout<<"pos: "<<pos<<endl;
// cout<<"rem: "<<rem<<endl;
for (int i = 0; i < N; i++) {
if (used[i])
continue;
if (intersect(cr[pos], cr[i])) {
// if i = pos, the circle intersects itself
par[i] = pos;
used[i] = true;
rem--;
}
}
}
// cout<<"ANSWER: ";
for (int x : par)
cout<<(x + 1)<<" ";
cout<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
456 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
704 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
82 ms |
644 KB |
Output is correct |
23 |
Correct |
82 ms |
600 KB |
Output is correct |
24 |
Correct |
82 ms |
600 KB |
Output is correct |
25 |
Correct |
81 ms |
624 KB |
Output is correct |
26 |
Correct |
86 ms |
648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
13952 KB |
Output is correct |
2 |
Correct |
88 ms |
13812 KB |
Output is correct |
3 |
Correct |
99 ms |
13552 KB |
Output is correct |
4 |
Correct |
70 ms |
13904 KB |
Output is correct |
5 |
Execution timed out |
3071 ms |
9580 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
3047 ms |
4696 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3020 ms |
12880 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
456 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
704 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
82 ms |
644 KB |
Output is correct |
23 |
Correct |
82 ms |
600 KB |
Output is correct |
24 |
Correct |
82 ms |
600 KB |
Output is correct |
25 |
Correct |
81 ms |
624 KB |
Output is correct |
26 |
Correct |
86 ms |
648 KB |
Output is correct |
27 |
Correct |
3 ms |
856 KB |
Output is correct |
28 |
Correct |
3 ms |
860 KB |
Output is correct |
29 |
Correct |
3 ms |
860 KB |
Output is correct |
30 |
Correct |
325 ms |
684 KB |
Output is correct |
31 |
Correct |
348 ms |
860 KB |
Output is correct |
32 |
Correct |
329 ms |
868 KB |
Output is correct |
33 |
Correct |
29 ms |
5716 KB |
Output is correct |
34 |
Correct |
29 ms |
5592 KB |
Output is correct |
35 |
Correct |
36 ms |
5468 KB |
Output is correct |
36 |
Execution timed out |
3072 ms |
4432 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
456 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
704 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
82 ms |
644 KB |
Output is correct |
23 |
Correct |
82 ms |
600 KB |
Output is correct |
24 |
Correct |
82 ms |
600 KB |
Output is correct |
25 |
Correct |
81 ms |
624 KB |
Output is correct |
26 |
Correct |
86 ms |
648 KB |
Output is correct |
27 |
Correct |
74 ms |
13952 KB |
Output is correct |
28 |
Correct |
88 ms |
13812 KB |
Output is correct |
29 |
Correct |
99 ms |
13552 KB |
Output is correct |
30 |
Correct |
70 ms |
13904 KB |
Output is correct |
31 |
Execution timed out |
3071 ms |
9580 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |