Language: C++

//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cntath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>

using namespace std;
 
const int N = 20000 + 5;
const int inf = 1e9 + 7;
 
int n;
int X[N];
int ind[N];
int out[N << 2];
int in[N << 2];
int pnt;
int color[N];
vector<int> graph[N * 20], rgraph[N * 20], topol;
int mark[N * 20];
 
bool cmp(int x, int y)
{

    return X[x] < X[y];
}
 
int Not(int a)
{
    if(a > 2 * n) 
    {
        a -= 2 * n;
    }
    else
    {
        a += 2 * n;
    }
    return a;
}
 
void build(int v, int l, int r)
{
    if (r - l == 1)
    {
        out[v] = ++pnt;
        graph[out[v]].push_back(Not(ind[l]));
        rgraph[Not(ind[l])].push_back(out[v]);
        in[v] = ++pnt;
        graph[ind[l]].push_back(in[v]);
        rgraph[in[v]].push_back(ind[l]);
        return;
    }
    int mid = (l + r) >> 1;
    build(v << 1, l, mid);
    build(v << 1 | 1, mid, r);
    out[v] = ++pnt;
    graph[out[v]].push_back(out[v << 1]);
    graph[out[v]].push_back(out[v << 1 | 1]);
    rgraph[out[v << 1]].push_back(out[v]);
    rgraph[out[v << 1 | 1]].push_back(out[v]);
    in[v] = ++pnt;
    graph[in[v << 1]].push_back(in[v]);
    graph[in[v << 1 | 1]].push_back(in[v]);
    rgraph[in[v]].push_back(in[v << 1]);
    rgraph[in[v]].push_back(in[v << 1 | 1]);
}
 
void dfs(int v)
{
    mark[v] = 1;
    for (auto u: graph[v])
    {
        if (!mark[u]) 
        {
            dfs(u);
        }
    }
    topol.push_back(v);
}
 
void sfd(int v, int c)
{
    mark[v] = 1;
    color[v] = c;
    for (auto u:rgraph[v])
    {
        if (!mark[u]) 
            sfd(u, c);
    }
}
 
void add(int v, int lq, int rq, bool f, int x, int l, int r)
{
    if (rq <= l || r <= lq) 
    {
        return;
    }
    if (lq <= l && r <= rq)
    {
        if (f == 0) 
        {
            graph[x].push_back(out[v]), rgraph[out[v]].push_back(x);
        }
        else
        {
            graph[in[v]].push_back(x);
            rgraph[x].push_back(in[v]);
        }
        return;
    }
    int mid = (l + r) >> 1;
    add(v << 1, lq, rq, f, x, l, mid);
    add(v << 1 | 1, lq, rq, f, x, mid, r);
}
 
void add_clause(int x, int y)
{
    graph[Not(x)].push_back(y);
    rgraph[y].push_back(Not(x));
    graph[Not(y)].push_back(x);
    rgraph[x].push_back(Not(y));
}
 
bool isVal(int x)
{
    pnt = 4 * n;
    memset(mark, 0, sizeof mark);
    for (int i = 0; i < N * 20; i++) 
    {
        graph[i].clear();
        rgraph[i].clear();
    }
    topol.clear();
    build(1, 1, 2 * n + 1);
    for (int i = 1; i <= n; i++)
    {
        int L = 2 * i - 1;
        int R = 2 * i;
        add_clause(Not(L), Not(R));
        add_clause(L, R);
    }
    X[0] = -inf;
    X[2 * n + 1] = inf;
    for (int i = 1; i <= 2 * n; i++)
    {
        int l = 0, r = i;
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if (abs(X[ind[mid]] - X[ind[i]]) < x)
            {
                r = mid;
            }
            else
            {
                l = mid;
            }
        }
        if (r != i)
        {
            add(1, r, i, 0, ind[i], 1, 2 * n + 1);
            add(1, r, i, 1, Not(ind[i]), 1, 2 * n + 1);
        }
        l = i, r = 2 * n + 1;
        while (r - l > 1)
        {
            int mid = (l + r) >> 1;
            if (abs(X[ind[mid]] - X[ind[i]]) < x) 
            {
                l = mid;
            }
            else
            {
                r = mid;
            }
        }
        if (l != i) 
        {
            add(1, i + 1, l + 1, 0, ind[i], 1, 2 * n + 1);
            add(1, i + 1, l + 1, 1, Not(ind[i]), 1, 2 * n + 1);
        }
    }
    for (int i = 1; i <= pnt; i++)
    {
        if (!mark[i]) 
        {
            dfs(i);
        }
    }
    reverse(topol.begin(), topol.end());
    memset(mark, 0, sizeof mark);
    int cnt = 0;
    for (auto u:topol)
    {
        if (!mark[u]) 
        {
            sfd(u, ++cnt);
        }
    }
    for (int i = 1; i <= 2 * n; i++) 
    {
        if (color[i] == color[i + 2 * n]) 
        {
            return 0;
        }
    }
    return 1;
}

void bsearch()
{
    int l = -1;
    int r = inf;
    while (r - l > 1)
    {
        int mid = (l + r) >> 1;
        if (isVal(mid)) 
        {
            l = mid;
        }
        else
        { 
            r = mid;
        }
    }
    cout << l;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= 2 * n; i++)
    {
        cin >> X[i];
        ind[i] = i;
    }
    sort(ind + 1, ind + 2 * n + 1, cmp);
    bsearch();
}







Compiler output:
a.cc:6:10: fatal error: cntath: No such file or directory
    6 | #include <cntath>
      |          ^~~~~~~~
compilation terminated.