답안 #797394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797394 2023-07-29T10:19:40 Z radaiosm7 원 고르기 (APIO18_circle_selection) C++
7 / 100
3000 ms 19632 KB
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
int n, i, j, curr, chk;
long long R1, R2;
int ans[300005];
pair<long long, int> rd[300005];
pair<long long, long long> pnt[300005];

bool cmp(const pair<long long, int>& a, const pair<long long, int>& b) {
  if (a.X == b.X) return a.Y < b.Y;
  else return a.X > b.X;
}

bool val(int x, int y) {
  return (pnt[x].X-pnt[y].X)*(pnt[x].X-pnt[y].X) + (pnt[x].Y-pnt[y].Y)*(pnt[x].Y-pnt[y].Y) <= (R1+R2)*(R1+R2);
}

int main() {
  scanf("%d", &n);

  for (i=1; i <= n; ++i) {
    scanf("%lld%lld%lld", &pnt[i].X, &pnt[i].Y, &rd[i].X);
    rd[i].Y = i;
  }

  sort(rd+1, rd+n+1, cmp);
  fill(ans, ans+n+1, -1);

  for (i=1; i <= n; ++i) {
    curr = rd[i].Y;
    R1 = rd[i].X;

    if (ans[curr] == -1) {
      ans[curr] = curr;
      
      for (j=i+1; j <= n; ++j) {
        chk = rd[j].Y;
        R2 = rd[j].X;
        if (ans[chk] == -1 && val(curr, chk)) ans[chk] = curr;
      }
    }
  }
  
  for (i=1; i < n; ++i) printf("%d ", ans[i]);
  printf("%d\n", ans[n]);
  return 0;
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
circle_selection.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%lld%lld%lld", &pnt[i].X, &pnt[i].Y, &rd[i].X);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 308 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 2 ms 596 KB Output is correct
20 Correct 4 ms 572 KB Output is correct
21 Correct 3 ms 572 KB Output is correct
22 Correct 28 ms 620 KB Output is correct
23 Correct 41 ms 612 KB Output is correct
24 Correct 28 ms 628 KB Output is correct
25 Correct 28 ms 608 KB Output is correct
26 Correct 27 ms 616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 120 ms 19632 KB Output is correct
2 Correct 141 ms 19560 KB Output is correct
3 Correct 124 ms 19364 KB Output is correct
4 Correct 124 ms 19604 KB Output is correct
5 Execution timed out 3083 ms 15456 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 3064 ms 6488 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3027 ms 18624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 308 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 2 ms 596 KB Output is correct
20 Correct 4 ms 572 KB Output is correct
21 Correct 3 ms 572 KB Output is correct
22 Correct 28 ms 620 KB Output is correct
23 Correct 41 ms 612 KB Output is correct
24 Correct 28 ms 628 KB Output is correct
25 Correct 28 ms 608 KB Output is correct
26 Correct 27 ms 616 KB Output is correct
27 Correct 5 ms 944 KB Output is correct
28 Correct 5 ms 1020 KB Output is correct
29 Correct 4 ms 980 KB Output is correct
30 Correct 116 ms 956 KB Output is correct
31 Correct 111 ms 908 KB Output is correct
32 Correct 131 ms 916 KB Output is correct
33 Correct 42 ms 7424 KB Output is correct
34 Correct 42 ms 7492 KB Output is correct
35 Correct 62 ms 7256 KB Output is correct
36 Execution timed out 3085 ms 6308 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 308 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 2 ms 596 KB Output is correct
20 Correct 4 ms 572 KB Output is correct
21 Correct 3 ms 572 KB Output is correct
22 Correct 28 ms 620 KB Output is correct
23 Correct 41 ms 612 KB Output is correct
24 Correct 28 ms 628 KB Output is correct
25 Correct 28 ms 608 KB Output is correct
26 Correct 27 ms 616 KB Output is correct
27 Correct 120 ms 19632 KB Output is correct
28 Correct 141 ms 19560 KB Output is correct
29 Correct 124 ms 19364 KB Output is correct
30 Correct 124 ms 19604 KB Output is correct
31 Execution timed out 3083 ms 15456 KB Time limit exceeded
32 Halted 0 ms 0 KB -