#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <time.h>
#pragma once
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
struct uint64_hash {
static inline uint64_t rotr(uint64_t x, unsigned k) {
return (x >> k) | (x << (8U * sizeof(uint64_t) - k));
}
static inline uint64_t hash_int(uint64_t x) noexcept {
auto h1 = x * (uint64_t)(0xA24BAED4963EE407);
auto h2 = rotr(x, 32U) * (uint64_t)(0x9FB21C651E98DF25);
auto h = rotr(h1 + h2, 32U);
return h;
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count();
return hash_int(x + FIXED_RANDOM);
}
};
template <typename K, typename V, typename Hash = uint64_hash>
using hash_map = __gnu_pbds::gp_hash_table<K, V, Hash>;
template <typename K, typename Hash = uint64_hash>
using hash_set = hash_map<K, __gnu_pbds::null_type, Hash>;
template <typename T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
using namespace std;
const int MAX_CERCLE = 3e5+42, INF = 1e9;
struct Cercle{
unsigned int xCentre, yCentre, rayon, id;
bool operator<(Cercle autre) {
if(rayon == autre.rayon)
return id < autre.id;
return rayon > autre.rayon;
}
};
int nbCercle;
Cercle cercle[MAX_CERCLE];
void input() {
cin >> nbCercle;
for(int idCercle = 0; idCercle < nbCercle; idCercle++) {
cin >> cercle[idCercle].xCentre >> cercle[idCercle].yCentre >> cercle[idCercle].rayon;
cercle[idCercle].xCentre += INF;
cercle[idCercle].yCentre += INF;
cercle[idCercle].id = idCercle;
}
sort(cercle, cercle + nbCercle);
}
hash_map<long long, vector<int>> grille;
bool enleve[MAX_CERCLE] = {0};
int quiEnleve[MAX_CERCLE];
unsigned int tailleGrille = (1 << 31);
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
input();
for(int grand = 0; grand < nbCercle; grand++) {
if(enleve[grand])
continue;
bool change = 0;
while(tailleGrille/2 >= cercle[grand].rayon) {
tailleGrille /= 2;
change = 1;
}
if(change) {
grille.clear();
for(int cur = 0; cur < nbCercle; cur++) {
if(enleve[cur])
continue;
long long xGrille = (long long)cercle[cur].xCentre / tailleGrille, yGrille = (long long)cercle[cur].yCentre / tailleGrille;
grille[(xGrille << 32) + yGrille].push_back(cur);
}
}
long long xGrille = (long long)cercle[grand].xCentre / tailleGrille, yGrille = (long long)cercle[grand].yCentre / tailleGrille;
vector<int> quiReste;
for(int deltaX = -2; deltaX <= 2; deltaX++) {
for(int deltaY = -2; deltaY <= 2; deltaY++) {
long long nouvX = xGrille + deltaX, nouvY = yGrille + deltaY;
auto &v = grille[(nouvX << 32) + nouvY];
for(int type = 0; type < 2; type++) {
if(type == 1) {
grille.erase((nouvX << 32) + nouvY);
continue;
}
for(auto autre : v) {
long long xDist = (long long)cercle[grand].xCentre - cercle[autre].xCentre, yDist = (long long)cercle[grand].yCentre - cercle[autre].yCentre;
long long rDist = (long long)cercle[grand].rayon + cercle[autre].rayon;
if(xDist * xDist + yDist * yDist <= rDist * rDist && !enleve[autre]) {
enleve[autre] = 1;
quiEnleve[cercle[autre].id] = cercle[grand].id;
}
if(xDist * xDist + yDist * yDist > rDist * rDist) {
quiReste.push_back(autre);
}
}
}
}
}
for(auto nouveau : quiReste) {
if(enleve[nouveau])
continue;
long long xGrille = (long long)cercle[nouveau].xCentre / tailleGrille, yGrille = (long long)cercle[nouveau].yCentre / tailleGrille;
grille[(xGrille << 32) + yGrille].push_back(nouveau);
}
}
for(int cur = 0; cur < nbCercle; cur++) {
cout << quiEnleve[cur]+1 << " ";
}
}
Compilation message
circle_selection.cpp:6:9: warning: #pragma once in main file
6 | #pragma once
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
23 ms |
1612 KB |
Output is correct |
23 |
Correct |
16 ms |
1680 KB |
Output is correct |
24 |
Correct |
39 ms |
1584 KB |
Output is correct |
25 |
Correct |
23 ms |
1584 KB |
Output is correct |
26 |
Correct |
29 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
143 ms |
9428 KB |
Output is correct |
2 |
Correct |
146 ms |
8640 KB |
Output is correct |
3 |
Correct |
129 ms |
9384 KB |
Output is correct |
4 |
Correct |
119 ms |
8768 KB |
Output is correct |
5 |
Correct |
166 ms |
10776 KB |
Output is correct |
6 |
Correct |
1120 ms |
26096 KB |
Output is correct |
7 |
Correct |
1873 ms |
11540 KB |
Output is correct |
8 |
Correct |
291 ms |
16560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
538 ms |
22428 KB |
Output is correct |
3 |
Correct |
2195 ms |
83060 KB |
Output is correct |
4 |
Correct |
2308 ms |
82928 KB |
Output is correct |
5 |
Correct |
1506 ms |
47212 KB |
Output is correct |
6 |
Correct |
476 ms |
23932 KB |
Output is correct |
7 |
Correct |
393 ms |
12212 KB |
Output is correct |
8 |
Correct |
38 ms |
3052 KB |
Output is correct |
9 |
Correct |
1784 ms |
92856 KB |
Output is correct |
10 |
Correct |
1037 ms |
47452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1696 ms |
84008 KB |
Output is correct |
2 |
Correct |
1655 ms |
84084 KB |
Output is correct |
3 |
Correct |
251 ms |
17212 KB |
Output is correct |
4 |
Correct |
1641 ms |
83948 KB |
Output is correct |
5 |
Correct |
1704 ms |
83984 KB |
Output is correct |
6 |
Correct |
179 ms |
10900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
23 ms |
1612 KB |
Output is correct |
23 |
Correct |
16 ms |
1680 KB |
Output is correct |
24 |
Correct |
39 ms |
1584 KB |
Output is correct |
25 |
Correct |
23 ms |
1584 KB |
Output is correct |
26 |
Correct |
29 ms |
1656 KB |
Output is correct |
27 |
Correct |
5 ms |
620 KB |
Output is correct |
28 |
Correct |
5 ms |
596 KB |
Output is correct |
29 |
Correct |
5 ms |
596 KB |
Output is correct |
30 |
Correct |
37 ms |
2924 KB |
Output is correct |
31 |
Correct |
34 ms |
2976 KB |
Output is correct |
32 |
Correct |
57 ms |
2924 KB |
Output is correct |
33 |
Correct |
44 ms |
3020 KB |
Output is correct |
34 |
Correct |
45 ms |
3044 KB |
Output is correct |
35 |
Correct |
47 ms |
3328 KB |
Output is correct |
36 |
Correct |
555 ms |
22600 KB |
Output is correct |
37 |
Correct |
477 ms |
22472 KB |
Output is correct |
38 |
Correct |
563 ms |
22428 KB |
Output is correct |
39 |
Correct |
466 ms |
22068 KB |
Output is correct |
40 |
Correct |
476 ms |
21820 KB |
Output is correct |
41 |
Correct |
471 ms |
21880 KB |
Output is correct |
42 |
Correct |
123 ms |
12096 KB |
Output is correct |
43 |
Correct |
812 ms |
21876 KB |
Output is correct |
44 |
Correct |
766 ms |
21792 KB |
Output is correct |
45 |
Correct |
761 ms |
21968 KB |
Output is correct |
46 |
Correct |
762 ms |
21856 KB |
Output is correct |
47 |
Correct |
834 ms |
21872 KB |
Output is correct |
48 |
Correct |
748 ms |
21928 KB |
Output is correct |
49 |
Correct |
780 ms |
21984 KB |
Output is correct |
50 |
Correct |
764 ms |
21880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
23 ms |
1612 KB |
Output is correct |
23 |
Correct |
16 ms |
1680 KB |
Output is correct |
24 |
Correct |
39 ms |
1584 KB |
Output is correct |
25 |
Correct |
23 ms |
1584 KB |
Output is correct |
26 |
Correct |
29 ms |
1656 KB |
Output is correct |
27 |
Correct |
143 ms |
9428 KB |
Output is correct |
28 |
Correct |
146 ms |
8640 KB |
Output is correct |
29 |
Correct |
129 ms |
9384 KB |
Output is correct |
30 |
Correct |
119 ms |
8768 KB |
Output is correct |
31 |
Correct |
166 ms |
10776 KB |
Output is correct |
32 |
Correct |
1120 ms |
26096 KB |
Output is correct |
33 |
Correct |
1873 ms |
11540 KB |
Output is correct |
34 |
Correct |
291 ms |
16560 KB |
Output is correct |
35 |
Correct |
0 ms |
340 KB |
Output is correct |
36 |
Correct |
538 ms |
22428 KB |
Output is correct |
37 |
Correct |
2195 ms |
83060 KB |
Output is correct |
38 |
Correct |
2308 ms |
82928 KB |
Output is correct |
39 |
Correct |
1506 ms |
47212 KB |
Output is correct |
40 |
Correct |
476 ms |
23932 KB |
Output is correct |
41 |
Correct |
393 ms |
12212 KB |
Output is correct |
42 |
Correct |
38 ms |
3052 KB |
Output is correct |
43 |
Correct |
1784 ms |
92856 KB |
Output is correct |
44 |
Correct |
1037 ms |
47452 KB |
Output is correct |
45 |
Correct |
1696 ms |
84008 KB |
Output is correct |
46 |
Correct |
1655 ms |
84084 KB |
Output is correct |
47 |
Correct |
251 ms |
17212 KB |
Output is correct |
48 |
Correct |
1641 ms |
83948 KB |
Output is correct |
49 |
Correct |
1704 ms |
83984 KB |
Output is correct |
50 |
Correct |
179 ms |
10900 KB |
Output is correct |
51 |
Correct |
5 ms |
620 KB |
Output is correct |
52 |
Correct |
5 ms |
596 KB |
Output is correct |
53 |
Correct |
5 ms |
596 KB |
Output is correct |
54 |
Correct |
37 ms |
2924 KB |
Output is correct |
55 |
Correct |
34 ms |
2976 KB |
Output is correct |
56 |
Correct |
57 ms |
2924 KB |
Output is correct |
57 |
Correct |
44 ms |
3020 KB |
Output is correct |
58 |
Correct |
45 ms |
3044 KB |
Output is correct |
59 |
Correct |
47 ms |
3328 KB |
Output is correct |
60 |
Correct |
555 ms |
22600 KB |
Output is correct |
61 |
Correct |
477 ms |
22472 KB |
Output is correct |
62 |
Correct |
563 ms |
22428 KB |
Output is correct |
63 |
Correct |
466 ms |
22068 KB |
Output is correct |
64 |
Correct |
476 ms |
21820 KB |
Output is correct |
65 |
Correct |
471 ms |
21880 KB |
Output is correct |
66 |
Correct |
123 ms |
12096 KB |
Output is correct |
67 |
Correct |
812 ms |
21876 KB |
Output is correct |
68 |
Correct |
766 ms |
21792 KB |
Output is correct |
69 |
Correct |
761 ms |
21968 KB |
Output is correct |
70 |
Correct |
762 ms |
21856 KB |
Output is correct |
71 |
Correct |
834 ms |
21872 KB |
Output is correct |
72 |
Correct |
748 ms |
21928 KB |
Output is correct |
73 |
Correct |
780 ms |
21984 KB |
Output is correct |
74 |
Correct |
764 ms |
21880 KB |
Output is correct |
75 |
Correct |
153 ms |
9192 KB |
Output is correct |
76 |
Correct |
138 ms |
8704 KB |
Output is correct |
77 |
Correct |
139 ms |
9076 KB |
Output is correct |
78 |
Correct |
129 ms |
8412 KB |
Output is correct |
79 |
Correct |
234 ms |
9872 KB |
Output is correct |
80 |
Correct |
130 ms |
8392 KB |
Output is correct |
81 |
Correct |
1724 ms |
91140 KB |
Output is correct |
82 |
Correct |
1708 ms |
83452 KB |
Output is correct |
83 |
Correct |
2485 ms |
83492 KB |
Output is correct |
84 |
Correct |
2117 ms |
83536 KB |
Output is correct |
85 |
Correct |
1944 ms |
83960 KB |
Output is correct |
86 |
Correct |
1712 ms |
83108 KB |
Output is correct |
87 |
Correct |
2114 ms |
82928 KB |
Output is correct |
88 |
Correct |
1477 ms |
45692 KB |
Output is correct |
89 |
Correct |
1553 ms |
45496 KB |
Output is correct |
90 |
Correct |
1533 ms |
45520 KB |
Output is correct |
91 |
Correct |
1510 ms |
45452 KB |
Output is correct |
92 |
Correct |
1549 ms |
45568 KB |
Output is correct |
93 |
Execution timed out |
3086 ms |
83092 KB |
Time limit exceeded |
94 |
Halted |
0 ms |
0 KB |
- |