1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
ll n, r;
cin >> n >> r;
vector<pll> ma(n);
rep(i, 0, n - 1) cin >> ma[i].first >> ma[i].second;
ll bias = 1e5;
ll tem = 0;
while (tem * tem < 3 * r * r) tem++;
while (true) {
ll dx = rng() % (2 * r);
ll dy = rng() % tem;
int cnt = 0;
set<pii> res;
for (auto& [x, y] : ma) {
ll tx = x + bias;
ll ty = y + bias;
ll cntx = tx / (2 * r);
ll cnty = ty / tem;
bool flag = false;
rep(i, cntx - 2, cntx + 2) {
if (flag) break;
rep(j, cnty - 2, cnty + 2) {
ll tx2 = i * 2 * r + (j % 2 == 0 ? r : 0) + dx;
ll ty2 = j * tem + dy;
ll dis = (tx2 - tx) * (tx2 - tx) + (ty2 - ty) * (ty2 - ty);
if (dis <= r * r) {
flag = true;
res.insert({tx2 - bias, ty2 - bias});
}
}
}
if (flag) cnt++;
}
if (cnt * 100 >= 89 * n) {
cout << sz(res) << endl;
for (auto& [x, y] : res) cout << x << ' ' << y << endl;
return;
}
}
return;
}
|