Language: C++

#include<bits/stdc++.h>

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;

const long double pi = 3.141592653589793238L;

bool extra(int x1,int y1,int x2, int y2, vi ft){
	bool ok = true;
	if((LL)(x1-x2)*(LL)(y1-y2) <0) ok = false;
	int n = (int)ft.size();
	int xm = min(x1,x2), xM = max(x1,x2), ym = min(y1,y2), yM = max(y1,y2);
	if(n==xM-xm+1){
		if(!ok) reverse(ft.begin(),ft.end());
		for(int i=1;i<n;++i) if(ft[i].second<ft[i-1].second)  return false;
		return true;
	}
	if(n==yM-ym+1){
		if(!ok) reverse(ft.begin(),ft.end());
		for(int i=0;i<n;++i) if(ft[i].second != ym+i) return false;
		return true;
	}
	return false;
}

int longestAsc(vi A){
	int n = (int)A.size();
	set<ii> ans;
	ans.insert(ii(A[0],1));
	for(int i=1;i<n;++i){
		auto it = ans.upper_bound(ii(A[i],0));
		auto it1 = it;
		int l = 1;
		if(it!=ans.begin()){
			it--;
			l = it->second + 1;
		}
		while(it1!=ans.end() && it1->second <= l) it1 = ans.erase(it1);
		ans.insert(ii(A[i],l));
	}
	return (--ans.end())->second;
}

LD minDis(int x1,int y1, int x2, int y2, vector<ii> ft){
	if(x1 == x2){
		LD ans = 100.*LD(abs(y1-y2));
		if(ft.empty()) return ans;
		ans += (pi-2.)*(LD)10.;
		return ans;
	}
	if(y1 == y2){
		LD ans = 100.*LD(abs(x1-x2));
		if(ft.empty()) return ans;
		ans += (pi-2.)*(LD)10.;
		return ans;
	}
	LD ans = 100.*LD(abs(x1-x2) + abs(y1-y2));
	if(ft.empty()) return ans;
	sort(ft.begin(),ft.end());
	int cnt = 1;
	bool ok = true, ed = false;
	if((LL)(x1-x2)*(LL)(y1-y2) <0) ok = false;
	int L = (int)ft.size();
	if(ok){
		vi tmp(L);
		for(int i=0;i<L;++i) tmp[i] = ft[i].second;
		cnt = longestAsc(tmp);
	}
	else{
		vi tmp(L);
		for(int i=L-1;i>=0;--i) tmp[L-i-1] = ft[i].second;
		cnt = longestAsc(tmp);
	}
	ans -= (LD)cnt*10.*(2.-pi/2.);
	if(extra(x1,y1,x2,y2,ft)) ans += pi/2.(LD)(10.);
	return ans;
}

int main(){
	int x1,x2,y1,y2,N;
	cin>>x1>>y1>>x2>>y2>>N;
	int xm = min(x1,x2),xM = max(x1,x2), ym=min(y1,y2),yM=max(y1,y2);
	vector<ii> ft;
	for(int i=0;i<N;++i){
		int x,y;
		cin>>x>>y;
		if(x>=xm && x<=xM && y>=ym && y<=yM) ft.push_back(ii(x,y));
	}
	cout << setprecision(31);
	cout << minDis(x1,y1,x2,y2,ft)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'bool extra(int, int, int, int, vi)':
a.cc:32:47: error: request for member 'second' in 'ft.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   32 |                 for(int i=1;i<n;++i) if(ft[i].second<ft[i-1].second)  return false;
      |                                               ^~~~~~
a.cc:32:62: error: request for member 'second' in 'ft.std::vector<int>::operator[](((std::vector<int>::size_type)(i - 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   32 |                 for(int i=1;i<n;++i) if(ft[i].second<ft[i-1].second)  return false;
      |                                                              ^~~~~~
a.cc:37:47: error: request for member 'second' in 'ft.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   37 |                 for(int i=0;i<n;++i) if(ft[i].second != ym+i) return false;
      |                                               ^~~~~~
a.cc: In function 'LD minDis(int, int, int, int, std::vector<std::pair<int, int> >)':
a.cc:92:30: error: could not convert 'ft' from 'vector<std::pair<int, int>>' to 'vector<int>'
   92 |         if(extra(x1,y1,x2,y2,ft)) ans += pi/2.(LD)(10.);
      |                              ^~
      |                              |
      |                              vector<std::pair<int, int>>
a.cc:92:50: error: expected primary-expression before ')' token
   92 |         if(extra(x1,y1,x2,y2,ft)) ans += pi/2.(LD)(10.);
      |                                                  ^
a.cc:92:50: error: expression cannot be used as a function