Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1000000000 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const long double pi = 3.141592653589793;

int x_1, y_1, x_2, y_2;
int n;
pair<int, int> xy[200000 + 5];
vector<pair<int, int>> hs;
vector<int> sy;

struct segtree {
    int size;
    vector<long long> node;

    segtree (int n) : size(1) {
        while (size < n) size *= 2;
        node.resize(2 * size - 1, 0);
    }

    void update(int k, int a) {
        k += size - 1;
        node[k] = a;
        while (k > 0){
            k = (k - 1) / 2;
            node[k] = max(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    //[queryL: queryR)
    long long get(int queryL, int queryR, int k = 0, int nodeL = 0, int nodeR = -1) {
        if (nodeR == -1) nodeR = size;
        if (nodeR <= queryL || queryR <= nodeL) return 0;
        if (queryL <= nodeL && nodeR <= queryR) return node[k];
        else{
            int nodeM = (nodeL + nodeR) / 2;
            long long vl = get(queryL, queryR, 2 * k + 1, nodeL, nodeM);
            long long vr = get(queryL, queryR, 2 * k + 2, nodeM, nodeR);
            return max(vl, vr);
        }
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    if (x_1 > x_2) {
        swap(x_1, x_2);
        swap(y_1, y_2);
    }
    //cout << x_1 << y_1 <<" "<< x_2 << y_2 << endl;
    cin >> n;
    rep(i, n) {
        cin >> xy[i].fi >> xy[i].se;
    }
    sort(xy, xy + n);
    int lx = 1e9;
    int rx = -1;
    rep(i, n) {
        if (x_1 <= xy[i].fi && xy[i].fi <= x_2) {
            lx = min(lx, i);
            rx = max(rx, i);
        }
    }
    //cout << lx << rx << endl;

    int cnt = 0;
    if (y_1 <= y_2) {
        rep2(i, lx, rx + 1) {
            //cout << xy[i].se << endl;
            if (y_1 <= xy[i].se && xy[i].se <= y_2) {
                sy.push_back(xy[i].se);
                hs.push_back(xy[i]);
            }
        }
        sort(all(sy));
        int size = hs.size();
        segtree seg(size + 1);
        rep(i, size) {
            //cout << hs[i].fi <<" " << hs[i].se<<  endl;
            int idx = lower_bound(all(sy), hs[i].se) - sy.begin();
            //cout << idx << endl;
            int tmp = seg.get(0, idx);
            seg.update(idx, tmp + 1);
            cnt = max(cnt,tmp + 1);
        }
    }
    else {
        rep2(i, lx, rx + 1) {
            if (y_2 <= xy[i].se && xy[i].se <= y_1) {
                sy.push_back(xy[i].se);
                hs.push_back(xy[i]);
            }
        }
        sort(all(sy));
        int size = hs.size();
        segtree seg(size + 1);
        rep(i, size) {
            //cout << hs[i].fi <<" " << hs[i].se<<  endl;
            int idx = lower_bound(all(sy), hs[i].se) - sy.begin();
            int tmp = seg.get(idx, size + 1);
            seg.update(idx, tmp + 1);
            cnt = max(cnt,tmp + 1);
        }
    }
    long double ans = (abs(x_2 - x_1) + abs(y_2 - y_1)) * 100.0;
    //cout << cnt << endl;
    ans -= cnt *  20.0;
    if (x_1 == x_2 || y_1 == y_2 || cnt == abs(y1 - y2)) {
        ans += cnt * 10.0 * pi;
    }
    else ans += cnt * 5.0 * pi;
    cout << fixed << setprecision(13) << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:142:53: error: 'y2' was not declared in this scope; did you mean 'yn'?
  142 |     if (x_1 == x_2 || y_1 == y_2 || cnt == abs(y1 - y2)) {
      |                                                     ^~
      |                                                     yn