Problem:
Score : 900 points

Problem Statement

In the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1.
All streets run straight from west to east, and all avenues run straight from south to north.
The distance between neighboring streets and between neighboring avenues is exactly 100 meters.

Every street intersects every avenue. Every intersection can be described by pair (x, y), where x is avenue ID and y is street ID.

There are N fountains in the city, situated at intersections (X_i, Y_i).
Unlike normal intersections, there's a circle with radius 10 meters centered at the intersection, and there are no road parts inside this circle.

The picture below shows an example of how a part of the city with roads and fountains may look like.

City governors don't like encountering more than one fountain while moving along the same road.
Therefore, every street contains at most one fountain on it, as well as every avenue.

Citizens can move along streets, avenues and fountain perimeters.
What is the shortest distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2)?

Constraints

0 \leq x_1, y_1, x_2, y_2 < 10^8

1 \leq N \leq 200,000

0 \leq X_i, Y_i < 10^8

X_i \neq X_j for i \neq j

Y_i \neq Y_j for i \neq j

Intersections (x_1, y_1) and (x_2, y_2) are different and don't contain fountains.

All input values are integers.

Input

Input is given from Standard Input in the following format:

x_1 y_1 x_2 y_2
N
X_1 Y_1
X_2 Y_2
:
X_N Y_N

Output

Print the shortest possible distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2), in meters.
Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-11}.

Sample Input 1

1 1 6 5
3
3 2
5 3
2 4

Sample Output 1

891.415926535897938

One possible shortest path is shown on the picture below. The path starts at the blue point, finishes at the purple point and follows along the red line.

Sample Input 2

3 5 6 4
3
3 2
5 3
2 4

Sample Output 2

400.000000000000000

Sample Input 3

4 2 2 2
3
3 2
5 3
2 4

Sample Output 3

211.415926535897938

Solution in C++14 (Clang 3.8.0) (judge verdict: Accepted)

#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N;
ll xs, ys, xg, yg;
ll X[MAX_N], Y[MAX_N];
ll dp[MAX_N+1];

int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);

  cin >> xs >> ys >> xg >> yg;
  cin >> N;
  rep(i, N) cin >> X[i] >> Y[i];

  xg -= xs;
  yg -= ys;
  for (int i = 0; i < N; ++i) {
      X[i] -= xs;
      Y[i] -= ys;
  }

  if (xg < 0) {
      xg *= -1;
      for (int i = 0; i < N; ++i) {
          X[i] *= -1;
      }
  }
  if (yg < 0) {
      yg *= -1;
      for (int i = 0; i < N; ++i) {
          Y[i] *= -1;
      }
  }

  vector<Pii> vp;
  for (int i = 0; i < N; ++i) {
      if (0 <= X[i] && X[i] <= xg && 0 <= Y[i] && Y[i] <= yg) {
          vp.push_back(Pii(X[i], Y[i]));
      }
  }
  sort(all(vp));

  for (int i = 0; i < _size(vp)+1; ++i) {
      dp[i] = INFINT;
  }
  dp[0] = -1;

  for (int i = 0; i < _size(vp); ++i) {
      int idx = upper_bound(dp, dp+_size(vp)+1, vp[i].sc) - dp;
      dp[idx] = vp[i].sc;
  }

  ll K = 0;
  for (int i = 1; i < _size(vp)+1; ++i) {
      if (dp[i] < INFINT) {
          ++K;
      } else {
          break;
      }
  }

  ll s = xg + yg;
  ll q, p;
  if (K < min(xg, yg) + 1) {
      q = K;
      p = 0;
  } else {
      q = K-1;
      p = 1;
  }

  printf("%.15lf\n", 100.0*s - (20.0 - 5.0*M_PI)*q - (20.0 - 10.0*M_PI)*p);
  return 0;
}