Submission #658748

# Submission time Handle Problem Language Result Execution time Memory
658748 2022-11-14T20:02:54 Z 600Mihnea Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 15180 KB
bool home = 0;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = (int) 3e5 + 7;
int n;

struct Circle {
  int x;
  int y;
  int r;
};

bool doIntersect(Circle a, Circle b) {
  /// dist <= a.r + b.r
  /// dist ^  2 <= (a.r + b.r) ^ 2
  return 1LL * (a.x - b.x) * (a.x - b.x) + 1LL * (a.y - b.y) * (a.y - b.y) <= 1LL * (a.r + b.r) * (a.r + b.r);
}

Circle circles[N];
int ret[N];

int main() {
  if (home == 0) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  } else {
    freopen ("input.txt", "r", stdin);
  }

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> circles[i].x >> circles[i].y >> circles[i].r;
  }

  vector<int> inds(n);
  iota(inds.begin(), inds.end(), 1);

  while ((int) inds.size() >= 1) {
    int best = inds[0];
    for (auto &ind : inds) {
      if (circles[ind].r > circles[best].r || (circles[ind].r == circles[best].r && ind < best)) {
        best = ind;
      }
    }
    vector<int> newInds;
    for (auto &ind : inds) {
      if (doIntersect(circles[ind], circles[best])) {
        ret[ind] = best;
      } else {
        newInds.push_back(ind);
      }
    }
    inds = newInds;
  }

  for (int i = 1; i <= n; i++) {
    cout << ret[i] << " ";
  }
  cout << "\n";

  return 0;
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:31:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     freopen ("input.txt", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 372 KB Output is correct
19 Correct 3 ms 596 KB Output is correct
20 Correct 2 ms 528 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 60 ms 596 KB Output is correct
23 Correct 60 ms 604 KB Output is correct
24 Correct 59 ms 608 KB Output is correct
25 Correct 59 ms 612 KB Output is correct
26 Correct 62 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 8272 KB Output is correct
2 Correct 100 ms 15180 KB Output is correct
3 Correct 103 ms 14788 KB Output is correct
4 Correct 99 ms 14976 KB Output is correct
5 Correct 2027 ms 14896 KB Output is correct
6 Execution timed out 3068 ms 14340 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 3055 ms 6200 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3038 ms 8700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 372 KB Output is correct
19 Correct 3 ms 596 KB Output is correct
20 Correct 2 ms 528 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 60 ms 596 KB Output is correct
23 Correct 60 ms 604 KB Output is correct
24 Correct 59 ms 608 KB Output is correct
25 Correct 59 ms 612 KB Output is correct
26 Correct 62 ms 596 KB Output is correct
27 Correct 4 ms 852 KB Output is correct
28 Correct 4 ms 800 KB Output is correct
29 Correct 4 ms 856 KB Output is correct
30 Correct 225 ms 900 KB Output is correct
31 Correct 221 ms 880 KB Output is correct
32 Correct 224 ms 904 KB Output is correct
33 Correct 37 ms 5972 KB Output is correct
34 Correct 38 ms 5948 KB Output is correct
35 Correct 38 ms 5940 KB Output is correct
36 Execution timed out 3053 ms 6272 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 372 KB Output is correct
19 Correct 3 ms 596 KB Output is correct
20 Correct 2 ms 528 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 60 ms 596 KB Output is correct
23 Correct 60 ms 604 KB Output is correct
24 Correct 59 ms 608 KB Output is correct
25 Correct 59 ms 612 KB Output is correct
26 Correct 62 ms 596 KB Output is correct
27 Correct 95 ms 8272 KB Output is correct
28 Correct 100 ms 15180 KB Output is correct
29 Correct 103 ms 14788 KB Output is correct
30 Correct 99 ms 14976 KB Output is correct
31 Correct 2027 ms 14896 KB Output is correct
32 Execution timed out 3068 ms 14340 KB Time limit exceeded
33 Halted 0 ms 0 KB -