Language: C++

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}
int n, x1, y1, x2, y2;
struct T{
    int x, y;
    bool operator < (const T& rhs) const{
        return x < rhs.x;
    }
    bool operator == (const T& rhs) const{
        return x == rhs.x;
    }
}a[N], tmp;
const double per = 20 - 5 * PI;
int cnt, b[N], bn, best[N];
double ans;
int main(){
  //  IN;
    SCC(x1, y1);
    SCC(x2, y2);
    if(x1 > x2){
        swap(x1, x2);
        swap(y1, y2);
    }
    SC(n);
    FF(i, 1, n) SCC(a[i].x, a[i].y);
    sort(a + 1, a + 1 + n);
    tmp.x = x1, tmp.y = 0;
    int lpos = lower_bound(a + 1, a + 1 + n, tmp) - a;
    tmp.x = x2, tmp.y = 0;
    int rpos = lower_bound(a + 1, a + 1 + n, tmp) - a;
    if(rpos > n) rpos = n;
    if(y1 <= y2){
        FF(i, lpos, rpos){
            if(a[i].y >= y1 && a[i].y <= y2){
                b[++bn] = a[i].y;
            }
        }
        memset(best, 0x3f, sizeof(best));
        cnt = 0;
        FF(i, 1, bn){
            int L=1,R=cnt;
            while(L<=R){
                int mid=(L+R)/2;
                if(best[mid]>b[i]) R=mid-1;
                else L=mid+1;
            }
            cnt=max(cnt,L);
            best[L]=min(best[L],b[i]);
        }
        int lim = min(x2 - x1 + 1, y2 - y1 + 1);
        ans = 1.0 * 100 * (x2 - x1) + 1.0 * 100 * (y2 - y1);
        ans -= cnt * per;
        if(lim == cnt) ans += 5 * PI;
    }else {
        FF(i, lpos, rpos){
            if(a[i].y >= y2 && a[i].y <= y1){
                b[++bn] = a[i].y;
            }
        }
        memset(best, 0, sizeof(best));
        cnt = 0;
        FF(i, 1, bn){
            int L=1,R=cnt;
            while(L<=R){
                int mid=(L+R)/2;
                if(best[mid]>b[i]) L=mid+1;
                else R=mid-1;
            }
            cnt=max(cnt,L);
            best[L]=max(best[L],b[i]);
        }
        int lim = min(x2 - x1 + 1, y1 - y2 + 1);
        ans = 1.0 * 100 * (x2 - x1) + 1.0 * 100 * (y1 - y2);
        ans -= cnt * per;
        if(lim == cnt) ans += 5 * PI;
    }
    printf("%.16f\n", ans);
    return 0;
}


Compiler output:
a.cc:51:12: error: 'int y1' redeclared as different kind of entity
   51 | int n, x1, y1, x2, y2;
      |            ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/bits/stl_algobase.h:59,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:70:13: error: no matching function for call to 'swap(double (&)(double) noexcept, int&)'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
In file included from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
/usr/include/c++/14/bits/exception_ptr.h:229:25: note:   no known conversion for argument 1 from 'double(double) noexcept' to 'std::__exception_ptr::exception_ptr&'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |          ~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
                 from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   deduced conflicting types for parameter '_Tp' ('double(double) noexcept' and 'int')
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
  250 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~
/usr/include/c++/14/bits/move.h:250:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types '_Tp [_Nm]' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
 1089 |     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
 1106 |     swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 4039 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)'
 2805 |     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
      |     ^~~~
/usr/include/c++/14/tuple:2805:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::tuple<_UTypes ...>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
/usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted)
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
/usr/include/c++/14/tuple:2823:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::tuple<_UTypes ...>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
In file included from a.cc:5:
/usr/include/c++/14/fstream:1331:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(basic_filebuf<_CharT, _Traits>&, basic_filebuf<_CharT, _Traits>&)'
 1331 |     swap(basic_filebuf<_CharT, _Traits>& __x,
      |     ^~~~
/usr/include/c++/14/fstream:1331:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::basic_filebuf<_CharT, _Traits>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
/usr/include/c++/14/fstream:1338:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(basic_ifstream<_CharT, _Traits>&, basic_ifstream<_CharT, _Traits>&)'
 1338 |     swap(basic_ifstream<_CharT, _Traits>& __x,
      |     ^~~~
/usr/include/c++/14/fstream:1338:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::basic_ifstream<_CharT, _Traits>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
/usr/include/c++/14/fstream:1345:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(basic_ofstream<_CharT, _Traits>&, basic_ofstream<_CharT, _Traits>&)'
 1345 |     swap(basic_ofstream<_CharT, _Traits>& __x,
      |     ^~~~
/usr/include/c++/14/fstream:1345:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::basic_ofstream<_CharT, _Traits>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
/usr/include/c++/14/fstream:1352:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(basic_fstream<_CharT, _Traits>&, basic_fstream<_CharT, _Traits>&)'
 1352 |     swap(basic_fstream<_CharT, _Traits>& __x,
      |     ^~~~
/usr/include/c++/14/fstream:1352:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::basic_fstream<_CharT, _Traits>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(vector<_Tp, _Alloc>&, vector<_Tp, _Alloc>&)'
 2122 |     swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_vector.h:2122:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::vector<_Tp, _Alloc>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:11:
/usr/include/c++/14/bits/stl_deque.h:2370:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(deque<_Tp, _Alloc>&, deque<_Tp, _Alloc>&)'
 2370 |     swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_deque.h:2370:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::deque<_Tp, _Alloc>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
In file included from /usr/include/c++/14/queue:66:
/usr/include/c++/14/bits/stl_queue.h:445:5: note: candidate: 'template<class _Tp, class _Seq> typename std::enable_if<std::__is_swappable<_T2>::value>::type std::swap(queue<_Tp, _Seq>&, queue<_Tp, _Seq>&)'
  445 |     swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_queue.h:445:5: note:   template argument deduction/substitution failed:
a.cc:70:13: note:   mismatched types 'std::queue<_Tp, _Seq>' and 'double(double) noexcept'
   70 |         swap(y1, y2);
      |         ~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:834:5: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> typename std::enable_if<std::__and_<std::__is_swappable<_T2>, std::__is_swappable<_Compare> >::value>::type std::swap(priority_queue<_Tp, _Sequence, _Compare>&, priority_queue<_Tp, _Sequence, _Compare>&)'
  834 |     swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_queue.h:834:5: note:   template