Language: C++

#include<bits/stdc++.h>

const int N = 200010;
const double PI = std::acos(-1);
typedef std::pair <int, int> pii;

int x1, y1, x2, y2;
int n;
std::vector <pii> fount;
int c[N];

bool in(int x1, int x2, int x){
	return x1 <= x && x <= x2 || x1 >= x && x >= x2;
}

const int MAX = 1 << 18;

int seg[MAX << 1];

void add(int sit, int value){
	seg[sit += MAX] = value;
	for (sit >>= 1; sit; sit >>= 1){
		seg[sit] = std::max(seg[sit << 1], seg[sit << 1 | 1]);
	}
}

int query(int l, int r){
	int ret = 0;
	for (l += MAX, r += MAX + 1; l < r; l >>= 1, r >>= 1){
		if (l & 1) ret = std::max(ret, seg[l ++]);
		if (r & 1) ret = std::max(ret, seg[-- r]);
	}
	return ret;
}

int main(){
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	if (x1 > x2){
		std::swap(x1, x2);
		std::swap(y1, y2);
	}
	scanf("%d", &n);
	for (int i = 0, x, y; i < n; ++ i){
		scanf("%d%d", &x, &y);
		if (in(x1, x2, x) && in(y1, y2, y)){
			fount.push_back({x, y});
		}
	}
	if (x1 == x2 || y1 == y2){
		double ans = 100ll * (std::abs(x2 - x1) + std::abs(y2 - y1));
		if (!fount.empty()){
			ans += (PI - 2) * 10;
		}
		printf("%.14lf\n", ans);
		return 0;
	}
	std::sort(fount.begin(), fount.end());
	int cnt = 0;
	for (auto u : fount){
		c[cnt ++] = u.second;
	}
	std::sort(c, c + cnt);
	for (auto u : fount){
		int sit = std::lower_bound(c, c + cnt, u.second) - c;
		int x = y1 < y2 ? query(0, sit) : query(sit, MAX - 1);
		add(sit, x + 1);
	}
	int x = query(0, MAX - 1);
	double ans = 100ll * (std::abs(x2 - x1) + std::abs(y2 - y1));
	ans -= (2 - PI / 2) * x * 10;
	printf("%.14lf\n", ans);
	return 0;
}

Compiler output:
a.cc:7:9: error: 'int y1' redeclared as different kind of entity
    7 | 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/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
                 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 'int main()':
a.cc:40:26: error: no matching function for call to 'swap(double (&)(double) noexcept, int&)'
   40 |                 std::swap(y1, y2);
      |                 ~~~~~~~~~^~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:77:
/usr/include/c++/14/any:430:15: note: candidate: 'void std::swap(any&, any&)' (near match)
  430 |   inline void swap(any& __x, any& __y) noexcept { __x.swap(__y); }
      |               ^~~~
/usr/include/c++/14/any:430:15: note:   conversion of argument 2 would be ill-formed:
a.cc:40:31: error: cannot bind non-const lvalue reference of type 'std::any&' to an rvalue of type 'std::any'
   40 |                 std::swap(y1, y2);
      |                               ^~
/usr/include/c++/14/any:191:7: note:   after user-defined conversion: 'std::any::any(_Tp&&) [with _Tp = int&; _VTp = int; _Mgr = _Manager_internal<int>; typename std::enable_if<(is_copy_constructible_v<_VTp> && (! __is_in_place_type_v<_VTp>)), bool>::type <anonymous> = true]'
  191 |       any(_Tp&& __value)
      |       ^~~
In file included from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/stdexcept:38,
                 from /usr/include/c++/14/system_error:43,
                 from /usr/include/c++/14/bits/ios_base.h:46,
                 from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/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/future:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:176:
/usr/include/c++/14/bits/std_thread.h:328:3: note: candidate: 'void std::swap(thread&, thread&)'
  328 |   swap(thread& __x, thread& __y) noexcept
      |   ^~~~
/usr/include/c++/14/bits/std_thread.h:328:16: note:   no known conversion for argument 1 from 'double(double) noexcept' to 'std::thread&'
  328 |   swap(thread& __x, thread& __y) noexcept
      |        ~~~~~~~~^~~
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/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/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:40:26: note:   deduced conflicting types for parameter '_Tp' ('double(double) noexcept' and 'int')
   40 |                 std::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:40:26: note:   mismatched types '_Tp [_Nm]' and 'double(double) noexcept'
   40 |                 std::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:40:26: note:   mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept'
   40 |                 std::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:40:26: note:   mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept'
   40 |                 std::swap(y1, y2);
      |                 ~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 4039 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'double(double) noexcept'
   40 |                 std::swap(y1, y2);
      |                 ~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68:
/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<_UTypes ...>&, tuple<_UTypes ...>&)'
 2805 |     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
      |     ^~~~
/usr/include/c++/14/tuple:2805:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   mismatched types 'std::tuple<_UTypes ...>' and 'double(double) noexcept'
   40 |                 std::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<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted)
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
/usr/include/c++/14/tuple:2823:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   mismatched types 'std::tuple<_UTypes ...>' and 'double(double) noexcept'
   40 |                 std::swap(y1, y2);
      |                 ~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/functional:59,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/std_function.h:782:5: note: candidate: 'template<class _Res, class ... _Args> void std::swap(function<_Res(_ArgTypes ...)>&, function<_Res(_ArgTypes ...)>&)'
  782 |     swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept
      |     ^~~~
/usr/include/c++/14/bits/std_function.h:782:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   mismatched types 'std::function<_Res(_ArgTypes ...)>' and 'double(double) noexcept'
   40 |                 std::swap(y1, y2);
      |                 ~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63:
/usr/include/c++/14/bits/unordered_map.h:2130:5: note: candidate: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> void std::swap(unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&)'
 2130 |     swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/unordered_map.h:2130:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   mismatched types 'std::unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>' and 'double(double) noexcept'
   40 |                 std::swap(y1, y2);
      |                 ~~~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:2137:5: note: candidate: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> void std::swap(unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&)'
 2137 |     swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/unordered_map.h:2137:5: note:   template argument deduction/substitution failed:
a.cc:40:26: note:   mismatched types 'std::unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>' and 'double(double) noexcept'
   40 |                 std::swap(y1, y2);
      |                 ~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64:
/usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate: 'template<class _Tp,