Submission #4034613


Source Code Expand

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int x1, y1, x2, y2;
  int N;
  vec X(N), Y(N);
  vector<P> v;

  cin >> x1 >> y1 >> x2 >> y2;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];

  if (x1 > x2) {
    x1 = 1e8 - x1;
    x2 = 1e8 - x2;
    for (int i = 0; i < N; i++) X[i] = 1e8 - X[i];
  }
  if (y1 > y2) {
    y1 = 1e8 - y1;
    y2 = 1e8 - y2;
    for (int i = 0; i < N; i++) Y[i] = 1e8 - Y[i];
  }

  for (int i = 0; i < N; i++) {
    if (y1 <= Y[i] && Y[i] <= y2 && x1 <= X[i] && X[i] <= x2) v.pb(P(X[i], Y[i]));
  }

  double gd = 20.0 - 5.0 * M_PI;

  sort(ALL(v));

  vec dp(N, INF);
  for (int i = 0; i < v.size(); i++) {
    int tmp = (int)(lower_bound(ALL(dp), v[i].second) - dp.begin());
    chmin(dp[tmp], v[i].second);
  }

  int num = (int)(lower_bound(ALL(dp), INF) - dp.begin());
  double ans = (double)(abs(x1 - x2) * 100.0 + abs(y1 - y2) * 100.0 - num * gd);
  if (num == min(abs(x1 - x2), abs(y1 - y2)) + 1) ans += 5.0 * M_PI;

  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task C - Fountain Walk
User null_null
Language C++14 (Clang 3.8.0)
Score 0
Code Size 2971 Byte
Status CE

Compile Error

./Main.cpp:3:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^
1 error generated.