Submission #1540657


Source Code Expand

#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& a) {
  sort(all(a));
  a.erase(unique(all(a)), a.end());
}

void precalc() {

}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

#define int li
//const int mod = 1000000007;

void solve(bool read) {
    int x[2], y[2];
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    if (make_pair(x[0], y[0]) > make_pair(x[1], y[1])) {
        swap(x[0], x[1]);
        swap(y[0], y[1]);
    }

    int n;
    cin >> n;
    vector<pair<int, int>> points;
    for (int i = 0; i < n; ++i) {
        int X, Y;
        cin >> X >> Y;
        if (X < x[0] || X > x[1] || Y < min(y[0], y[1]) || Y > max(y[1], y[0])) {
            continue;
        }
        points.push_back({X, Y});
    }

    sort(all(points));

    vector<int> res(n + 1, (int)1e18);
    res[0] = -1;
    for (auto item : points) {
        int id = lower_bound(all(res), item.second) - res.begin();
        res[id] = item.second;
    }

    int best = 0;
    for (int i = res.size() - 1; i >= 0; --i) {
        if (res[i] < 2e9) {
            best = i;
            break;
        }
    }

    //cout << best << endl;

    if (x[0] == x[1] || y[0] == y[1]) {
        double ans = (abs(x[0] - x[1]) + abs(y[0] - y[1])) * 100 + (10 * acos(-1.0) - 20) * best;
        cout << ans << endl;
        return;
    }

    double ans = (abs(x[0] - x[1]) + abs(y[0] - y[1])) * 100 + (5 * acos(-1.0) - 20) * best;

    cout << ans << endl;

}

Submission Info

Submission Time
Task C - Fountain Walk
User Kostroma
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3145 Byte
Status WA
Exec Time 65 ms
Memory 6540 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 3
AC × 37
WA × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_30.txt, subtask_1_31.txt, subtask_1_32.txt, subtask_1_33.txt, subtask_1_34.txt, subtask_1_35.txt, subtask_1_36.txt, subtask_1_37.txt, subtask_1_38.txt, subtask_1_39.txt, subtask_1_40.txt, subtask_1_41.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 1 ms 256 KB
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 1 ms 256 KB
subtask_1_07.txt AC 1 ms 256 KB
subtask_1_08.txt AC 1 ms 256 KB
subtask_1_09.txt AC 14 ms 768 KB
subtask_1_10.txt WA 29 ms 1408 KB
subtask_1_11.txt WA 8 ms 512 KB
subtask_1_12.txt WA 65 ms 6512 KB
subtask_1_13.txt AC 30 ms 1536 KB
subtask_1_14.txt WA 14 ms 768 KB
subtask_1_15.txt WA 7 ms 512 KB
subtask_1_16.txt WA 65 ms 6256 KB
subtask_1_17.txt AC 24 ms 1280 KB
subtask_1_18.txt WA 19 ms 1024 KB
subtask_1_19.txt AC 19 ms 1024 KB
subtask_1_20.txt AC 62 ms 6128 KB
subtask_1_21.txt AC 64 ms 6256 KB
subtask_1_22.txt WA 58 ms 5360 KB
subtask_1_23.txt WA 58 ms 5232 KB
subtask_1_24.txt AC 1 ms 256 KB
subtask_1_25.txt AC 1 ms 256 KB
subtask_1_26.txt AC 1 ms 256 KB
subtask_1_27.txt AC 1 ms 256 KB
subtask_1_28.txt AC 36 ms 2048 KB
subtask_1_29.txt WA 38 ms 2048 KB
subtask_1_30.txt AC 65 ms 5104 KB
subtask_1_31.txt AC 43 ms 5872 KB
subtask_1_32.txt AC 48 ms 5488 KB
subtask_1_33.txt AC 48 ms 4972 KB
subtask_1_34.txt AC 43 ms 6540 KB
subtask_1_35.txt AC 53 ms 5232 KB
subtask_1_36.txt AC 55 ms 5232 KB
subtask_1_37.txt AC 53 ms 5616 KB
subtask_1_38.txt AC 53 ms 5360 KB
subtask_1_39.txt AC 53 ms 4972 KB
subtask_1_40.txt AC 50 ms 5104 KB
subtask_1_41.txt AC 51 ms 5232 KB