Language: C++

#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>

#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

struct pt { int x, y; } ;

const double pi = acos(-1);
const double arc = 2 * 10 * pi / 4;

int LIS(vint v) {
  const int inf = 1 << 30;
  int n = v.size();
  vint result(n, inf);
  REP(i, v.size()) {
    int p = lower_bound(ALL(result), v[i]) - result.begin();
    result[p] = v[i];
  }
  REP(i, n) if (result[i] == inf) return i;
  return n;
}

double solve(pt src, pt dst, vector<pt>& v) {
  if (src.x > dst.x) {
    REP(i,v.size()) v[i].x *= -1;
    src.x *= -1;
    dst.x *= -1;
  }  
  if (src.y > dst.y) {
    REP(i,v.size()) v[i].y *= -1;
    src.y *= -1;
    dst.y *= -1;
  }

  vector<pt> u;
  REP(i,v.size()) if (src.x <= v[i].x && v[i].x <= dst.x && src.y <= v[i].y && v[i].y <= dst.y)
    u.push_back(v[i]);

  sort(ALL(u), [](const pt& a, const pt& b){ return a.x < b.x; });
  vint ys;
  REP(i,u.size()) ys.push_back(u[i].y);
  int lis = LIS(ys);
  // pp(ys);
  // cout << "lis " << lis << endl;
  if (lis == min(dx - sx, dy - sy) + 1) {
    return ((dst.x - src.x) + (dst.y - src.y)) * 100LL - 20 * (lis - 1) + arc * (lis - 1) - 20 * 2 * arc;
  }
  return ((dst.x - src.x) + (dst.y - src.y)) * 100LL - 20 * lis + arc * lis;
}

double simple(pt src, pt dst, vector<pt>& v) {
  // src.x == dst.x
  int sy = min(src.y, dst.y);
  int dy = max(src.y, dst.y);
  bool straight = true;
  REP(i, v.size()) if (v[i].x == src.x && sy < v[i].y && v[i].y < dy)
    straight = false;
  if (straight) return (dy - sy) * 100LL;
  else return (dy - sy) * 100LL - 20 + arc * 2;
}

int main(){
  pt src, dst;
  int n;
  while (cin >> src.x >> src.y >> dst.x >> dst.y >> n) {
    vector<pt> v(n);
    REP(i,n) cin >> v[i].x >> v[i].y;
    double result = 0;
    if (src.x == dst.x) {
      result = simple(src, dst, v);
    } else if (src.y == dst.y) {
      REP(i, v.size()) swap(v[i].x, v[i].y);
      swap(src.x, src.y);
      swap(dst.x, dst.y);
      result = simple(src, dst, v);
    } else {
      result = solve(src, dst, v);
    }

    printf("%.12lf\n", result);
  }
}


Compiler output:
a.cc: In function 'double solve(pt, pt, std::vector<pt>&)':
a.cc:79:18: error: 'dx' was not declared in this scope
   79 |   if (lis == min(dx - sx, dy - sy) + 1) {
      |                  ^~
a.cc:79:23: error: 'sx' was not declared in this scope
   79 |   if (lis == min(dx - sx, dy - sy) + 1) {
      |                       ^~
a.cc:79:27: error: 'dy' was not declared in this scope
   79 |   if (lis == min(dx - sx, dy - sy) + 1) {
      |                           ^~
a.cc:79:32: error: 'sy' was not declared in this scope; did you mean 'ys'?
   79 |   if (lis == min(dx - sx, dy - sy) + 1) {
      |                                ^~
      |                                ys