Submission #905061

# Submission time Handle Problem Language Result Execution time Memory
905061 2024-01-12T13:38:04 Z nguyentunglam Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 18644 KB
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define endl "\n"
#define int long long
using namespace std;

const int N = 3e5 + 10;

int n;

int x[N], y[N], r[N];

int ans[N];

int32_t main() {
  #define task ""

  cin.tie(0) -> sync_with_stdio(0);

  if (fopen("task.inp", "r")) {
    freopen("task.inp", "r", stdin);
    freopen("task.out", "w", stdout);
  }

  if (fopen(task".inp", "r")) {
    freopen (task".inp", "r", stdin);
    freopen (task".out", "w", stdout);
  }

  cin >> n;

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

  while (1) {
    int idx = 0;
    for(int i = 1; i <= n; i++) if (!ans[i]) if (r[i] > r[idx]) idx = i;
    if (idx == 0) break;
    for(int i = 1; i <= n; i++) if (!ans[i]) {
      int dist = (x[i] - x[idx]) * (x[i] - x[idx]) + (y[i] - y[idx]) * (y[i] - y[idx]);
      if (dist <= (r[i] + r[idx]) * (r[i] + r[idx])) ans[i] = idx;
    }
  }

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



Compilation message

circle_selection.cpp: In function 'int32_t main()':
circle_selection.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen("task.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
circle_selection.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen("task.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
circle_selection.cpp:26:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen (task".inp", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
circle_selection.cpp:27:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen (task".out", "w", stdout);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6620 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6748 KB Output is correct
20 Correct 4 ms 6748 KB Output is correct
21 Correct 3 ms 6748 KB Output is correct
22 Correct 123 ms 6748 KB Output is correct
23 Correct 123 ms 6772 KB Output is correct
24 Correct 125 ms 6784 KB Output is correct
25 Correct 128 ms 6776 KB Output is correct
26 Correct 130 ms 6776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 18644 KB Output is correct
2 Correct 84 ms 18420 KB Output is correct
3 Correct 81 ms 18264 KB Output is correct
4 Correct 83 ms 18644 KB Output is correct
5 Execution timed out 3040 ms 14568 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6504 KB Output is correct
2 Execution timed out 3075 ms 10376 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3097 ms 15520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6620 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6748 KB Output is correct
20 Correct 4 ms 6748 KB Output is correct
21 Correct 3 ms 6748 KB Output is correct
22 Correct 123 ms 6748 KB Output is correct
23 Correct 123 ms 6772 KB Output is correct
24 Correct 125 ms 6784 KB Output is correct
25 Correct 128 ms 6776 KB Output is correct
26 Correct 130 ms 6776 KB Output is correct
27 Correct 6 ms 7004 KB Output is correct
28 Correct 5 ms 7004 KB Output is correct
29 Correct 5 ms 7004 KB Output is correct
30 Correct 565 ms 6932 KB Output is correct
31 Correct 567 ms 6936 KB Output is correct
32 Correct 550 ms 6944 KB Output is correct
33 Correct 31 ms 10964 KB Output is correct
34 Correct 32 ms 10944 KB Output is correct
35 Correct 46 ms 10836 KB Output is correct
36 Execution timed out 3048 ms 9792 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6620 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6748 KB Output is correct
20 Correct 4 ms 6748 KB Output is correct
21 Correct 3 ms 6748 KB Output is correct
22 Correct 123 ms 6748 KB Output is correct
23 Correct 123 ms 6772 KB Output is correct
24 Correct 125 ms 6784 KB Output is correct
25 Correct 128 ms 6776 KB Output is correct
26 Correct 130 ms 6776 KB Output is correct
27 Correct 82 ms 18644 KB Output is correct
28 Correct 84 ms 18420 KB Output is correct
29 Correct 81 ms 18264 KB Output is correct
30 Correct 83 ms 18644 KB Output is correct
31 Execution timed out 3040 ms 14568 KB Time limit exceeded
32 Halted 0 ms 0 KB -