Language: C++

#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

#define LL long long
inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 400010;
const int INF = 2147483600;

int N;
const double Pi = acos(-1);
const double Ti = 20.0-5.0*Pi;
const double Ci = 10.0*Pi-20.0;

int x1,y1,x2,y2;
int dx[MAXN+1],dy[MAXN+1];
struct data{
	int x,y,opr;
}p[MAXN+1],to[MAXN+1];
bool cmp(data a,data b){
	if(a.x!=b.x) return a.x<b.x;
	return a.y<b.y;
} double ret=-INF; int f[MAXN+1];
int c[MAXN+1],cx,cy; int d[MAXN+1];

inline int lowbit(int x){return x&(-x);}
inline void Add(int k,int x){
	for(;k<=cy;k+=lowbit(k)) c[k]=max(c[k],x);
} inline int Query(int k){
	int ret=0; for(;k;k-=lowbit(k)) ret=max(ret,c[k]); return ret;
} int topx; double zei=INF;

inline void solve(){
	sort(p+1,p+N+1,cmp); memset(c,0,sizeof(c));
	int tmp=0; double num=0,rg=0;
	if(y1<y2){
		topx=0; data ng;
		for(int i=1;i<=N;i++){
			if(p[i].x>=x1&&p[i].x<=x2&&p[i].y==y2) ng=p[i],num=Ci,rg+=Ci;
			if(p[i].y>=y1&&p[i].y<=y2&&p[i].x==x1) rg+=Ci; 
			if(p[i].x>=x1&&p[i].x<=x2&&p[i].y<=y2&&p[i].y>=y1) to[++topx]=p[i]; 
		} int j=1,l=0;
		for(int i=x1;i<=x2;i++){
			int now=j; if(i==ng.x) num=0;
			while(j<=topx&&to[j].x==i) {
				f[j]=max(Query(to[j].y)+1,1);
				ret=max(ret,1.0*f[j]*Ti-num);++j;
			} for(int k=now;k<j;k++) Add(to[k].y,f[k]);
		}
	} else{
		topx=0; data ng;
		for(int i=1;i<=N;i++){
			if(p[i].x>=x1&&p[i].x<=x2&&p[i].y==y1) ng=p[i],num=Ci,rg+=Ci;
			if(p[i].y>=y2&&p[i].y<=y1&&p[i].x==x1) rg+=Ci; 
			if(p[i].x>=x1&&p[i].x<=x2&&p[i].y<=y1&&p[i].y>=y2) to[++topx]=p[i];
		} int j=1,l=0;
		for(int i=x1;i<=x2;i++){
			int now=j; if(i==ng.x) num=0;
			while(j<=topx&&to[j].x==i) {
				f[j]=max(Query(to[j].y)+1,1);
				ret=max(ret,f[j]*Ti-num);++j;
			} for(int k=now;k<j;k++) Add(cy-to[k].y+1,f[k]);
		}
	} zei=min(zei,rg);
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	x1=read(),y1=read(),x2=read(),y2=read();
	N=read(); for(int i=1;i<=N;i++){
		p[i].x=read(),p[i].y=read(); p[i].opr=1;
		c[++cx]=p[i].x,d[++cy]=p[i].y;
	} c[++cx]=x1; c[++cx]=x2; d[++cy]=y1; d[++cy]=y2;
	if(x1==x2||y1==y2){
		if(x1>x2) swap(x1,x2); if(y1>y2) swap(y1,y2); zei=0;
		for(int i=1;i<=N;i++){
			if(p[i].x>=x1&&p[i].x<=x2&&p[i].y>=y1&&p[i].y<=y2) zei+=Ci;
		} printf("%.11lf\n",abs(x1-x2)*100+abs(y1-y2)*100+zei);
		return 0;
	}
	sort(c+1,c+cx+1); sort(d+1,d+cy+1);
	cx=unique(c+1,c+cx+1)-c-1,cy=unique(d+1,d+cy+1)-d-1;
	for(int i=1;i<=N;i++){
		p[i].x=lower_bound(c+1,c+cx+1,p[i].x)-c;
		p[i].y=lower_bound(d+1,d+cy+1,p[i].y)-d;
	}
	x1=lower_bound(c+1,c+cx+1,x1)-c; y1=lower_bound(d+1,d+cy+1,y1)-d;
	x2=lower_bound(c+1,c+cx+1,x2)-c; y2=lower_bound(d+1,d+cy+1,y2)-d;
	double ans=abs(d[y1]-d[y2])*100+abs(c[x1]-c[x2])*100;
	if(x1>x2) swap(x1,x2),swap(y1,y2); solve();
	swap(x1,y1); swap(x2,y2); if(x1>x2) swap(x1,x2); 
	for(int i=1;i<=N;i++) swap(p[i].x,p[i].y); swap(cy,cx);
	solve(); printf("%.11lf\n",min(ans-ret,zei+ans));
}




