Submission #895814

# Submission time Handle Problem Language Result Execution time Memory
895814 2023-12-30T21:48:54 Z MilosMilutinovic Circle selection (APIO18_circle_selection) C++14
49 / 100
3000 ms 30292 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))) {
        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 2 ms 4444 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 4444 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 4696 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 4952 KB Output is correct
20 Correct 3 ms 4892 KB Output is correct
21 Correct 3 ms 4892 KB Output is correct
22 Correct 42 ms 4972 KB Output is correct
23 Correct 43 ms 4976 KB Output is correct
24 Correct 41 ms 4972 KB Output is correct
25 Correct 38 ms 5068 KB Output is correct
26 Correct 40 ms 4972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 29716 KB Output is correct
2 Correct 183 ms 29892 KB Output is correct
3 Correct 182 ms 29240 KB Output is correct
4 Correct 138 ms 22604 KB Output is correct
5 Correct 806 ms 29720 KB Output is correct
6 Correct 1295 ms 29500 KB Output is correct
7 Correct 848 ms 29944 KB Output is correct
8 Correct 967 ms 29712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1293 ms 13096 KB Output is correct
3 Execution timed out 3022 ms 30292 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3101 ms 29952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 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 4444 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 4696 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 4952 KB Output is correct
20 Correct 3 ms 4892 KB Output is correct
21 Correct 3 ms 4892 KB Output is correct
22 Correct 42 ms 4972 KB Output is correct
23 Correct 43 ms 4976 KB Output is correct
24 Correct 41 ms 4972 KB Output is correct
25 Correct 38 ms 5068 KB Output is correct
26 Correct 40 ms 4972 KB Output is correct
27 Correct 6 ms 5224 KB Output is correct
28 Correct 6 ms 5152 KB Output is correct
29 Correct 7 ms 5228 KB Output is correct
30 Correct 87 ms 5360 KB Output is correct
31 Correct 85 ms 5384 KB Output is correct
32 Correct 89 ms 5500 KB Output is correct
33 Correct 47 ms 12156 KB Output is correct
34 Correct 47 ms 10956 KB Output is correct
35 Correct 68 ms 13492 KB Output is correct
36 Correct 1016 ms 13760 KB Output is correct
37 Correct 1028 ms 14084 KB Output is correct
38 Correct 1098 ms 13036 KB Output is correct
39 Correct 559 ms 13020 KB Output is correct
40 Correct 547 ms 13736 KB Output is correct
41 Correct 364 ms 13148 KB Output is correct
42 Correct 295 ms 13200 KB Output is correct
43 Correct 794 ms 13004 KB Output is correct
44 Correct 799 ms 13244 KB Output is correct
45 Correct 813 ms 13024 KB Output is correct
46 Correct 803 ms 13640 KB Output is correct
47 Correct 811 ms 13020 KB Output is correct
48 Correct 817 ms 13012 KB Output is correct
49 Correct 809 ms 13628 KB Output is correct
50 Correct 814 ms 13036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 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 4444 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 4696 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 4952 KB Output is correct
20 Correct 3 ms 4892 KB Output is correct
21 Correct 3 ms 4892 KB Output is correct
22 Correct 42 ms 4972 KB Output is correct
23 Correct 43 ms 4976 KB Output is correct
24 Correct 41 ms 4972 KB Output is correct
25 Correct 38 ms 5068 KB Output is correct
26 Correct 40 ms 4972 KB Output is correct
27 Correct 152 ms 29716 KB Output is correct
28 Correct 183 ms 29892 KB Output is correct
29 Correct 182 ms 29240 KB Output is correct
30 Correct 138 ms 22604 KB Output is correct
31 Correct 806 ms 29720 KB Output is correct
32 Correct 1295 ms 29500 KB Output is correct
33 Correct 848 ms 29944 KB Output is correct
34 Correct 967 ms 29712 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1293 ms 13096 KB Output is correct
37 Execution timed out 3022 ms 30292 KB Time limit exceeded
38 Halted 0 ms 0 KB -