Submission #895809

# Submission time Handle Problem Language Result Execution time Memory
895809 2023-12-30T21:39:08 Z MilosMilutinovic Circle selection (APIO18_circle_selection) C++14
7 / 100
3000 ms 31256 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 - 2) - 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 348 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 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 456 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 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 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 932 KB Output is correct
21 Correct 3 ms 928 KB Output is correct
22 Correct 255 ms 1036 KB Output is correct
23 Correct 223 ms 1028 KB Output is correct
24 Correct 261 ms 1032 KB Output is correct
25 Correct 242 ms 1020 KB Output is correct
26 Correct 214 ms 1036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 156 ms 28860 KB Output is correct
2 Correct 155 ms 30284 KB Output is correct
3 Correct 153 ms 29376 KB Output is correct
4 Correct 151 ms 30424 KB Output is correct
5 Execution timed out 3039 ms 28096 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 3093 ms 9412 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3023 ms 31256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 456 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 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 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 932 KB Output is correct
21 Correct 3 ms 928 KB Output is correct
22 Correct 255 ms 1036 KB Output is correct
23 Correct 223 ms 1028 KB Output is correct
24 Correct 261 ms 1032 KB Output is correct
25 Correct 242 ms 1020 KB Output is correct
26 Correct 214 ms 1036 KB Output is correct
27 Correct 5 ms 1564 KB Output is correct
28 Correct 6 ms 1568 KB Output is correct
29 Correct 5 ms 1444 KB Output is correct
30 Correct 806 ms 1756 KB Output is correct
31 Correct 1190 ms 1700 KB Output is correct
32 Correct 859 ms 1708 KB Output is correct
33 Correct 50 ms 10948 KB Output is correct
34 Correct 50 ms 9680 KB Output is correct
35 Correct 85 ms 9696 KB Output is correct
36 Execution timed out 3056 ms 9672 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 456 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 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 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 932 KB Output is correct
21 Correct 3 ms 928 KB Output is correct
22 Correct 255 ms 1036 KB Output is correct
23 Correct 223 ms 1028 KB Output is correct
24 Correct 261 ms 1032 KB Output is correct
25 Correct 242 ms 1020 KB Output is correct
26 Correct 214 ms 1036 KB Output is correct
27 Correct 156 ms 28860 KB Output is correct
28 Correct 155 ms 30284 KB Output is correct
29 Correct 153 ms 29376 KB Output is correct
30 Correct 151 ms 30424 KB Output is correct
31 Execution timed out 3039 ms 28096 KB Time limit exceeded
32 Halted 0 ms 0 KB -