Language: C++

#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define pi acos(-1.0)
struct pig
{
    int x,y;
}info[200100];
int cnt,n,a[200100],seg[800100],x1,x2,y1,y2,m = 1;
map<int,int>mmap;
bool cmp(pig a,pig b)
{
    if(a.x == b.x)return a.y > b.y;
    return y1 < y2 ? a.x < b.x : a.x > b.x;
}
int main()
{
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),swap(y1,y2);
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)scanf("%d%d",&info[i].x,&info[i].y),a[i] = info[i].y;
    sort(info + 1,info + 1 + n,cmp);
    sort(a + 1,a + 1 + n);
    for(int i = 1;i <= n;i++)if(a[i] != a[i - 1])mmap[a[i]] = ++cnt;
    while(m < cnt + 1)m <<= 1;
    for(int i = 1;i <= n;i++)
    {
        if(info[i].x > max(x2,x1) || info[i].y > max(y2,y1) || info[i].y < min(y1,y2) || info[i].x < min(x1,y1))continue;
        int maxx = 0;
        for(int s = m,t = mmap[info[i].y] + m;s ^ t ^ 1;s >>= 1,t >>= 1)
        {
            if(~s & 1)maxx = max(maxx,seg[s ^ 1]);
            if( t & 1)maxx = max(maxx,seg[t ^ 1]);
        }
        int tmp = mmap[info[i].y] + m;
        seg[tmp] = maxx + 1;
        while(tmp >>= 1){seg[tmp] = max(seg[tmp << 1],seg[(tmp << 1) + 1]);}
    }
    if(x1 == x2 || y1 == y2)printf("%.11lf\n",(abs(x2 - x1) + abs(y2 - y1)) * 100 + seg[1] * (pi * 10 - 20));
    else printf("%.11lf\n",(abs(x2 - x1) + abs(y2 - y1)) * 100 + seg[1] * (pi * 5 - 20));
}


Compiler output:
a.cc:12:39: error: 'int y1' redeclared as different kind of entity
   12 | int cnt,n,a[200100],seg[800100],x1,x2,y1,y2,m = 1;
      |                                       ^~
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/requires_hosted.h:31,
                 from /usr/include/c++/14/map:60,
                 from a.cc:1:
/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 'bool cmp(pig, pig)':
a.cc:17:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |     return y1 < y2 ? a.x < b.x : a.x > b.x;
      |            ~~~^~~~
a.cc: In function 'int main()':
a.cc:21:66: error: no matching function for call to 'swap(double (&)(double) noexcept, int&)'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),swap(y1,y2);
      |                                                              ~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/bits/stl_tree.h:63,
                 from /usr/include/c++/14/map:62:
/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:21:66: note:   deduced conflicting types for parameter '_Tp' ('double(double) noexcept' and 'int')
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),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:21:66: note:   mismatched types '_Tp [_Nm]' and 'double(double) noexcept'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),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:21:66: note:   mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),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:21:66: note:   mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),swap(y1,y2);
      |                                                              ~~~~^~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1675:5: note: candidate: 'template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> void std::swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)'
 1675 |     swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_tree.h:1675:5: note:   template argument deduction/substitution failed:
a.cc:21:66: note:   mismatched types 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>' and 'double(double) noexcept'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),swap(y1,y2);
      |                                                              ~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/stl_map.h:63,
                 from /usr/include/c++/14/map:63:
/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<_Args1 ...>&, tuple<_Args1 ...>&)'
 2805 |     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
      |     ^~~~
/usr/include/c++/14/tuple:2805:5: note:   template argument deduction/substitution failed:
a.cc:21:66: note:   mismatched types 'std::tuple<_Args1 ...>' and 'double(double) noexcept'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),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<_Args1 ...>&, tuple<_Args1 ...>&)' (deleted)
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
/usr/include/c++/14/tuple:2823:5: note:   template argument deduction/substitution failed:
a.cc:21:66: note:   mismatched types 'std::tuple<_Args1 ...>' and 'double(double) noexcept'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),swap(y1,y2);
      |                                                              ~~~~^~~~~~~
/usr/include/c++/14/bits/stl_map.h:1586:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(map<_Key, _Tp, _Compare, _Allocator>&, map<_Key, _Tp, _Compare, _Allocator>&)'
 1586 |     swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_map.h:1586:5: note:   template argument deduction/substitution failed:
a.cc:21:66: note:   mismatched types 'std::map<_Key, _Tp, _Compare, _Allocator>' and 'double(double) noexcept'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),swap(y1,y2);
      |                                                              ~~~~^~~~~~~
In file included from /usr/include/c++/14/map:64:
/usr/include/c++/14/bits/stl_multimap.h:1208:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(multimap<_Key, _Tp, _Compare, _Allocator>&, multimap<_Key, _Tp, _Compare, _Allocator>&)'
 1208 |     swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_multimap.h:1208:5: note:   template argument deduction/substitution failed:
a.cc:21:66: note:   mismatched types 'std::multimap<_Key, _Tp, _Compare, _Allocator>' and 'double(double) noexcept'
   21 |     scanf("%d%d%d%d",&x1,&y1,&x2,&y2);if(x2 < x1)swap(x1,x2),swap(y1,y2);
      |                                                              ~~~~^~~~~~~
a.cc:30:53: error: no matching function for call to 'max(int&, double (&)(double) noexcept)'
   30 |         if(info[i].x > max(x2,x1) || info[i].y > max(y2,y1) || info[i].y < min(y1,y2) || info[i].x < min(x1,y1))continue;
      |                                                  ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:30:53: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double(double) noexcept')
   30 |         if(info[i].x > max(x2,x1) || info[i].y > max(y2,y1) || info[i].y < min(y1,y2) || info[i].x < min(x1,y1))continue;
      |                                                  ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:30:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |         if(info[i].x > max(x2,x1) || info[i].y > max(y2,y1) || info[i].y < min(y1,y2) || info[i].x < min(x1,y1))continue;
      |                                                  ~~~^~~~~~~
a.cc:30:79: error: no matching function for call to 'min(double (&)(double) noexcept, int&)'
   30 |         if(info[i].x > max(x2,x1) || info[i].y > max(y2,y1) || info[i].y < min(y1,y2) || info[i].x < min(x1,y1))continue;
      |                                                                            ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp>