답안 #966744

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966744 2024-04-20T09:32:31 Z Soumya1 원 고르기 (APIO18_circle_selection) C++17
100 / 100
1018 ms 36944 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = 3e5 + 5;
int x[mxN], y[mxN], r[mxN], ans[mxN];
bool intersect(int a, int b) {
  return 1LL * (x[a] - x[b]) * (x[a] - x[b]) + 1LL * (y[a] - y[b]) * (y[a] - y[b]) <= 1LL * (r[a] + r[b]) * (r[a] + r[b]);
}
int block;
vector<int> all[mxN];
vector<pair<int, int>> vv;
int n;
int get(pair<int, int> p) {
  auto it = lower_bound(vv.begin(), vv.end(), p);
  if (it != vv.end() && *it == p) return it - vv.begin();
  return -1;
}
void scale() {
  vv.clear();
  for (int i = 0; i < n; i++) all[i].clear();
  for (int i = 0; i < n; i++) {
    if (ans[i]) continue;
    vv.push_back({x[i] / block, y[i] / block});
  }
  sort(vv.begin(), vv.end());
  vv.erase(unique(vv.begin(), vv.end()), vv.end());
  for (int i = 0; i < n; i++) {
    if (ans[i]) continue;
    all[get({x[i] / block, y[i] / block})].push_back(i);
  }
}
void testCase() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> r[i];
  }
  vector<int> ord(n);
  iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(), [&](int i, int j) {
    if (r[i] != r[j]) return r[i] > r[j];
    return i < j;
  });
  block = r[ord[0]];
  scale();
  for (int i : ord) {
    if (ans[i]) continue;
    if (2 * r[i] < block) {
      block = r[i];
      scale();
    }
    for (int xx = x[i] / block - 2; xx <= x[i] / block + 2; xx++) {
      for (int yy = y[i] / block - 2; yy <= y[i] / block + 2; yy++) {
        auto id = get({xx, yy});
        if (id == -1) continue;
        for (int j = 0; j < all[id].size(); ) {
          if (intersect(i, all[id][j])) {
            ans[all[id][j]] = i + 1;
            swap(all[id][j], all[id].back());
            all[id].pop_back();
          } else {
            j++;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  testCase();
  return 0;
}

Compilation message

circle_selection.cpp: In function 'void testCase()':
circle_selection.cpp:54:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for (int j = 0; j < all[id].size(); ) {
      |                         ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 10840 KB Output is correct
2 Correct 3 ms 10844 KB Output is correct
3 Correct 2 ms 10844 KB Output is correct
4 Correct 2 ms 10844 KB Output is correct
5 Correct 2 ms 10844 KB Output is correct
6 Correct 2 ms 10844 KB Output is correct
7 Correct 2 ms 10844 KB Output is correct
8 Correct 2 ms 10844 KB Output is correct
9 Correct 2 ms 10844 KB Output is correct
10 Correct 2 ms 10840 KB Output is correct
11 Correct 4 ms 10844 KB Output is correct
12 Correct 2 ms 10844 KB Output is correct
13 Correct 2 ms 10844 KB Output is correct
14 Correct 3 ms 10844 KB Output is correct
15 Correct 2 ms 10844 KB Output is correct
16 Correct 2 ms 11096 KB Output is correct
17 Correct 3 ms 10840 KB Output is correct
18 Correct 3 ms 10844 KB Output is correct
19 Correct 4 ms 11072 KB Output is correct
20 Correct 6 ms 10844 KB Output is correct
21 Correct 5 ms 10844 KB Output is correct
22 Correct 13 ms 11100 KB Output is correct
23 Correct 13 ms 11156 KB Output is correct
24 Correct 13 ms 11156 KB Output is correct
25 Correct 11 ms 11140 KB Output is correct
26 Correct 15 ms 10964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 21888 KB Output is correct
2 Correct 136 ms 20416 KB Output is correct
3 Correct 135 ms 20488 KB Output is correct
4 Correct 127 ms 22080 KB Output is correct
5 Correct 174 ms 20904 KB Output is correct
6 Correct 459 ms 22984 KB Output is correct
7 Correct 212 ms 19976 KB Output is correct
8 Correct 241 ms 21476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 10844 KB Output is correct
2 Correct 285 ms 16096 KB Output is correct
3 Correct 938 ms 35236 KB Output is correct
4 Correct 920 ms 35908 KB Output is correct
5 Correct 831 ms 34756 KB Output is correct
6 Correct 322 ms 22196 KB Output is correct
7 Correct 145 ms 16684 KB Output is correct
8 Correct 27 ms 11988 KB Output is correct
9 Correct 1004 ms 35488 KB Output is correct
10 Correct 734 ms 33488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 796 ms 31420 KB Output is correct
2 Correct 678 ms 30908 KB Output is correct
3 Correct 259 ms 26340 KB Output is correct
4 Correct 701 ms 31876 KB Output is correct
5 Correct 668 ms 32808 KB Output is correct
6 Correct 185 ms 24872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 10840 KB Output is correct
2 Correct 3 ms 10844 KB Output is correct
3 Correct 2 ms 10844 KB Output is correct
4 Correct 2 ms 10844 KB Output is correct
5 Correct 2 ms 10844 KB Output is correct
6 Correct 2 ms 10844 KB Output is correct
7 Correct 2 ms 10844 KB Output is correct
8 Correct 2 ms 10844 KB Output is correct
9 Correct 2 ms 10844 KB Output is correct
10 Correct 2 ms 10840 KB Output is correct
11 Correct 4 ms 10844 KB Output is correct
12 Correct 2 ms 10844 KB Output is correct
13 Correct 2 ms 10844 KB Output is correct
14 Correct 3 ms 10844 KB Output is correct
15 Correct 2 ms 10844 KB Output is correct
16 Correct 2 ms 11096 KB Output is correct
17 Correct 3 ms 10840 KB Output is correct
18 Correct 3 ms 10844 KB Output is correct
19 Correct 4 ms 11072 KB Output is correct
20 Correct 6 ms 10844 KB Output is correct
21 Correct 5 ms 10844 KB Output is correct
22 Correct 13 ms 11100 KB Output is correct
23 Correct 13 ms 11156 KB Output is correct
24 Correct 13 ms 11156 KB Output is correct
25 Correct 11 ms 11140 KB Output is correct
26 Correct 15 ms 10964 KB Output is correct
27 Correct 7 ms 11356 KB Output is correct
28 Correct 7 ms 11412 KB Output is correct
29 Correct 7 ms 11352 KB Output is correct
30 Correct 26 ms 11652 KB Output is correct
31 Correct 23 ms 11612 KB Output is correct
32 Correct 26 ms 11652 KB Output is correct
33 Correct 54 ms 15536 KB Output is correct
34 Correct 52 ms 15564 KB Output is correct
35 Correct 55 ms 15372 KB Output is correct
36 Correct 286 ms 17492 KB Output is correct
37 Correct 271 ms 18740 KB Output is correct
38 Correct 286 ms 18772 KB Output is correct
39 Correct 236 ms 17868 KB Output is correct
40 Correct 231 ms 17948 KB Output is correct
41 Correct 213 ms 17920 KB Output is correct
42 Correct 122 ms 17724 KB Output is correct
43 Correct 193 ms 18640 KB Output is correct
44 Correct 195 ms 18556 KB Output is correct
45 Correct 195 ms 18636 KB Output is correct
46 Correct 204 ms 18588 KB Output is correct
47 Correct 193 ms 18636 KB Output is correct
48 Correct 231 ms 18640 KB Output is correct
49 Correct 207 ms 18640 KB Output is correct
50 Correct 196 ms 18640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 10840 KB Output is correct
2 Correct 3 ms 10844 KB Output is correct
3 Correct 2 ms 10844 KB Output is correct
4 Correct 2 ms 10844 KB Output is correct
5 Correct 2 ms 10844 KB Output is correct
6 Correct 2 ms 10844 KB Output is correct
7 Correct 2 ms 10844 KB Output is correct
8 Correct 2 ms 10844 KB Output is correct
9 Correct 2 ms 10844 KB Output is correct
10 Correct 2 ms 10840 KB Output is correct
11 Correct 4 ms 10844 KB Output is correct
12 Correct 2 ms 10844 KB Output is correct
13 Correct 2 ms 10844 KB Output is correct
14 Correct 3 ms 10844 KB Output is correct
15 Correct 2 ms 10844 KB Output is correct
16 Correct 2 ms 11096 KB Output is correct
17 Correct 3 ms 10840 KB Output is correct
18 Correct 3 ms 10844 KB Output is correct
19 Correct 4 ms 11072 KB Output is correct
20 Correct 6 ms 10844 KB Output is correct
21 Correct 5 ms 10844 KB Output is correct
22 Correct 13 ms 11100 KB Output is correct
23 Correct 13 ms 11156 KB Output is correct
24 Correct 13 ms 11156 KB Output is correct
25 Correct 11 ms 11140 KB Output is correct
26 Correct 15 ms 10964 KB Output is correct
27 Correct 126 ms 21888 KB Output is correct
28 Correct 136 ms 20416 KB Output is correct
29 Correct 135 ms 20488 KB Output is correct
30 Correct 127 ms 22080 KB Output is correct
31 Correct 174 ms 20904 KB Output is correct
32 Correct 459 ms 22984 KB Output is correct
33 Correct 212 ms 19976 KB Output is correct
34 Correct 241 ms 21476 KB Output is correct
35 Correct 3 ms 10844 KB Output is correct
36 Correct 285 ms 16096 KB Output is correct
37 Correct 938 ms 35236 KB Output is correct
38 Correct 920 ms 35908 KB Output is correct
39 Correct 831 ms 34756 KB Output is correct
40 Correct 322 ms 22196 KB Output is correct
41 Correct 145 ms 16684 KB Output is correct
42 Correct 27 ms 11988 KB Output is correct
43 Correct 1004 ms 35488 KB Output is correct
44 Correct 734 ms 33488 KB Output is correct
45 Correct 796 ms 31420 KB Output is correct
46 Correct 678 ms 30908 KB Output is correct
47 Correct 259 ms 26340 KB Output is correct
48 Correct 701 ms 31876 KB Output is correct
49 Correct 668 ms 32808 KB Output is correct
50 Correct 185 ms 24872 KB Output is correct
51 Correct 7 ms 11356 KB Output is correct
52 Correct 7 ms 11412 KB Output is correct
53 Correct 7 ms 11352 KB Output is correct
54 Correct 26 ms 11652 KB Output is correct
55 Correct 23 ms 11612 KB Output is correct
56 Correct 26 ms 11652 KB Output is correct
57 Correct 54 ms 15536 KB Output is correct
58 Correct 52 ms 15564 KB Output is correct
59 Correct 55 ms 15372 KB Output is correct
60 Correct 286 ms 17492 KB Output is correct
61 Correct 271 ms 18740 KB Output is correct
62 Correct 286 ms 18772 KB Output is correct
63 Correct 236 ms 17868 KB Output is correct
64 Correct 231 ms 17948 KB Output is correct
65 Correct 213 ms 17920 KB Output is correct
66 Correct 122 ms 17724 KB Output is correct
67 Correct 193 ms 18640 KB Output is correct
68 Correct 195 ms 18556 KB Output is correct
69 Correct 195 ms 18636 KB Output is correct
70 Correct 204 ms 18588 KB Output is correct
71 Correct 193 ms 18636 KB Output is correct
72 Correct 231 ms 18640 KB Output is correct
73 Correct 207 ms 18640 KB Output is correct
74 Correct 196 ms 18640 KB Output is correct
75 Correct 154 ms 29624 KB Output is correct
76 Correct 145 ms 30180 KB Output is correct
77 Correct 153 ms 29132 KB Output is correct
78 Correct 132 ms 28568 KB Output is correct
79 Correct 197 ms 30120 KB Output is correct
80 Correct 150 ms 31164 KB Output is correct
81 Correct 954 ms 35704 KB Output is correct
82 Correct 919 ms 36028 KB Output is correct
83 Correct 932 ms 35716 KB Output is correct
84 Correct 951 ms 36944 KB Output is correct
85 Correct 915 ms 35468 KB Output is correct
86 Correct 934 ms 35524 KB Output is correct
87 Correct 1018 ms 36312 KB Output is correct
88 Correct 776 ms 34324 KB Output is correct
89 Correct 764 ms 34276 KB Output is correct
90 Correct 797 ms 33536 KB Output is correct
91 Correct 776 ms 32708 KB Output is correct
92 Correct 831 ms 33472 KB Output is correct
93 Correct 792 ms 33824 KB Output is correct
94 Correct 762 ms 35444 KB Output is correct
95 Correct 776 ms 34212 KB Output is correct
96 Correct 770 ms 35236 KB Output is correct
97 Correct 927 ms 34540 KB Output is correct
98 Correct 553 ms 31428 KB Output is correct
99 Correct 823 ms 34484 KB Output is correct
100 Correct 705 ms 34500 KB Output is correct
101 Correct 688 ms 32380 KB Output is correct
102 Correct 777 ms 35268 KB Output is correct
103 Correct 942 ms 35424 KB Output is correct
104 Correct 782 ms 35152 KB Output is correct
105 Correct 449 ms 33440 KB Output is correct
106 Correct 604 ms 34516 KB Output is correct
107 Correct 645 ms 34320 KB Output is correct
108 Correct 628 ms 34520 KB Output is correct
109 Correct 598 ms 34084 KB Output is correct
110 Correct 624 ms 34432 KB Output is correct
111 Correct 588 ms 34704 KB Output is correct
112 Correct 609 ms 35856 KB Output is correct
113 Correct 641 ms 34204 KB Output is correct
114 Correct 665 ms 34120 KB Output is correct
115 Correct 633 ms 35772 KB Output is correct
116 Correct 596 ms 35756 KB Output is correct