Language: C++

#include <cstdio>
#include <algorithm>

using namespace std;

const double pi=3.14159265359;

struct punct
{
    int x,y;
};

punct v[200010],v1[200010];
long long arb[600010],s;

int cmp1(punct a,punct b)
{
    return a.y>b.y;
}

int cmp2(punct a,punct b)
{
    return a.y<b.y;
}

int cmp3(punct a,punct b)
{
    return a.x<b.x;
}

void arbint_update(int nod,int st,int dr,int poz,int val)
{
    if(st==dr) arb[nod]=val;
    else
    {
        int mid=(st+dr)/2;
        if(poz<=mid) arbint_update(nod*2,st,mid,poz,val);
        else arbint_update(nod*2+1,mid+1,dr,poz,val);
        arb[nod]=max(arb[nod*2],arb[nod*2+1]);
    }
}

int arbint_query(int nod,int st,int dr,int left,int right)
{
    if(left<=st && dr<=right) return arb[nod];
    int mid=(st+dr)/2;s=0;
    if(left<=mid) s=max(s,arbint_query(nod*2,st,mid,left,right));
    if(mid<right) s=max(s,arbint_query(nod*2+1,mid+1,dr,left,right));
    return s;
}

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int x1,y1,x2,y2,n,x,y;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    if(x1>x2) {swap(x1,x2);swap(y1,y2);}
    scanf("%d",&n);
    double sol=1LL*abs(x2-x1)*100+1LL*abs(y2-y1)*100;
    int l=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
        if(x>=x1 && x<=x2 && y>=min(y1,y2) && y<=max(y1,y2)) v[++l]={x,y};
    }
    if(y1==y2)
    {
        if(l>0) sol=sol-20+5.0*pi*2;
        printf("%.16f",sol);
        return 0;
    }
    if(x1==x2)
    {
        if(l>0) sol=sol-20+5.0*pi*2;
        printf("%.16f",sol);
        return 0;
    }
    if(y1>y2) sort(v+1,v+l+1,cmp1);
    else sort(v+1,v+l+1,cmp2);
    for(int i=1;i<=l;i++) v1[i]=v[i];
    sort(v1+1,v1+l+1,cmp3);
    for(int i=1;i<=l;i++)
        v1[i].y=i;
    int c=0;
    for(int i=1;i<=l;i++)
    {
        int st=1,dr=l;
        while(st<=dr)
        {
            int mid=(st+dr)/2;
            if(v1[mid].x<v[i].x) st=mid+1;
            else dr=mid-1;
        }
        int val=arbint_query(1,1,n,1,v1[st].y)+1;
        c=max(c,val);
        arbint_update(1,1,n,v1[st].y,val);
    }
    sol=sol-20*c+5.0*pi*c;
    printf("%.16f",sol);
    return 0;
}


Compiler output:
a.cc: In function 'int arbint_query(int, int, int, int, int)':
a.cc:47:24: error: no matching function for call to 'max(long long int&, int)'
   47 |     if(left<=mid) s=max(s,arbint_query(nod*2,st,mid,left,right));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/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:47:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   47 |     if(left<=mid) s=max(s,arbint_query(nod*2,st,mid,left,right));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:47:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |     if(left<=mid) s=max(s,arbint_query(nod*2,st,mid,left,right));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:48:24: error: no matching function for call to 'max(long long int&, int)'
   48 |     if(mid<right) s=max(s,arbint_query(nod*2+1,mid+1,dr,left,right));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:48:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   48 |     if(mid<right) s=max(s,arbint_query(nod*2+1,mid+1,dr,left,right));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:48:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |     if(mid<right) s=max(s,arbint_query(nod*2+1,mid+1,dr,left,right));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~