Language: C++

#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <cmath>
#include <unordered_set>
#include <vector>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;

const int MAX_COORD = 1e8 + 12;
const long long STREET_LEN = 100;

const long double GOOD_PATH_LEN = 20 - 5 * acos(-1.0);
const long double BAD_PATH_LEN = 10 * acos(-1.0) - 20;

int x[N];
int y[N];

bool inside(int x1, int y1, int x2, int y2, int x3, int y3) {
    return x1 <= x3 && x3 <= x2 && y1 <= y3 && y3 <= y2;
}

unordered_map<int, pair<int, int>> tree;

void add(int v, int tl, int tr, int pos, int value) {
    if (tl == tr) {
        tree[v] = max(tree[v], {value, pos});
    } else {
        int mid = (tl + tr) / 2;
        if (pos <= mid) {
            add(v + v, tl, mid, pos, value);
        } else {
            add(v + v + 1, mid + 1, tr, pos, value);
        }
        tree[v] = max(tree[v + v], tree[v + v + 1]);
    }
}

pair<int, int> get_max(int v, int tl, int tr, int l, int r) {
    if (l > r) {
        return 0;
    }
    if (tl == l && tr == r) {
        if (tree.count(v)) {
            return tree[v];
        }
        return 0;
    }
    int mid = (tl + tr) / 2;
    return max(get_max(v + v, tl, mid, l, min(r, mid)), get_max(v + v + 1, mid + 1, tr, max(l, mid + 1), r));
}


void solve() {
    int x1, y1, x2, y2;
    int n;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x1 > x2) {
        swap(x1, x2);
        swap(y1, y2);
    }
    bool swaped = false;
    if (y1 > y2) {
        y1 = MAX_COORD - y1;
        y2 = MAX_COORD - y2;
        swaped = true;
    }
    long long path = abs(x1 - x2) + abs(y1 - y2);
    path *= STREET_LEN;
    scanf("%d", &n);
    vector<pair<int, int>> usefull;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &x[i], &y[i]);
        if (swaped) {
            y[i] = MAX_COORD - y[i];
        }
        if (inside(x1, y1, x2, y2, x[i], y[i])) {
            usefull.push_back({x[i], y[i]});
        }
    }
    sort(usefull.begin(), usefull.end());
    if (x1 == x2 || y1 == y2) {
        printf("%.11Lf\n", path + BAD_PATH_LEN * usefull.size());
        return;
    }
    int max_fountains = 0;
    long double ans = 0;
    for (int i = 0; i < usefull.size(); ++i) {
        auto cur = get_max(1, 0, MAX_COORD, 0, usefull[i].second - 1);
        if (usefull[i].second == y2) {
            if (cur.second + 1 == usefull[i].second) {
                ans = max(ans, path - cur.first * GOOD_PATH_LEN + BAD_PATH_LEN);
                cur = get_max(1, 0, MAX_COORD, 0, usefull[i].second - 2);
                cur.first += 1;
                ans = max(ans, path - cur.first * GOOD_PATH_LEN);
            } else {
                cur.first += 1;
                ans = max(ans, path - cur.first * GOOD_PATH_LEN);
            }
        } else {
            cur.first += 1;
            ans = max(ans, path - cur.first * GOOD_PATH_LEN);
            add(1, 0, MAX_COORD, usefull[i].second, cur.first);
        }
    }
    printf("%.11Lf", ans);
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}
 

Compiler output:
a.cc: In function 'std::pair<int, int> get_max(int, int, int, int, int)':
a.cc:57:16: error: could not convert '0' from 'int' to 'std::pair<int, int>'
   57 |         return 0;
      |                ^
      |                |
      |                int
a.cc:63:16: error: could not convert '0' from 'int' to 'std::pair<int, int>'
   63 |         return 0;
      |                ^
      |                |
      |                int