#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define int ll
using ld = long double;
using pii = pair<int, int>;
#define F first
#define S second
const ld PI = 3.1415926535;
const int N = 5e5 + 2;
const int M = 2e6 + 1;
int mod = 998244353;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;
int mult(int a, int b) {
return a * 1LL * b % mod;
}
int sum(int a, int b) {
if (a + b < 0)
return a + b + mod;
if (a + b >= mod)
return a + b - mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0)
return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % mod;
} else {
ll b = binpow(a, n / 2);
return b * b % mod;
}
}
struct hash_pair {
template <class T1, class T2>
size_t operator()(const pair<T1, T2>& p) const
{
// Hash the first element
size_t hash1 = hash<T1>{}(p.first);
// Hash the second element
size_t hash2 = hash<T2>{}(p.second);
// Combine the two hash values
return hash1
^ (hash2 + 0x9e3779b9 + (hash1 << 6)
+ (hash1 >> 2));
}
};
int n, ans[N];
int csz = 1e9+1;
set<pair<pii, pii>> cs;
unordered_map<pii, vector<pair<pii, pii>>, hash_pair> mp;
pii get(int x, int y){
return {floor((ld)x / (ld)csz), floor((ld)y / (ld)csz)};
}
bool inter(pair<pii, pii> a, pair<pii, pii> b){
return (((a.S.F - b.S.F) * (a.S.F - b.S.F) + (a.S.S - b.S.S) * (a.S.S - b.S.S)) <= (a.F.F + b.F.F) * (a.F.F + b.F.F));
}
void solve() {
cin >> n;
for(int i = 1; i <= n; i++){
int x, y, r;
cin >> x >> y >> r;
cs.insert({{r, n - i + 1}, {x, y}});
mp[get(x, y)].push_back({{r, n - i + 1}, {x, y}});
}
while(cs.size() > 0){
auto e = *cs.rbegin();
cs.erase(e);
if(e.F.F <= csz / 2){
csz = e.F.F;
unordered_map<pii, vector<pair<pii, pii>>, hash_pair> np;
for(auto bl : mp){
for(auto crc : bl.S){
np[get(crc.S.F, crc.S.S)].push_back(crc);
}
}
mp.swap(np);
}
ans[n - e.F.S + 1] = n - e.F.S + 1;
pii bl = get(e.S.F, e.S.S);
for(int x = bl.F - 2; x <= bl.F + 2; x++){
for(int y = bl.S - 2; y <= bl.S + 2; y++){
if(mp.find({x, y}) == mp.end())
continue;
for(auto crc : mp[{x, y}]){
if(inter(crc, e)){
if(ans[n - crc.F.S + 1] == 0){
ans[n - crc.F.S + 1] = n - e.F.S + 1;
cs.erase(crc);
}
}
}
}
}
}
for(int i = 1; i <= n; i++)
cout << ans[i] << ' ';
cout << '\n';
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 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 |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
592 KB |
Output is correct |
17 |
Correct |
1 ms |
592 KB |
Output is correct |
18 |
Correct |
1 ms |
592 KB |
Output is correct |
19 |
Correct |
4 ms |
1104 KB |
Output is correct |
20 |
Correct |
5 ms |
972 KB |
Output is correct |
21 |
Correct |
6 ms |
1200 KB |
Output is correct |
22 |
Correct |
17 ms |
1920 KB |
Output is correct |
23 |
Correct |
18 ms |
1740 KB |
Output is correct |
24 |
Correct |
26 ms |
1908 KB |
Output is correct |
25 |
Correct |
16 ms |
1756 KB |
Output is correct |
26 |
Correct |
23 ms |
1764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
392 ms |
61844 KB |
Output is correct |
2 |
Correct |
468 ms |
56488 KB |
Output is correct |
3 |
Correct |
369 ms |
57340 KB |
Output is correct |
4 |
Correct |
387 ms |
55336 KB |
Output is correct |
5 |
Correct |
754 ms |
59296 KB |
Output is correct |
6 |
Correct |
1492 ms |
76080 KB |
Output is correct |
7 |
Correct |
1281 ms |
72272 KB |
Output is correct |
8 |
Correct |
1201 ms |
73396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
701 ms |
31488 KB |
Output is correct |
3 |
Execution timed out |
3053 ms |
87204 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
869 ms |
75908 KB |
Output is correct |
2 |
Correct |
780 ms |
75276 KB |
Output is correct |
3 |
Correct |
518 ms |
57748 KB |
Output is correct |
4 |
Correct |
831 ms |
73696 KB |
Output is correct |
5 |
Correct |
760 ms |
76968 KB |
Output is correct |
6 |
Correct |
379 ms |
55720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 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 |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
592 KB |
Output is correct |
17 |
Correct |
1 ms |
592 KB |
Output is correct |
18 |
Correct |
1 ms |
592 KB |
Output is correct |
19 |
Correct |
4 ms |
1104 KB |
Output is correct |
20 |
Correct |
5 ms |
972 KB |
Output is correct |
21 |
Correct |
6 ms |
1200 KB |
Output is correct |
22 |
Correct |
17 ms |
1920 KB |
Output is correct |
23 |
Correct |
18 ms |
1740 KB |
Output is correct |
24 |
Correct |
26 ms |
1908 KB |
Output is correct |
25 |
Correct |
16 ms |
1756 KB |
Output is correct |
26 |
Correct |
23 ms |
1764 KB |
Output is correct |
27 |
Correct |
16 ms |
2672 KB |
Output is correct |
28 |
Correct |
8 ms |
2504 KB |
Output is correct |
29 |
Correct |
8 ms |
2508 KB |
Output is correct |
30 |
Correct |
41 ms |
3340 KB |
Output is correct |
31 |
Correct |
38 ms |
3336 KB |
Output is correct |
32 |
Correct |
38 ms |
3152 KB |
Output is correct |
33 |
Correct |
85 ms |
15060 KB |
Output is correct |
34 |
Correct |
90 ms |
13600 KB |
Output is correct |
35 |
Correct |
360 ms |
27764 KB |
Output is correct |
36 |
Correct |
598 ms |
32116 KB |
Output is correct |
37 |
Correct |
619 ms |
32280 KB |
Output is correct |
38 |
Correct |
660 ms |
32232 KB |
Output is correct |
39 |
Correct |
220 ms |
27180 KB |
Output is correct |
40 |
Correct |
235 ms |
27320 KB |
Output is correct |
41 |
Correct |
216 ms |
27164 KB |
Output is correct |
42 |
Correct |
175 ms |
27568 KB |
Output is correct |
43 |
Correct |
173 ms |
25908 KB |
Output is correct |
44 |
Correct |
177 ms |
25868 KB |
Output is correct |
45 |
Correct |
178 ms |
25860 KB |
Output is correct |
46 |
Correct |
191 ms |
26080 KB |
Output is correct |
47 |
Correct |
161 ms |
25864 KB |
Output is correct |
48 |
Correct |
158 ms |
25888 KB |
Output is correct |
49 |
Correct |
163 ms |
25856 KB |
Output is correct |
50 |
Correct |
177 ms |
25920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 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 |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
592 KB |
Output is correct |
17 |
Correct |
1 ms |
592 KB |
Output is correct |
18 |
Correct |
1 ms |
592 KB |
Output is correct |
19 |
Correct |
4 ms |
1104 KB |
Output is correct |
20 |
Correct |
5 ms |
972 KB |
Output is correct |
21 |
Correct |
6 ms |
1200 KB |
Output is correct |
22 |
Correct |
17 ms |
1920 KB |
Output is correct |
23 |
Correct |
18 ms |
1740 KB |
Output is correct |
24 |
Correct |
26 ms |
1908 KB |
Output is correct |
25 |
Correct |
16 ms |
1756 KB |
Output is correct |
26 |
Correct |
23 ms |
1764 KB |
Output is correct |
27 |
Correct |
392 ms |
61844 KB |
Output is correct |
28 |
Correct |
468 ms |
56488 KB |
Output is correct |
29 |
Correct |
369 ms |
57340 KB |
Output is correct |
30 |
Correct |
387 ms |
55336 KB |
Output is correct |
31 |
Correct |
754 ms |
59296 KB |
Output is correct |
32 |
Correct |
1492 ms |
76080 KB |
Output is correct |
33 |
Correct |
1281 ms |
72272 KB |
Output is correct |
34 |
Correct |
1201 ms |
73396 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
701 ms |
31488 KB |
Output is correct |
37 |
Execution timed out |
3053 ms |
87204 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |