답안 #895813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895813 2023-12-30T21:45:45 Z MilosMilutinovic 원 고르기 (APIO18_circle_selection) C++14
49 / 100
3000 ms 37848 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> x(n), y(n), r(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;
    }
  });
  auto 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]);
  };
  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))) {
        continue;
      }
      for (int dx = -2; dx <= 2; dx++) {
        int ptr = (int) (lower_bound(v.begin(), v.end(), make_tuple(x[i] / k - dx, y[i] / k - 2, -1)) - v.begin());
        while (ptr < (int) v.size() && get<0>(v[ptr]) == x[i] / k - dx && abs((y[i] / k) - get<1>(v[ptr])) <= 2) {
          if (Good(i, get<2>(v[ptr]))) {
            int idx = get<2>(v[ptr]);
            if (res[idx] == idx && (r[idx] < r[i] || (r[i] == r[idx] && idx > i))) {
              res[idx] = i;
            }
          }
          ptr += 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] + 1 << " ";
  }
  cout << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 3 ms 860 KB Output is correct
20 Correct 3 ms 860 KB Output is correct
21 Correct 4 ms 828 KB Output is correct
22 Correct 41 ms 928 KB Output is correct
23 Correct 40 ms 928 KB Output is correct
24 Correct 42 ms 1088 KB Output is correct
25 Correct 38 ms 944 KB Output is correct
26 Correct 40 ms 932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 30256 KB Output is correct
2 Correct 196 ms 29580 KB Output is correct
3 Correct 192 ms 29896 KB Output is correct
4 Correct 146 ms 22960 KB Output is correct
5 Correct 833 ms 30596 KB Output is correct
6 Correct 1324 ms 35128 KB Output is correct
7 Correct 884 ms 34756 KB Output is correct
8 Correct 969 ms 35824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1364 ms 9792 KB Output is correct
3 Execution timed out 3082 ms 37848 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3048 ms 29812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 3 ms 860 KB Output is correct
20 Correct 3 ms 860 KB Output is correct
21 Correct 4 ms 828 KB Output is correct
22 Correct 41 ms 928 KB Output is correct
23 Correct 40 ms 928 KB Output is correct
24 Correct 42 ms 1088 KB Output is correct
25 Correct 38 ms 944 KB Output is correct
26 Correct 40 ms 932 KB Output is correct
27 Correct 9 ms 1392 KB Output is correct
28 Correct 7 ms 1236 KB Output is correct
29 Correct 7 ms 1392 KB Output is correct
30 Correct 91 ms 1480 KB Output is correct
31 Correct 86 ms 1396 KB Output is correct
32 Correct 85 ms 1392 KB Output is correct
33 Correct 50 ms 7876 KB Output is correct
34 Correct 50 ms 6664 KB Output is correct
35 Correct 75 ms 9012 KB Output is correct
36 Correct 1036 ms 9320 KB Output is correct
37 Correct 1048 ms 12328 KB Output is correct
38 Correct 1075 ms 11884 KB Output is correct
39 Correct 572 ms 10244 KB Output is correct
40 Correct 554 ms 10216 KB Output is correct
41 Correct 359 ms 10136 KB Output is correct
42 Correct 307 ms 11168 KB Output is correct
43 Correct 828 ms 11656 KB Output is correct
44 Correct 812 ms 12184 KB Output is correct
45 Correct 806 ms 12084 KB Output is correct
46 Correct 798 ms 11624 KB Output is correct
47 Correct 804 ms 12364 KB Output is correct
48 Correct 809 ms 11636 KB Output is correct
49 Correct 815 ms 11668 KB Output is correct
50 Correct 797 ms 12264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 3 ms 860 KB Output is correct
20 Correct 3 ms 860 KB Output is correct
21 Correct 4 ms 828 KB Output is correct
22 Correct 41 ms 928 KB Output is correct
23 Correct 40 ms 928 KB Output is correct
24 Correct 42 ms 1088 KB Output is correct
25 Correct 38 ms 944 KB Output is correct
26 Correct 40 ms 932 KB Output is correct
27 Correct 163 ms 30256 KB Output is correct
28 Correct 196 ms 29580 KB Output is correct
29 Correct 192 ms 29896 KB Output is correct
30 Correct 146 ms 22960 KB Output is correct
31 Correct 833 ms 30596 KB Output is correct
32 Correct 1324 ms 35128 KB Output is correct
33 Correct 884 ms 34756 KB Output is correct
34 Correct 969 ms 35824 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1364 ms 9792 KB Output is correct
37 Execution timed out 3082 ms 37848 KB Time limit exceeded
38 Halted 0 ms 0 KB -