// oooo
/*
har chi delet mikhad bebar ~
gitar o ba khodet nabar! ~
;Amoo_Hasan;
*/
#include<bits/stdc++.h>
//#pragma GCC optimize("O3,no-stack-protector,unroll-loops")
//#pragma GCC target("avx2,fma")
using namespace std;
typedef long long ll;
typedef long double ld;
#define Sz(x) int((x).size())
#define All(x) (x).begin(), (x).end()
#define wtf(x) cout<<#x <<" : " <<x <<endl
constexpr ll inf = 1e18, N = 1e6 + 10, mod = 1e9 + 7, pr = 1000696969;
int x[N], y[N], r[N], ans[N];
bool mark[N];
vector<int> adj[N];
bool Ok(int i, int j) {
ll cur = 1ll * (x[i] - x[j]) * (x[i] - x[j]);
cur += 1ll * (y[i] - y[j]) * (y[i] - y[j]);
if(cur <= 1ll * (r[i] + r[j]) * (r[i] + r[j])) return true;
return false;
}
bool cmp(int i, int j) {
return r[i] > r[j];
}
int main() {
ios :: sync_with_stdio(0), cin.tie(0);
int n; cin >>n;
for(int i = 0; i < n; i++) cin >>x[i] >>y[i] >>r[i];
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++) {
if(Ok(i, j)) {
adj[i].push_back(j);
adj[j].push_back(i);
}
}
vector<int> vc;
for(int i = 0; i < n; i++) vc.push_back(i);
sort(All(vc), cmp);
for(auto i : vc) {
if(mark[i]) continue;
ans[i] = i;
for(auto j : adj[i]) {
if(!mark[j]) {
mark[j] = 1;
ans[j] = i;
}
}
}
for(int i = 0; i < n; i++) cout<<ans[i] + 1 <<' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
12 ms |
23808 KB |
Output is correct |
3 |
Correct |
12 ms |
23764 KB |
Output is correct |
4 |
Correct |
12 ms |
23812 KB |
Output is correct |
5 |
Correct |
13 ms |
23768 KB |
Output is correct |
6 |
Correct |
12 ms |
23892 KB |
Output is correct |
7 |
Correct |
14 ms |
23860 KB |
Output is correct |
8 |
Correct |
13 ms |
23892 KB |
Output is correct |
9 |
Correct |
13 ms |
23892 KB |
Output is correct |
10 |
Correct |
13 ms |
23892 KB |
Output is correct |
11 |
Correct |
12 ms |
23732 KB |
Output is correct |
12 |
Correct |
12 ms |
23764 KB |
Output is correct |
13 |
Correct |
13 ms |
23852 KB |
Output is correct |
14 |
Correct |
12 ms |
23856 KB |
Output is correct |
15 |
Correct |
12 ms |
23756 KB |
Output is correct |
16 |
Correct |
28 ms |
31948 KB |
Output is correct |
17 |
Correct |
28 ms |
31700 KB |
Output is correct |
18 |
Correct |
28 ms |
32444 KB |
Output is correct |
19 |
Correct |
456 ms |
292184 KB |
Output is correct |
20 |
Correct |
442 ms |
288572 KB |
Output is correct |
21 |
Correct |
435 ms |
177380 KB |
Output is correct |
22 |
Correct |
99 ms |
24208 KB |
Output is correct |
23 |
Correct |
100 ms |
24152 KB |
Output is correct |
24 |
Correct |
106 ms |
24172 KB |
Output is correct |
25 |
Correct |
102 ms |
24268 KB |
Output is correct |
26 |
Correct |
101 ms |
24264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3083 ms |
906092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23744 KB |
Output is correct |
2 |
Execution timed out |
3055 ms |
28220 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3061 ms |
35544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
12 ms |
23808 KB |
Output is correct |
3 |
Correct |
12 ms |
23764 KB |
Output is correct |
4 |
Correct |
12 ms |
23812 KB |
Output is correct |
5 |
Correct |
13 ms |
23768 KB |
Output is correct |
6 |
Correct |
12 ms |
23892 KB |
Output is correct |
7 |
Correct |
14 ms |
23860 KB |
Output is correct |
8 |
Correct |
13 ms |
23892 KB |
Output is correct |
9 |
Correct |
13 ms |
23892 KB |
Output is correct |
10 |
Correct |
13 ms |
23892 KB |
Output is correct |
11 |
Correct |
12 ms |
23732 KB |
Output is correct |
12 |
Correct |
12 ms |
23764 KB |
Output is correct |
13 |
Correct |
13 ms |
23852 KB |
Output is correct |
14 |
Correct |
12 ms |
23856 KB |
Output is correct |
15 |
Correct |
12 ms |
23756 KB |
Output is correct |
16 |
Correct |
28 ms |
31948 KB |
Output is correct |
17 |
Correct |
28 ms |
31700 KB |
Output is correct |
18 |
Correct |
28 ms |
32444 KB |
Output is correct |
19 |
Correct |
456 ms |
292184 KB |
Output is correct |
20 |
Correct |
442 ms |
288572 KB |
Output is correct |
21 |
Correct |
435 ms |
177380 KB |
Output is correct |
22 |
Correct |
99 ms |
24208 KB |
Output is correct |
23 |
Correct |
100 ms |
24152 KB |
Output is correct |
24 |
Correct |
106 ms |
24172 KB |
Output is correct |
25 |
Correct |
102 ms |
24268 KB |
Output is correct |
26 |
Correct |
101 ms |
24264 KB |
Output is correct |
27 |
Correct |
1874 ms |
758576 KB |
Output is correct |
28 |
Correct |
2223 ms |
996232 KB |
Output is correct |
29 |
Correct |
2070 ms |
946344 KB |
Output is correct |
30 |
Correct |
385 ms |
24844 KB |
Output is correct |
31 |
Correct |
362 ms |
24704 KB |
Output is correct |
32 |
Correct |
370 ms |
24616 KB |
Output is correct |
33 |
Execution timed out |
3089 ms |
838472 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
12 ms |
23808 KB |
Output is correct |
3 |
Correct |
12 ms |
23764 KB |
Output is correct |
4 |
Correct |
12 ms |
23812 KB |
Output is correct |
5 |
Correct |
13 ms |
23768 KB |
Output is correct |
6 |
Correct |
12 ms |
23892 KB |
Output is correct |
7 |
Correct |
14 ms |
23860 KB |
Output is correct |
8 |
Correct |
13 ms |
23892 KB |
Output is correct |
9 |
Correct |
13 ms |
23892 KB |
Output is correct |
10 |
Correct |
13 ms |
23892 KB |
Output is correct |
11 |
Correct |
12 ms |
23732 KB |
Output is correct |
12 |
Correct |
12 ms |
23764 KB |
Output is correct |
13 |
Correct |
13 ms |
23852 KB |
Output is correct |
14 |
Correct |
12 ms |
23856 KB |
Output is correct |
15 |
Correct |
12 ms |
23756 KB |
Output is correct |
16 |
Correct |
28 ms |
31948 KB |
Output is correct |
17 |
Correct |
28 ms |
31700 KB |
Output is correct |
18 |
Correct |
28 ms |
32444 KB |
Output is correct |
19 |
Correct |
456 ms |
292184 KB |
Output is correct |
20 |
Correct |
442 ms |
288572 KB |
Output is correct |
21 |
Correct |
435 ms |
177380 KB |
Output is correct |
22 |
Correct |
99 ms |
24208 KB |
Output is correct |
23 |
Correct |
100 ms |
24152 KB |
Output is correct |
24 |
Correct |
106 ms |
24172 KB |
Output is correct |
25 |
Correct |
102 ms |
24268 KB |
Output is correct |
26 |
Correct |
101 ms |
24264 KB |
Output is correct |
27 |
Execution timed out |
3083 ms |
906092 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |