Submission #895815

# Submission time Handle Problem Language Result Execution time Memory
895815 2023-12-30T21:49:55 Z MilosMilutinovic Circle selection (APIO18_circle_selection) C++14
100 / 100
1893 ms 39604 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX = 300300;

int n;
long long x[MAX];
long long y[MAX];
long long r[MAX];

bool Good(int i, int j) {
  return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) <= (r[i] + r[j]) * (r[i] + r[j]);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> r[i];
  }
  vector<int> order(n);
  iota(order.begin(), order.end(), 0);
  sort(order.begin(), order.end(), [&](int i, int j) {
    if (r[i] != r[j]) {
      return r[i] > r[j];
    } else {
      return i < j;
    }
  });
  vector<int> res(n);
  iota(res.begin(), res.end(), 0);
  for (int pw = 30; pw >= 0; pw--) {
    int k = (1 << pw);
    vector<tuple<long long, long long, int>> v;
    for (int i = 0; i < n; i++) {
      if (res[i] != i) {
        continue;
      }
      v.emplace_back(x[i] / k, y[i] / k, i);
    }
    sort(v.begin(), v.end());
    for (int i : order) {
      if (res[i] != i || r[i] < (1 << (pw - 1)) || r[i] > k) {
        continue;
      }
      long long new_x = x[i] / k;
      long long new_y = y[i] / k;
      for (int dx = -2; dx <= 2; dx++) {
        int ptr = (int) (lower_bound(v.begin(), v.end(), make_tuple(new_x - dx, new_y - 2, -1)) - v.begin());
        while (ptr < (int) v.size() && get<0>(v[ptr]) == new_x - dx && abs(new_y - get<1>(v[ptr])) <= 2) {
          if (Good(i, get<2>(v[ptr]))) {
            int idx = get<2>(v[ptr]);
            if (res[idx] == idx) {
              res[idx] = i;
            }
          }
          ptr += 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] + 1 << " ";
  }
  cout << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4568 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 3 ms 4892 KB Output is correct
20 Correct 3 ms 4892 KB Output is correct
21 Correct 3 ms 4892 KB Output is correct
22 Correct 18 ms 4976 KB Output is correct
23 Correct 21 ms 4984 KB Output is correct
24 Correct 18 ms 4976 KB Output is correct
25 Correct 17 ms 5060 KB Output is correct
26 Correct 18 ms 4972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 153 ms 29548 KB Output is correct
2 Correct 189 ms 30544 KB Output is correct
3 Correct 181 ms 31012 KB Output is correct
4 Correct 130 ms 22460 KB Output is correct
5 Correct 815 ms 30856 KB Output is correct
6 Correct 1028 ms 30900 KB Output is correct
7 Correct 888 ms 30940 KB Output is correct
8 Correct 878 ms 31196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 434 ms 13084 KB Output is correct
3 Correct 1465 ms 31168 KB Output is correct
4 Correct 1482 ms 39064 KB Output is correct
5 Correct 1213 ms 37240 KB Output is correct
6 Correct 523 ms 23680 KB Output is correct
7 Correct 272 ms 14924 KB Output is correct
8 Correct 50 ms 6736 KB Output is correct
9 Correct 1436 ms 39532 KB Output is correct
10 Correct 1028 ms 37904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1377 ms 29432 KB Output is correct
2 Correct 1462 ms 39604 KB Output is correct
3 Correct 512 ms 39392 KB Output is correct
4 Correct 1331 ms 37500 KB Output is correct
5 Correct 1322 ms 37652 KB Output is correct
6 Correct 474 ms 39528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4568 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 3 ms 4892 KB Output is correct
20 Correct 3 ms 4892 KB Output is correct
21 Correct 3 ms 4892 KB Output is correct
22 Correct 18 ms 4976 KB Output is correct
23 Correct 21 ms 4984 KB Output is correct
24 Correct 18 ms 4976 KB Output is correct
25 Correct 17 ms 5060 KB Output is correct
26 Correct 18 ms 4972 KB Output is correct
27 Correct 6 ms 5228 KB Output is correct
28 Correct 6 ms 5232 KB Output is correct
29 Correct 6 ms 5228 KB Output is correct
30 Correct 39 ms 5352 KB Output is correct
31 Correct 37 ms 5348 KB Output is correct
32 Correct 38 ms 5352 KB Output is correct
33 Correct 45 ms 11460 KB Output is correct
34 Correct 48 ms 10700 KB Output is correct
35 Correct 65 ms 12956 KB Output is correct
36 Correct 448 ms 13076 KB Output is correct
37 Correct 446 ms 13036 KB Output is correct
38 Correct 435 ms 13568 KB Output is correct
39 Correct 581 ms 13216 KB Output is correct
40 Correct 614 ms 13008 KB Output is correct
41 Correct 369 ms 13044 KB Output is correct
42 Correct 237 ms 13100 KB Output is correct
43 Correct 392 ms 13160 KB Output is correct
44 Correct 393 ms 13772 KB Output is correct
45 Correct 386 ms 13016 KB Output is correct
46 Correct 419 ms 14156 KB Output is correct
47 Correct 410 ms 13776 KB Output is correct
48 Correct 405 ms 13024 KB Output is correct
49 Correct 405 ms 13028 KB Output is correct
50 Correct 400 ms 15056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4568 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 3 ms 4892 KB Output is correct
20 Correct 3 ms 4892 KB Output is correct
21 Correct 3 ms 4892 KB Output is correct
22 Correct 18 ms 4976 KB Output is correct
23 Correct 21 ms 4984 KB Output is correct
24 Correct 18 ms 4976 KB Output is correct
25 Correct 17 ms 5060 KB Output is correct
26 Correct 18 ms 4972 KB Output is correct
27 Correct 153 ms 29548 KB Output is correct
28 Correct 189 ms 30544 KB Output is correct
29 Correct 181 ms 31012 KB Output is correct
30 Correct 130 ms 22460 KB Output is correct
31 Correct 815 ms 30856 KB Output is correct
32 Correct 1028 ms 30900 KB Output is correct
33 Correct 888 ms 30940 KB Output is correct
34 Correct 878 ms 31196 KB Output is correct
35 Correct 1 ms 4440 KB Output is correct
36 Correct 434 ms 13084 KB Output is correct
37 Correct 1465 ms 31168 KB Output is correct
38 Correct 1482 ms 39064 KB Output is correct
39 Correct 1213 ms 37240 KB Output is correct
40 Correct 523 ms 23680 KB Output is correct
41 Correct 272 ms 14924 KB Output is correct
42 Correct 50 ms 6736 KB Output is correct
43 Correct 1436 ms 39532 KB Output is correct
44 Correct 1028 ms 37904 KB Output is correct
45 Correct 1377 ms 29432 KB Output is correct
46 Correct 1462 ms 39604 KB Output is correct
47 Correct 512 ms 39392 KB Output is correct
48 Correct 1331 ms 37500 KB Output is correct
49 Correct 1322 ms 37652 KB Output is correct
50 Correct 474 ms 39528 KB Output is correct
51 Correct 6 ms 5228 KB Output is correct
52 Correct 6 ms 5232 KB Output is correct
53 Correct 6 ms 5228 KB Output is correct
54 Correct 39 ms 5352 KB Output is correct
55 Correct 37 ms 5348 KB Output is correct
56 Correct 38 ms 5352 KB Output is correct
57 Correct 45 ms 11460 KB Output is correct
58 Correct 48 ms 10700 KB Output is correct
59 Correct 65 ms 12956 KB Output is correct
60 Correct 448 ms 13076 KB Output is correct
61 Correct 446 ms 13036 KB Output is correct
62 Correct 435 ms 13568 KB Output is correct
63 Correct 581 ms 13216 KB Output is correct
64 Correct 614 ms 13008 KB Output is correct
65 Correct 369 ms 13044 KB Output is correct
66 Correct 237 ms 13100 KB Output is correct
67 Correct 392 ms 13160 KB Output is correct
68 Correct 393 ms 13772 KB Output is correct
69 Correct 386 ms 13016 KB Output is correct
70 Correct 419 ms 14156 KB Output is correct
71 Correct 410 ms 13776 KB Output is correct
72 Correct 405 ms 13024 KB Output is correct
73 Correct 405 ms 13028 KB Output is correct
74 Correct 400 ms 15056 KB Output is correct
75 Correct 201 ms 39208 KB Output is correct
76 Correct 236 ms 39396 KB Output is correct
77 Correct 211 ms 38992 KB Output is correct
78 Correct 150 ms 32484 KB Output is correct
79 Correct 292 ms 38580 KB Output is correct
80 Correct 151 ms 33500 KB Output is correct
81 Correct 1453 ms 38844 KB Output is correct
82 Correct 1464 ms 38884 KB Output is correct
83 Correct 1418 ms 37404 KB Output is correct
84 Correct 1517 ms 37840 KB Output is correct
85 Correct 1443 ms 38196 KB Output is correct
86 Correct 1453 ms 37396 KB Output is correct
87 Correct 1516 ms 38956 KB Output is correct
88 Correct 1343 ms 34040 KB Output is correct
89 Correct 1893 ms 34436 KB Output is correct
90 Correct 1201 ms 33556 KB Output is correct
91 Correct 1191 ms 34808 KB Output is correct
92 Correct 1809 ms 35992 KB Output is correct
93 Correct 1367 ms 37876 KB Output is correct
94 Correct 1477 ms 37704 KB Output is correct
95 Correct 1342 ms 36824 KB Output is correct
96 Correct 1364 ms 38208 KB Output is correct
97 Correct 1610 ms 37980 KB Output is correct
98 Correct 1065 ms 36984 KB Output is correct
99 Correct 1360 ms 38020 KB Output is correct
100 Correct 1400 ms 37620 KB Output is correct
101 Correct 1106 ms 37380 KB Output is correct
102 Correct 1364 ms 36692 KB Output is correct
103 Correct 1486 ms 38248 KB Output is correct
104 Correct 1363 ms 39356 KB Output is correct
105 Correct 795 ms 36248 KB Output is correct
106 Correct 1234 ms 38440 KB Output is correct
107 Correct 1220 ms 37444 KB Output is correct
108 Correct 1242 ms 37976 KB Output is correct
109 Correct 1240 ms 39028 KB Output is correct
110 Correct 1220 ms 38896 KB Output is correct
111 Correct 1221 ms 38168 KB Output is correct
112 Correct 1227 ms 39116 KB Output is correct
113 Correct 1208 ms 38048 KB Output is correct
114 Correct 1216 ms 37636 KB Output is correct
115 Correct 1214 ms 37328 KB Output is correct
116 Correct 1149 ms 37352 KB Output is correct