Compiler output:
a.cc:25:8: error: 'int y1' redeclared as different kind of entity
   25 | int 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/requires_hosted.h:31,
                 from /usr/include/c++/14/iostream:38,
                 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:30:10: error: reference to 'data' is ambiguous
   30 | bool cmp(data a,data b){
      |          ^~~~
In file included from /usr/include/c++/14/string:53,
                 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,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:27:8: note:                 'struct data'
   27 | struct data{
      |        ^~~~
a.cc:30:17: error: reference to 'data' is ambiguous
   30 | bool cmp(data a,data b){
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:27:8: note:                 'struct data'
   27 | struct data{
      |        ^~~~
a.cc:30:23: error: expression list treated as compound expression in initializer [-fpermissive]
   30 | bool cmp(data a,data b){
      |                       ^
a.cc: In function 'void solve()':
a.cc:46:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   46 |         if(y1<y2){
      |            ~~^~~
a.cc:47:25: error: reference to 'data' is ambiguous
   47 |                 topx=0; data ng;
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:27:8: note:                 'struct data'
   27 | struct data{
      |        ^~~~
a.cc:49:64: error: 'ng' was not declared in this scope; did you mean 'rg'?
   49 |                         if(p[i].x>=x1&&p[i].x<=x2&&p[i].y==y2) ng=p[i],num=Ci,rg+=Ci;
      |                                                                ^~
      |                                                                rg
a.cc:50:34: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   50 |                         if(p[i].y>=y1&&p[i].y<=y2&&p[i].x==x1) rg+=Ci;
      |                            ~~~~~~^~~~
a.cc:51:70: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   51 |                         if(p[i].x>=x1&&p[i].x<=x2&&p[i].y<=y2&&p[i].y>=y1) to[++topx]=p[i];
      |                                                                ~~~~~~^~~~
a.cc:54:42: error: 'ng' was not declared in this scope; did you mean 'rg'?
   54 |                         int now=j; if(i==ng.x) num=0;
      |                                          ^~
      |                                          rg
a.cc:61:25: error: reference to 'data' is ambiguous
   61 |                 topx=0; data ng;
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:27:8: note:                 'struct data'
   27 | struct data{
      |        ^~~~
a.cc:63:58: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   63 |                         if(p[i].x>=x1&&p[i].x<=x2&&p[i].y==y1) ng=p[i],num=Ci,rg+=Ci;
      |                                                    ~~~~~~^~~~
a.cc:63:64: error: 'ng' was not declared in this scope; did you mean 'rg'?
   63 |                         if(p[i].x>=x1&&p[i].x<=x2&&p[i].y==y1) ng=p[i],num=Ci,rg+=Ci;
      |                                                                ^~
      |                                                                rg
a.cc:64:46: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   64 |                         if(p[i].y>=y2&&p[i].y<=y1&&p[i].x==x1) rg+=Ci;
      |                                        ~~~~~~^~~~
a.cc:65:58: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   65 |                         if(p[i].x>=x1&&p[i].x<=x2&&p[i].y<=y1&&p[i].y>=y2) to[++topx]=p[i];
      |                                                    ~~~~~~^~~~
a.cc:68:42: error: 'ng' was not declared in this scope; did you mean 'rg'?
   68 |                         int now=j; if(i==ng.x) num=0;
      |                                          ^~
      |                                          rg
a.cc: In function 'int main()':
a.cc:79:21: error: assignment of function 'double y1(double)'
   79 |         x1=read(),y1=read(),x2=read(),y2=read();
      |                   ~~^~~~~~~
a.cc:83:43: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
   83 |         } c[++cx]=x1; c[++cx]=x2; d[++cy]=y1; d[++cy]=y2;
      |                                           ^~
      |                                           |
      |                                           double (*)(double) noexcept
a.cc:84:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   84 |         if(x1==x2||y1==y2){
      |                    ~~^~~~
a.cc:85:45: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   85 |                 if(x1>x2) swap(x1,x2); if(y1>y2) swap(y1,y2); zei=0;
      |                                           ~~^~~
a.cc:85:54: error: no matching function for call to 'swap(double (&)(double) noexcept, int&)'
   85 |                 if(x1>x2) swap(x1,x2); if(y1>y2) swap(y1,y2); zei=0;
      |                                                  ~~~~^~~~~~~
In file included from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/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/exception_ptr.h:41:
/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&)'
  22