#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cctype> #include<vector> #include<cmath> #include<queue> #include<stack> usingnamespace std; #define ll long long
constint N = 1e4 + 10;
int dfn[N],low[N],c[N],cnt,num,n; bool ins[N];
stack <int> s; vector <int> G[N];
voidtarjan(int x){ dfn[x] = low[x] = ++cnt; s.push(x);ins[x] = 1; for (int i = 0;i < G[x].size();++i) { int v = G[x][i]; if (!dfn[v]) { tarjan(v); low[x] = min(low[x],low[v]); } elseif (ins[v]) { low[x] = min(low[x],dfn[v]); } } if (dfn[x] == low[x]) { int y;c[x] = ++num; do { y = s.top();s.pop(); c[y] = num;ins[y] = 0; } while (x != y); } }
int a[N][2];
boolcheck(int cap){ for (int i = 1;i <= 2 * n;++i) G[i].clear(); memset(dfn,0,sizeof dfn); memset(low,0,sizeof low); memset(c,0,sizeof c); memset(ins,0,sizeof ins); cnt = num = 0; for (int i = 1;i <= n;++i) { for (int qwq = 0;qwq <= 1;++qwq) { for (int j = i + 1;j <= n;++j) { for (int qaq = 0;qaq <= 1;++qaq) { if (abs(a[i][qwq] - a[j][qaq]) < cap) { G[i + n * qwq].push_back(j + n * (qaq ^ 1)); G[j + n * qaq].push_back(i + n * (qwq ^ 1)); } } } } }//重新建图的过程 for (int i = 1;i <= 2 * n;++i) if (!dfn[i]) tarjan(i); for (int i = 1;i <= n;++i) { if (c[i] == c[i+n]) return0; } return1; }
voidsolve(){ memset(ins,0,sizeof ins); tot = 0; int l = 0,r = 0,ans = 0; for (int i = 1;i <= n;++i) scanf("%d %d\n",&a[i][0],&a[i][1]),r = max(r,a[i][1]); while (l < r - 1) { int mid = (l + r) >> 1; if (check(mid)) l = mid; else r = mid; } cout << l << endl; return ; }
signedmain(){ while (scanf("%d\n",&n) != EOF) solve(); return0; }