Submission #895810

# Submission time Handle Problem Language Result Execution time Memory
895810 2023-12-30T21:40:47 Z MilosMilutinovic Circle selection (APIO18_circle_selection) C++14
7 / 100
3000 ms 24256 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) {
        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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 500 KB Output is correct
5 Correct 0 ms 600 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 0 ms 348 KB Output is correct
10 Correct 1 ms 348 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 3 ms 864 KB Output is correct
22 Correct 335 ms 892 KB Output is correct
23 Correct 286 ms 976 KB Output is correct
24 Correct 333 ms 892 KB Output is correct
25 Correct 301 ms 920 KB Output is correct
26 Correct 287 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 22952 KB Output is correct
2 Correct 154 ms 23116 KB Output is correct
3 Correct 166 ms 22204 KB Output is correct
4 Correct 160 ms 24256 KB Output is correct
5 Execution timed out 3073 ms 22464 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 3073 ms 7796 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3016 ms 23740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 500 KB Output is correct
5 Correct 0 ms 600 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 0 ms 348 KB Output is correct
10 Correct 1 ms 348 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 3 ms 864 KB Output is correct
22 Correct 335 ms 892 KB Output is correct
23 Correct 286 ms 976 KB Output is correct
24 Correct 333 ms 892 KB Output is correct
25 Correct 301 ms 920 KB Output is correct
26 Correct 287 ms 888 KB Output is correct
27 Correct 6 ms 1116 KB Output is correct
28 Correct 7 ms 1176 KB Output is correct
29 Correct 5 ms 1116 KB Output is correct
30 Correct 1097 ms 1420 KB Output is correct
31 Correct 1467 ms 1648 KB Output is correct
32 Correct 1146 ms 1364 KB Output is correct
33 Correct 53 ms 7796 KB Output is correct
34 Correct 50 ms 7368 KB Output is correct
35 Correct 84 ms 6768 KB Output is correct
36 Execution timed out 3080 ms 8048 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 500 KB Output is correct
5 Correct 0 ms 600 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 0 ms 348 KB Output is correct
10 Correct 1 ms 348 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 3 ms 864 KB Output is correct
22 Correct 335 ms 892 KB Output is correct
23 Correct 286 ms 976 KB Output is correct
24 Correct 333 ms 892 KB Output is correct
25 Correct 301 ms 920 KB Output is correct
26 Correct 287 ms 888 KB Output is correct
27 Correct 146 ms 22952 KB Output is correct
28 Correct 154 ms 23116 KB Output is correct
29 Correct 166 ms 22204 KB Output is correct
30 Correct 160 ms 24256 KB Output is correct
31 Execution timed out 3073 ms 22464 KB Time limit exceeded
32 Halted 0 ms 0 KB -