답안 #734476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734476 2023-05-02T13:56:57 Z vjudge1 원 고르기 (APIO18_circle_selection) C++14
100 / 100
622 ms 41028 KB
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=j; i<=k; ++i)
#define ROF(i,j,k) for(int i=j; i>=k; --i)
inline int read (void) {
  int x = 0, f = 1, ch = getchar();
  while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
  while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}
using ll = long long;
const int maxn = 300005;
const int inf = 1e9;
struct hash_table {
  #define mod 611953
  #define base 7919
  std::list <int> v[mod];
  inline int ask (int x, int y) {
    return ((1ll * base * x + y) % mod + mod) % mod;
  }
  inline void ins (int x, int y, int id) {
    v[ask (x, y)].push_back (id);
  }
  inline void clear (void) {
    FOR(i,0,mod-1) v[i].clear();
  }
  #undef mod
  #undef base
} ht;
struct Node {
  int x, y, r;
} node[maxn];
inline ll pw (ll x) { return x * x; }
inline bool check (int p, int q) {
  return pw (node[p].x - node[q].x) + pw (node[p].y - node[q].y) <= pw (node[p].r + node[q].r);
}
int n, B, a[maxn], ans[maxn];
inline bool cmp (int p, int q) {
  return node[p].r != node[q].r ? node[p].r > node[q].r : p < q;
}
inline void rebuild (int r) {
  ht.clear (); B = r; FOR(i,1,n) if(!ans[i])
    ht.ins ((node[i].x + inf) / B, (node[i].y + inf) / B, i);
}
int main (void) {
  n = read();
  FOR(i,1,n) {
    int x = read(), y = read(), r = read();
    node[i] = {x, y, r};
  }
  std::iota (a+1, a+n+1, 1);
  std::sort (a+1, a+n+1, cmp);
  rebuild (node[a[1]].r * 2);
  FOR(i,1,n) if(!ans[a[i]]) {
    if(B > 4ll * node[a[i]].r) rebuild (node[a[i]].r * 2);
    int x = (node[a[i]].x + inf) / B, y = (node[a[i]].y + inf) / B, k;
    FOR(dx,-1,1) FOR(dy,-1,1) {
      k = ht.ask (x + dx, y + dy);
      for(auto it=ht.v[k].begin(); it!=ht.v[k].end(); )
        if(check(a[i], *it)) {
          ans[*it] = a[i];
          ht.v[k].erase (it ++);
        } else ++ it;
    }
  }
  FOR(i,1,n) printf("%d%c", ans[i], i==n?10:32);
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 14676 KB Output is correct
2 Correct 13 ms 14680 KB Output is correct
3 Correct 14 ms 14704 KB Output is correct
4 Correct 12 ms 14696 KB Output is correct
5 Correct 10 ms 14676 KB Output is correct
6 Correct 12 ms 14672 KB Output is correct
7 Correct 13 ms 14704 KB Output is correct
8 Correct 11 ms 14680 KB Output is correct
9 Correct 15 ms 14676 KB Output is correct
10 Correct 12 ms 14704 KB Output is correct
11 Correct 19 ms 14700 KB Output is correct
12 Correct 21 ms 14700 KB Output is correct
13 Correct 21 ms 14676 KB Output is correct
14 Correct 20 ms 14676 KB Output is correct
15 Correct 18 ms 14664 KB Output is correct
16 Correct 19 ms 14764 KB Output is correct
17 Correct 10 ms 14676 KB Output is correct
18 Correct 12 ms 14732 KB Output is correct
19 Correct 15 ms 15008 KB Output is correct
20 Correct 13 ms 15112 KB Output is correct
21 Correct 16 ms 15008 KB Output is correct
22 Correct 38 ms 15052 KB Output is correct
23 Correct 35 ms 14984 KB Output is correct
24 Correct 34 ms 15076 KB Output is correct
25 Correct 32 ms 15060 KB Output is correct
26 Correct 33 ms 15004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 38756 KB Output is correct
2 Correct 173 ms 38600 KB Output is correct
3 Correct 156 ms 38352 KB Output is correct
4 Correct 183 ms 38760 KB Output is correct
5 Correct 219 ms 36444 KB Output is correct
6 Correct 344 ms 36536 KB Output is correct
7 Correct 238 ms 36592 KB Output is correct
8 Correct 275 ms 36568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 14676 KB Output is correct
2 Correct 165 ms 23048 KB Output is correct
3 Correct 530 ms 39964 KB Output is correct
4 Correct 511 ms 39920 KB Output is correct
5 Correct 521 ms 39456 KB Output is correct
6 Correct 219 ms 27820 KB Output is correct
7 Correct 108 ms 21492 KB Output is correct
8 Correct 31 ms 15972 KB Output is correct
9 Correct 602 ms 39944 KB Output is correct
10 Correct 506 ms 40296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 298 ms 39792 KB Output is correct
2 Correct 294 ms 38892 KB Output is correct
3 Correct 217 ms 39888 KB Output is correct
4 Correct 259 ms 39332 KB Output is correct
5 Correct 268 ms 39408 KB Output is correct
6 Correct 180 ms 39752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 14676 KB Output is correct
2 Correct 13 ms 14680 KB Output is correct
3 Correct 14 ms 14704 KB Output is correct
4 Correct 12 ms 14696 KB Output is correct
5 Correct 10 ms 14676 KB Output is correct
6 Correct 12 ms 14672 KB Output is correct
7 Correct 13 ms 14704 KB Output is correct
8 Correct 11 ms 14680 KB Output is correct
9 Correct 15 ms 14676 KB Output is correct
10 Correct 12 ms 14704 KB Output is correct
11 Correct 19 ms 14700 KB Output is correct
12 Correct 21 ms 14700 KB Output is correct
13 Correct 21 ms 14676 KB Output is correct
14 Correct 20 ms 14676 KB Output is correct
15 Correct 18 ms 14664 KB Output is correct
16 Correct 19 ms 14764 KB Output is correct
17 Correct 10 ms 14676 KB Output is correct
18 Correct 12 ms 14732 KB Output is correct
19 Correct 15 ms 15008 KB Output is correct
20 Correct 13 ms 15112 KB Output is correct
21 Correct 16 ms 15008 KB Output is correct
22 Correct 38 ms 15052 KB Output is correct
23 Correct 35 ms 14984 KB Output is correct
24 Correct 34 ms 15076 KB Output is correct
25 Correct 32 ms 15060 KB Output is correct
26 Correct 33 ms 15004 KB Output is correct
27 Correct 22 ms 15444 KB Output is correct
28 Correct 14 ms 15536 KB Output is correct
29 Correct 13 ms 15444 KB Output is correct
30 Correct 38 ms 15488 KB Output is correct
31 Correct 36 ms 15444 KB Output is correct
32 Correct 40 ms 15452 KB Output is correct
33 Correct 59 ms 23424 KB Output is correct
34 Correct 54 ms 23396 KB Output is correct
35 Correct 90 ms 23244 KB Output is correct
36 Correct 153 ms 22796 KB Output is correct
37 Correct 164 ms 22964 KB Output is correct
38 Correct 146 ms 22956 KB Output is correct
39 Correct 184 ms 21416 KB Output is correct
40 Correct 189 ms 21440 KB Output is correct
41 Correct 182 ms 21472 KB Output is correct
42 Correct 59 ms 21888 KB Output is correct
43 Correct 82 ms 22952 KB Output is correct
44 Correct 78 ms 22860 KB Output is correct
45 Correct 79 ms 22892 KB Output is correct
46 Correct 79 ms 22936 KB Output is correct
47 Correct 78 ms 22864 KB Output is correct
48 Correct 78 ms 22988 KB Output is correct
49 Correct 80 ms 22932 KB Output is correct
50 Correct 82 ms 22868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 14676 KB Output is correct
2 Correct 13 ms 14680 KB Output is correct
3 Correct 14 ms 14704 KB Output is correct
4 Correct 12 ms 14696 KB Output is correct
5 Correct 10 ms 14676 KB Output is correct
6 Correct 12 ms 14672 KB Output is correct
7 Correct 13 ms 14704 KB Output is correct
8 Correct 11 ms 14680 KB Output is correct
9 Correct 15 ms 14676 KB Output is correct
10 Correct 12 ms 14704 KB Output is correct
11 Correct 19 ms 14700 KB Output is correct
12 Correct 21 ms 14700 KB Output is correct
13 Correct 21 ms 14676 KB Output is correct
14 Correct 20 ms 14676 KB Output is correct
15 Correct 18 ms 14664 KB Output is correct
16 Correct 19 ms 14764 KB Output is correct
17 Correct 10 ms 14676 KB Output is correct
18 Correct 12 ms 14732 KB Output is correct
19 Correct 15 ms 15008 KB Output is correct
20 Correct 13 ms 15112 KB Output is correct
21 Correct 16 ms 15008 KB Output is correct
22 Correct 38 ms 15052 KB Output is correct
23 Correct 35 ms 14984 KB Output is correct
24 Correct 34 ms 15076 KB Output is correct
25 Correct 32 ms 15060 KB Output is correct
26 Correct 33 ms 15004 KB Output is correct
27 Correct 143 ms 38756 KB Output is correct
28 Correct 173 ms 38600 KB Output is correct
29 Correct 156 ms 38352 KB Output is correct
30 Correct 183 ms 38760 KB Output is correct
31 Correct 219 ms 36444 KB Output is correct
32 Correct 344 ms 36536 KB Output is correct
33 Correct 238 ms 36592 KB Output is correct
34 Correct 275 ms 36568 KB Output is correct
35 Correct 19 ms 14676 KB Output is correct
36 Correct 165 ms 23048 KB Output is correct
37 Correct 530 ms 39964 KB Output is correct
38 Correct 511 ms 39920 KB Output is correct
39 Correct 521 ms 39456 KB Output is correct
40 Correct 219 ms 27820 KB Output is correct
41 Correct 108 ms 21492 KB Output is correct
42 Correct 31 ms 15972 KB Output is correct
43 Correct 602 ms 39944 KB Output is correct
44 Correct 506 ms 40296 KB Output is correct
45 Correct 298 ms 39792 KB Output is correct
46 Correct 294 ms 38892 KB Output is correct
47 Correct 217 ms 39888 KB Output is correct
48 Correct 259 ms 39332 KB Output is correct
49 Correct 268 ms 39408 KB Output is correct
50 Correct 180 ms 39752 KB Output is correct
51 Correct 22 ms 15444 KB Output is correct
52 Correct 14 ms 15536 KB Output is correct
53 Correct 13 ms 15444 KB Output is correct
54 Correct 38 ms 15488 KB Output is correct
55 Correct 36 ms 15444 KB Output is correct
56 Correct 40 ms 15452 KB Output is correct
57 Correct 59 ms 23424 KB Output is correct
58 Correct 54 ms 23396 KB Output is correct
59 Correct 90 ms 23244 KB Output is correct
60 Correct 153 ms 22796 KB Output is correct
61 Correct 164 ms 22964 KB Output is correct
62 Correct 146 ms 22956 KB Output is correct
63 Correct 184 ms 21416 KB Output is correct
64 Correct 189 ms 21440 KB Output is correct
65 Correct 182 ms 21472 KB Output is correct
66 Correct 59 ms 21888 KB Output is correct
67 Correct 82 ms 22952 KB Output is correct
68 Correct 78 ms 22860 KB Output is correct
69 Correct 79 ms 22892 KB Output is correct
70 Correct 79 ms 22936 KB Output is correct
71 Correct 78 ms 22864 KB Output is correct
72 Correct 78 ms 22988 KB Output is correct
73 Correct 80 ms 22932 KB Output is correct
74 Correct 82 ms 22868 KB Output is correct
75 Correct 174 ms 41028 KB Output is correct
76 Correct 164 ms 40700 KB Output is correct
77 Correct 146 ms 40884 KB Output is correct
78 Correct 154 ms 40704 KB Output is correct
79 Correct 274 ms 40516 KB Output is correct
80 Correct 158 ms 40656 KB Output is correct
81 Correct 487 ms 39848 KB Output is correct
82 Correct 480 ms 39732 KB Output is correct
83 Correct 465 ms 39648 KB Output is correct
84 Correct 434 ms 40208 KB Output is correct
85 Correct 469 ms 39724 KB Output is correct
86 Correct 462 ms 39816 KB Output is correct
87 Correct 454 ms 39900 KB Output is correct
88 Correct 549 ms 35060 KB Output is correct
89 Correct 622 ms 35060 KB Output is correct
90 Correct 519 ms 35080 KB Output is correct
91 Correct 577 ms 35036 KB Output is correct
92 Correct 606 ms 35144 KB Output is correct
93 Correct 406 ms 38780 KB Output is correct
94 Correct 478 ms 39312 KB Output is correct
95 Correct 431 ms 38760 KB Output is correct
96 Correct 482 ms 38768 KB Output is correct
97 Correct 387 ms 38700 KB Output is correct
98 Correct 302 ms 39376 KB Output is correct
99 Correct 405 ms 39032 KB Output is correct
100 Correct 365 ms 38656 KB Output is correct
101 Correct 370 ms 39244 KB Output is correct
102 Correct 400 ms 38836 KB Output is correct
103 Correct 418 ms 38900 KB Output is correct
104 Correct 454 ms 38620 KB Output is correct
105 Correct 205 ms 36600 KB Output is correct
106 Correct 253 ms 39620 KB Output is correct
107 Correct 257 ms 39616 KB Output is correct
108 Correct 242 ms 39628 KB Output is correct
109 Correct 227 ms 39608 KB Output is correct
110 Correct 245 ms 39628 KB Output is correct
111 Correct 251 ms 39544 KB Output is correct
112 Correct 244 ms 39688 KB Output is correct
113 Correct 244 ms 39628 KB Output is correct
114 Correct 249 ms 39600 KB Output is correct
115 Correct 240 ms 39596 KB Output is correct
116 Correct 240 ms 39572 KB Output is correct