Language: C++

#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,popcnt,sse4.1,sse4.2,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 105, mod = 1e9 + 7;
const ld tau = 6.28318530717958647692;
const ld A = 2.5*tau - 20.;
const ld B = 5.0*tau - 20.;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define y1 orz
int x1, n, y1, m, k;
vpi a;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> x1 >> y1 >> n >> m >> k;
	n -= x1, m -= y1;
	a.resize(k);
	for(auto &i : a) cin >> i.first >> i.second, i.first -= x1, i.second -= y1;
	if(n < 0) {
		n *= -1;
		for(auto &i : a) i.first *= -1;
	}
	if(m < 0) {
		m *= -1;
		for(auto &i : a) i.second *= -1;
	}
	map<int, int> xty, ytx;
	{
		vpi t;
		for(auto &i : a) {
			if(i.first >= 0 && i.first <= n && i.second >= 0 && i.second <= m) t.pb(i);
		}
		a = t;
		for(auto i : a) {
			xty[i.first] = i.second;
			ytx[i.second] = i.first;
		}
	}
	if(a.empty()) return cout << fixed << setprecision(15) << 100.*(n+m), 0;
	if(n == 0 || m == 0) return cout << fixed << setprecision(15) << 100.*(n+m) + lis.size()*B, 0;
	vi lis, ux, uy;
	sort(all(a));
	for(auto &i : a) {
		auto it = lower_bound
		(all(lis), i.second);
		if(it == lis.end()) {
			lis.pb(i.second), it = --lis.end();
			ux.pb(ux.size()?ux.back():0);
			uy.pb(uy.size()?uy.back():0);
		} else {
			*it = i.second;
		}
		int p = it-lis.begin();
		if(p) {
			ux[p] |= ytx[lis[p]]-ytx[lis[p-1]]>1;
			uy[p] |= lis[p]-lis[p-1]>1;
		}
	}
	int border = 0;
	pi pos;
	for(auto i : a) {
		if(!binary_search(all(lis), i.second)) continue;
		if(i.first==0 || i.first==n || i.second==0 || i.second==m) pos = i, border = 1;
	}
	if(!border || ((pos.first == 0 || pos.first == n)?ux.back():uy.back())) return cout << fixed << setprecision(15) << 100.*(n+m) + lis.size()*A, 0;
	if((lis.back().first!=n&&lis.back().second!=m)||(lis[0].first&&lis[0].second)) lis.pb({0, 0});
	cout << fixed << setprecision(15) << 100.*(n+m) + ((int)lis.size()-(lis.size()%2==0))*A + B*(lis.size()%2==0), 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:87: error: 'lis' was not declared in this scope
   52 |         if(n == 0 || m == 0) return cout << fixed << setprecision(15) << 100.*(n+m) + lis.size()*B, 0;
      |                                                                                       ^~~
a.cc:78:24: error: request for member 'first' in 'lis.std::vector<int>::back()', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   78 |         if((lis.back().first!=n&&lis.back().second!=m)||(lis[0].first&&lis[0].second)) lis.pb({0, 0});
      |                        ^~~~~
a.cc:78:45: error: request for member 'second' in 'lis.std::vector<int>::back()', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   78 |         if((lis.back().first!=n&&lis.back().second!=m)||(lis[0].first&&lis[0].second)) lis.pb({0, 0});
      |                                             ^~~~~~
a.cc:78:65: error: request for member 'first' in 'lis.std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   78 |         if((lis.back().first!=n&&lis.back().second!=m)||(lis[0].first&&lis[0].second)) lis.pb({0, 0});
      |                                                                 ^~~~~
a.cc:78:79: error: request for member 'second' in 'lis.std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   78 |         if((lis.back().first!=n&&lis.back().second!=m)||(lis[0].first&&lis[0].second)) lis.pb({0, 0});
      |                                                                               ^~~~~~
a.cc:78:94: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   78 |         if((lis.back().first!=n&&lis.back().second!=m)||(lis[0].first&&lis[0].second)) lis.pb({0, 0});
      |                                                                                        ~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~