Pagini recente » Cod sursa (job #990856) | Cod sursa (job #472209) | Cod sursa (job #1854200) | Cod sursa (job #190742) | Cod sursa (job #1808696)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> Point;
#define x first
#define y second
bool Solve(vector<Point> List, int len, int at) {
if(List.empty()) return true;
if(at == 3) return false;
vector<Point> P, New;
for(int it = 0; it < (4 >> at); ++it) {
int min_x = 50005, min_y = 50005;
P = List; New.clear();
for(auto &p : P) {
if(it & 1) p.x = -p.x;
if(it & 2) p.y = -p.y;
min_x = min(min_x, p.x);
min_y = min(min_y, p.y);
}
for(auto p : P)
if(p.x > min_x + len || p.y > min_y + len)
New.push_back(p);
if(Solve(New, len, at + 1)) return true;
}
return false;
}
void Read(int &a) {
static char c;
for(c = getchar(); !isdigit(c); c = getchar());
for(a = 0; isdigit(c); c = getchar())
a = (a << 1) + (a << 3) + c - '0';
}
int main() {
freopen("patrate.in", "r", stdin);
freopen("patrate.out", "w", stdout);
int n;
Read(n);
vector<Point> P(n);
for(int i = 0; i < n; ++i) {
Read(P[i].x); Read(P[i].y);
}
int ans = -1;
for(int step = (1 << 15); step; step /= 2)
if(!Solve(P, ans + step, 0))
ans += step;
cout << ans + 1 << endl;
return 0;
}