forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
79 lines (66 loc) · 2.02 KB
/
C.cpp
File metadata and controls
79 lines (66 loc) · 2.02 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; ++i)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; --i)
#define REP(i,a) for(int i=0,_a=(a); i < _a; ++i)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A,n) { cout << #A << " = "; FOR(_,1,n) cout << A[_] << ' '; cout << endl; }
#define PR0(A,n) { cout << #A << " = "; REP(_,n) cout << A[_] << ' '; cout << endl; }
#define sqr(x) ((x) * (x))
#define ll long long
#define SZ(x) ((int) (x).size())
using namespace std;
const int MN = 211;
int x[MN], y[MN];
int cx[MN], cy[MN], sx, sy;
int savex, savey, W, H;
int n;
bool check(int L) {
sx = sy = 0;
cx[++sx] = 0;
cy[++sy] = 0;
cx[++sx] = W - L;
cy[++sy] = H - L;
FOR(i,1,n) {
if (x[i] + L <= W) cx[++sx] = x[i];
if (y[i] + L <= H) cy[++sy] = y[i];
if (x[i] >= L) cx[++sx] = x[i] - L;
if (y[i] >= L) cy[++sy] = y[i] - L;
}
sort(cx+1, cx+sx+1);
sort(cy+1, cy+sy+1);
sx = unique(cx+1, cx+sx+1) - cx - 1;
sy = unique(cy+1, cy+sy+1) - cy - 1;
FOR(i,1,sx) FOR(j,1,sy) {
int curx = cx[i], cury = cy[j];
bool can = true;
FOR(k,1,n) {
if (curx < x[k] && x[k] < curx + L &&
cury < y[k] && y[k] < cury + L) {
can = false;
break;
}
}
if (can) {
savex = curx;
savey = cury;
return true;
}
}
return false;
}
int main() {
ios :: sync_with_stdio(0); cin.tie(0);
freopen("cricket.in", "r", stdin);
freopen("cricket.out", "w", stdout);
while (cin >> n >> W >> H) {
FOR(i,1,n) cin >> x[i] >> y[i];
int l = 0, r = min(W, H), res = 0;
while (l <= r) {
int mid = (l + r) >> 1;
if (check(mid)) res = mid, l = mid + 1;
else r = mid - 1;
}
check(res);
cout << savex << ' ' << savey << ' ' << res << endl;
}
}