#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
const int MAX_N = 300010;
const ll inf = 1ll << 55;
int n;
int x[MAX_N], y[MAX_N];
ll dp[MAX_N * 4];
vector<pair<int,int>> edge[MAX_N * 4];
int dis(int i, int j) { return abs(x[i]-x[j]) + abs(y[i]-y[j]); }
pair<int,int> adv(int i, int dir, int j) {
int a = x[i], b = y[i];
if (dir == 0) a += j;
if (dir == 1) b += j;
if (dir == 2) a -= j;
if (dir == 3) b -= j;
return make_pair(a, b);
}
void init() {
for (int i = 0;i < n;++i)
for (int j = i+1;j < n;++j) {
for (int k = 0;k < 4;++k)
for (int l = 0;l < 4;++l) {
int h = dis(i, j) / 2;
if (adv(i, k, h) == adv(j, l, h)) {
int a = i * 4 + k, b = j * 4 + l;
edge[a].pb(b, h);
edge[b].pb(a, h);
}
}
}
}
int solve(int d) {
fill(dp, dp + n * 4, inf);
//priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> pq;
stack<pair<ll,ll>> pq;
auto upd = [&](int id, ll t) {
if (chmin(dp[id], t))
pq.emplace(t, id);
};
upd(d, 0);
vector<int> vis(n * 4);
while (pq.size()) {
auto [t, id] = pq.top(); pq.pop();
if (vis[id]) continue;
vis[id] = true;
//if (t != dp[id]) continue;
for (auto [u, w] : edge[id]) {
if (w >= t)
upd(u, w);
}
}
int res = 0;
for (int i = 0;i < n;++i) {
ll d = inf;
for (int j = 0;j < 4;++j)
chmin(d, dp[i * 4 + j]);
if (d < inf) ++res;
}
return res;
}
int32_t main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n;
for (int i = 0;i < n;++i) cin >> x[i] >> y[i], x[i] *= 2, y[i] *= 2;
init();
int res = 1;
for (int i = 0;i < 4;++i)
chmax(res, solve(i));
cout << res << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
28492 KB |
Output is correct |
2 |
Correct |
22 ms |
28460 KB |
Output is correct |
3 |
Correct |
22 ms |
28496 KB |
Output is correct |
4 |
Correct |
20 ms |
28496 KB |
Output is correct |
5 |
Correct |
19 ms |
28496 KB |
Output is correct |
6 |
Correct |
25 ms |
28492 KB |
Output is correct |
7 |
Correct |
18 ms |
28412 KB |
Output is correct |
8 |
Correct |
18 ms |
28428 KB |
Output is correct |
9 |
Correct |
19 ms |
28400 KB |
Output is correct |
10 |
Correct |
19 ms |
28440 KB |
Output is correct |
11 |
Correct |
24 ms |
28456 KB |
Output is correct |
12 |
Correct |
18 ms |
28492 KB |
Output is correct |
13 |
Correct |
20 ms |
28484 KB |
Output is correct |
14 |
Correct |
20 ms |
28496 KB |
Output is correct |
15 |
Correct |
20 ms |
28492 KB |
Output is correct |
16 |
Correct |
20 ms |
28480 KB |
Output is correct |
17 |
Correct |
19 ms |
28492 KB |
Output is correct |
18 |
Correct |
20 ms |
28492 KB |
Output is correct |
19 |
Correct |
20 ms |
28408 KB |
Output is correct |
20 |
Correct |
18 ms |
28496 KB |
Output is correct |
21 |
Correct |
19 ms |
28504 KB |
Output is correct |
22 |
Correct |
21 ms |
28380 KB |
Output is correct |
23 |
Correct |
24 ms |
28492 KB |
Output is correct |
24 |
Correct |
20 ms |
28496 KB |
Output is correct |
25 |
Correct |
22 ms |
28492 KB |
Output is correct |
26 |
Correct |
20 ms |
28440 KB |
Output is correct |
27 |
Correct |
20 ms |
28408 KB |
Output is correct |
28 |
Correct |
20 ms |
28492 KB |
Output is correct |
29 |
Correct |
20 ms |
28492 KB |
Output is correct |
30 |
Correct |
19 ms |
28500 KB |
Output is correct |
31 |
Correct |
18 ms |
28404 KB |
Output is correct |
32 |
Correct |
22 ms |
28492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
28492 KB |
Output is correct |
2 |
Correct |
22 ms |
28460 KB |
Output is correct |
3 |
Correct |
22 ms |
28496 KB |
Output is correct |
4 |
Correct |
20 ms |
28496 KB |
Output is correct |
5 |
Correct |
19 ms |
28496 KB |
Output is correct |
6 |
Correct |
25 ms |
28492 KB |
Output is correct |
7 |
Correct |
18 ms |
28412 KB |
Output is correct |
8 |
Correct |
18 ms |
28428 KB |
Output is correct |
9 |
Correct |
19 ms |
28400 KB |
Output is correct |
10 |
Correct |
19 ms |
28440 KB |
Output is correct |
11 |
Correct |
24 ms |
28456 KB |
Output is correct |
12 |
Correct |
18 ms |
28492 KB |
Output is correct |
13 |
Correct |
20 ms |
28484 KB |
Output is correct |
14 |
Correct |
20 ms |
28496 KB |
Output is correct |
15 |
Correct |
20 ms |
28492 KB |
Output is correct |
16 |
Correct |
20 ms |
28480 KB |
Output is correct |
17 |
Correct |
19 ms |
28492 KB |
Output is correct |
18 |
Correct |
20 ms |
28492 KB |
Output is correct |
19 |
Correct |
20 ms |
28408 KB |
Output is correct |
20 |
Correct |
18 ms |
28496 KB |
Output is correct |
21 |
Correct |
19 ms |
28504 KB |
Output is correct |
22 |
Correct |
21 ms |
28380 KB |
Output is correct |
23 |
Correct |
24 ms |
28492 KB |
Output is correct |
24 |
Correct |
20 ms |
28496 KB |
Output is correct |
25 |
Correct |
22 ms |
28492 KB |
Output is correct |
26 |
Correct |
20 ms |
28440 KB |
Output is correct |
27 |
Correct |
20 ms |
28408 KB |
Output is correct |
28 |
Correct |
20 ms |
28492 KB |
Output is correct |
29 |
Correct |
20 ms |
28492 KB |
Output is correct |
30 |
Correct |
19 ms |
28500 KB |
Output is correct |
31 |
Correct |
18 ms |
28404 KB |
Output is correct |
32 |
Correct |
22 ms |
28492 KB |
Output is correct |
33 |
Correct |
19 ms |
28492 KB |
Output is correct |
34 |
Correct |
17 ms |
28492 KB |
Output is correct |
35 |
Correct |
19 ms |
28472 KB |
Output is correct |
36 |
Correct |
18 ms |
28500 KB |
Output is correct |
37 |
Correct |
20 ms |
28584 KB |
Output is correct |
38 |
Correct |
19 ms |
28492 KB |
Output is correct |
39 |
Correct |
21 ms |
28500 KB |
Output is correct |
40 |
Correct |
19 ms |
28492 KB |
Output is correct |
41 |
Correct |
23 ms |
28440 KB |
Output is correct |
42 |
Correct |
19 ms |
28420 KB |
Output is correct |
43 |
Correct |
18 ms |
28396 KB |
Output is correct |
44 |
Correct |
19 ms |
28436 KB |
Output is correct |
45 |
Incorrect |
19 ms |
28520 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
28492 KB |
Output is correct |
2 |
Correct |
22 ms |
28424 KB |
Output is correct |
3 |
Correct |
20 ms |
28428 KB |
Output is correct |
4 |
Correct |
19 ms |
28500 KB |
Output is correct |
5 |
Correct |
23 ms |
28444 KB |
Output is correct |
6 |
Correct |
20 ms |
28756 KB |
Output is correct |
7 |
Correct |
19 ms |
28748 KB |
Output is correct |
8 |
Correct |
21 ms |
28716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
28492 KB |
Output is correct |
2 |
Correct |
22 ms |
28460 KB |
Output is correct |
3 |
Correct |
22 ms |
28496 KB |
Output is correct |
4 |
Correct |
20 ms |
28496 KB |
Output is correct |
5 |
Correct |
19 ms |
28496 KB |
Output is correct |
6 |
Correct |
25 ms |
28492 KB |
Output is correct |
7 |
Correct |
18 ms |
28412 KB |
Output is correct |
8 |
Correct |
18 ms |
28428 KB |
Output is correct |
9 |
Correct |
19 ms |
28400 KB |
Output is correct |
10 |
Correct |
19 ms |
28440 KB |
Output is correct |
11 |
Correct |
24 ms |
28456 KB |
Output is correct |
12 |
Correct |
18 ms |
28492 KB |
Output is correct |
13 |
Correct |
20 ms |
28484 KB |
Output is correct |
14 |
Correct |
20 ms |
28496 KB |
Output is correct |
15 |
Correct |
20 ms |
28492 KB |
Output is correct |
16 |
Correct |
20 ms |
28480 KB |
Output is correct |
17 |
Correct |
19 ms |
28492 KB |
Output is correct |
18 |
Correct |
20 ms |
28492 KB |
Output is correct |
19 |
Correct |
20 ms |
28408 KB |
Output is correct |
20 |
Correct |
18 ms |
28496 KB |
Output is correct |
21 |
Correct |
19 ms |
28504 KB |
Output is correct |
22 |
Correct |
21 ms |
28380 KB |
Output is correct |
23 |
Correct |
24 ms |
28492 KB |
Output is correct |
24 |
Correct |
20 ms |
28496 KB |
Output is correct |
25 |
Correct |
22 ms |
28492 KB |
Output is correct |
26 |
Correct |
20 ms |
28440 KB |
Output is correct |
27 |
Correct |
20 ms |
28408 KB |
Output is correct |
28 |
Correct |
20 ms |
28492 KB |
Output is correct |
29 |
Correct |
20 ms |
28492 KB |
Output is correct |
30 |
Correct |
19 ms |
28500 KB |
Output is correct |
31 |
Correct |
18 ms |
28404 KB |
Output is correct |
32 |
Correct |
22 ms |
28492 KB |
Output is correct |
33 |
Correct |
19 ms |
28492 KB |
Output is correct |
34 |
Correct |
17 ms |
28492 KB |
Output is correct |
35 |
Correct |
19 ms |
28472 KB |
Output is correct |
36 |
Correct |
18 ms |
28500 KB |
Output is correct |
37 |
Correct |
20 ms |
28584 KB |
Output is correct |
38 |
Correct |
19 ms |
28492 KB |
Output is correct |
39 |
Correct |
21 ms |
28500 KB |
Output is correct |
40 |
Correct |
19 ms |
28492 KB |
Output is correct |
41 |
Correct |
23 ms |
28440 KB |
Output is correct |
42 |
Correct |
19 ms |
28420 KB |
Output is correct |
43 |
Correct |
18 ms |
28396 KB |
Output is correct |
44 |
Correct |
19 ms |
28436 KB |
Output is correct |
45 |
Incorrect |
19 ms |
28520 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
28492 KB |
Output is correct |
2 |
Correct |
22 ms |
28460 KB |
Output is correct |
3 |
Correct |
22 ms |
28496 KB |
Output is correct |
4 |
Correct |
20 ms |
28496 KB |
Output is correct |
5 |
Correct |
19 ms |
28496 KB |
Output is correct |
6 |
Correct |
25 ms |
28492 KB |
Output is correct |
7 |
Correct |
18 ms |
28412 KB |
Output is correct |
8 |
Correct |
18 ms |
28428 KB |
Output is correct |
9 |
Correct |
19 ms |
28400 KB |
Output is correct |
10 |
Correct |
19 ms |
28440 KB |
Output is correct |
11 |
Correct |
24 ms |
28456 KB |
Output is correct |
12 |
Correct |
18 ms |
28492 KB |
Output is correct |
13 |
Correct |
20 ms |
28484 KB |
Output is correct |
14 |
Correct |
20 ms |
28496 KB |
Output is correct |
15 |
Correct |
20 ms |
28492 KB |
Output is correct |
16 |
Correct |
20 ms |
28480 KB |
Output is correct |
17 |
Correct |
19 ms |
28492 KB |
Output is correct |
18 |
Correct |
20 ms |
28492 KB |
Output is correct |
19 |
Correct |
20 ms |
28408 KB |
Output is correct |
20 |
Correct |
18 ms |
28496 KB |
Output is correct |
21 |
Correct |
19 ms |
28504 KB |
Output is correct |
22 |
Correct |
21 ms |
28380 KB |
Output is correct |
23 |
Correct |
24 ms |
28492 KB |
Output is correct |
24 |
Correct |
20 ms |
28496 KB |
Output is correct |
25 |
Correct |
22 ms |
28492 KB |
Output is correct |
26 |
Correct |
20 ms |
28440 KB |
Output is correct |
27 |
Correct |
20 ms |
28408 KB |
Output is correct |
28 |
Correct |
20 ms |
28492 KB |
Output is correct |
29 |
Correct |
20 ms |
28492 KB |
Output is correct |
30 |
Correct |
19 ms |
28500 KB |
Output is correct |
31 |
Correct |
18 ms |
28404 KB |
Output is correct |
32 |
Correct |
22 ms |
28492 KB |
Output is correct |
33 |
Correct |
19 ms |
28492 KB |
Output is correct |
34 |
Correct |
17 ms |
28492 KB |
Output is correct |
35 |
Correct |
19 ms |
28472 KB |
Output is correct |
36 |
Correct |
18 ms |
28500 KB |
Output is correct |
37 |
Correct |
20 ms |
28584 KB |
Output is correct |
38 |
Correct |
19 ms |
28492 KB |
Output is correct |
39 |
Correct |
21 ms |
28500 KB |
Output is correct |
40 |
Correct |
19 ms |
28492 KB |
Output is correct |
41 |
Correct |
23 ms |
28440 KB |
Output is correct |
42 |
Correct |
19 ms |
28420 KB |
Output is correct |
43 |
Correct |
18 ms |
28396 KB |
Output is correct |
44 |
Correct |
19 ms |
28436 KB |
Output is correct |
45 |
Incorrect |
19 ms |
28520 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
28492 KB |
Output is correct |
2 |
Correct |
22 ms |
28460 KB |
Output is correct |
3 |
Correct |
22 ms |
28496 KB |
Output is correct |
4 |
Correct |
20 ms |
28496 KB |
Output is correct |
5 |
Correct |
19 ms |
28496 KB |
Output is correct |
6 |
Correct |
25 ms |
28492 KB |
Output is correct |
7 |
Correct |
18 ms |
28412 KB |
Output is correct |
8 |
Correct |
18 ms |
28428 KB |
Output is correct |
9 |
Correct |
19 ms |
28400 KB |
Output is correct |
10 |
Correct |
19 ms |
28440 KB |
Output is correct |
11 |
Correct |
24 ms |
28456 KB |
Output is correct |
12 |
Correct |
18 ms |
28492 KB |
Output is correct |
13 |
Correct |
20 ms |
28484 KB |
Output is correct |
14 |
Correct |
20 ms |
28496 KB |
Output is correct |
15 |
Correct |
20 ms |
28492 KB |
Output is correct |
16 |
Correct |
20 ms |
28480 KB |
Output is correct |
17 |
Correct |
19 ms |
28492 KB |
Output is correct |
18 |
Correct |
20 ms |
28492 KB |
Output is correct |
19 |
Correct |
20 ms |
28408 KB |
Output is correct |
20 |
Correct |
18 ms |
28496 KB |
Output is correct |
21 |
Correct |
19 ms |
28504 KB |
Output is correct |
22 |
Correct |
21 ms |
28380 KB |
Output is correct |
23 |
Correct |
24 ms |
28492 KB |
Output is correct |
24 |
Correct |
20 ms |
28496 KB |
Output is correct |
25 |
Correct |
22 ms |
28492 KB |
Output is correct |
26 |
Correct |
20 ms |
28440 KB |
Output is correct |
27 |
Correct |
20 ms |
28408 KB |
Output is correct |
28 |
Correct |
20 ms |
28492 KB |
Output is correct |
29 |
Correct |
20 ms |
28492 KB |
Output is correct |
30 |
Correct |
19 ms |
28500 KB |
Output is correct |
31 |
Correct |
18 ms |
28404 KB |
Output is correct |
32 |
Correct |
22 ms |
28492 KB |
Output is correct |
33 |
Correct |
19 ms |
28492 KB |
Output is correct |
34 |
Correct |
17 ms |
28492 KB |
Output is correct |
35 |
Correct |
19 ms |
28472 KB |
Output is correct |
36 |
Correct |
18 ms |
28500 KB |
Output is correct |
37 |
Correct |
20 ms |
28584 KB |
Output is correct |
38 |
Correct |
19 ms |
28492 KB |
Output is correct |
39 |
Correct |
21 ms |
28500 KB |
Output is correct |
40 |
Correct |
19 ms |
28492 KB |
Output is correct |
41 |
Correct |
23 ms |
28440 KB |
Output is correct |
42 |
Correct |
19 ms |
28420 KB |
Output is correct |
43 |
Correct |
18 ms |
28396 KB |
Output is correct |
44 |
Correct |
19 ms |
28436 KB |
Output is correct |
45 |
Incorrect |
19 ms |
28520 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
28492 KB |
Output is correct |
2 |
Correct |
22 ms |
28460 KB |
Output is correct |
3 |
Correct |
22 ms |
28496 KB |
Output is correct |
4 |
Correct |
20 ms |
28496 KB |
Output is correct |
5 |
Correct |
19 ms |
28496 KB |
Output is correct |
6 |
Correct |
25 ms |
28492 KB |
Output is correct |
7 |
Correct |
18 ms |
28412 KB |
Output is correct |
8 |
Correct |
18 ms |
28428 KB |
Output is correct |
9 |
Correct |
19 ms |
28400 KB |
Output is correct |
10 |
Correct |
19 ms |
28440 KB |
Output is correct |
11 |
Correct |
24 ms |
28456 KB |
Output is correct |
12 |
Correct |
18 ms |
28492 KB |
Output is correct |
13 |
Correct |
20 ms |
28484 KB |
Output is correct |
14 |
Correct |
20 ms |
28496 KB |
Output is correct |
15 |
Correct |
20 ms |
28492 KB |
Output is correct |
16 |
Correct |
20 ms |
28480 KB |
Output is correct |
17 |
Correct |
19 ms |
28492 KB |
Output is correct |
18 |
Correct |
20 ms |
28492 KB |
Output is correct |
19 |
Correct |
20 ms |
28408 KB |
Output is correct |
20 |
Correct |
18 ms |
28496 KB |
Output is correct |
21 |
Correct |
19 ms |
28504 KB |
Output is correct |
22 |
Correct |
21 ms |
28380 KB |
Output is correct |
23 |
Correct |
24 ms |
28492 KB |
Output is correct |
24 |
Correct |
20 ms |
28496 KB |
Output is correct |
25 |
Correct |
22 ms |
28492 KB |
Output is correct |
26 |
Correct |
20 ms |
28440 KB |
Output is correct |
27 |
Correct |
20 ms |
28408 KB |
Output is correct |
28 |
Correct |
20 ms |
28492 KB |
Output is correct |
29 |
Correct |
20 ms |
28492 KB |
Output is correct |
30 |
Correct |
19 ms |
28500 KB |
Output is correct |
31 |
Correct |
18 ms |
28404 KB |
Output is correct |
32 |
Correct |
22 ms |
28492 KB |
Output is correct |
33 |
Correct |
19 ms |
28492 KB |
Output is correct |
34 |
Correct |
17 ms |
28492 KB |
Output is correct |
35 |
Correct |
19 ms |
28472 KB |
Output is correct |
36 |
Correct |
18 ms |
28500 KB |
Output is correct |
37 |
Correct |
20 ms |
28584 KB |
Output is correct |
38 |
Correct |
19 ms |
28492 KB |
Output is correct |
39 |
Correct |
21 ms |
28500 KB |
Output is correct |
40 |
Correct |
19 ms |
28492 KB |
Output is correct |
41 |
Correct |
23 ms |
28440 KB |
Output is correct |
42 |
Correct |
19 ms |
28420 KB |
Output is correct |
43 |
Correct |
18 ms |
28396 KB |
Output is correct |
44 |
Correct |
19 ms |
28436 KB |
Output is correct |
45 |
Incorrect |
19 ms |
28520 KB |
Output isn't correct |