Submission #1540617


Source Code Expand

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const double PI = acos(-1);

int X[200050], Y[200050];

int flip(int s) {
  return 100000000 - s - 1;
}

int lis(const vector<int>& a) {
  const int n = a.size();
  if (n == 0) {
    return 0;
  }
  
  vector<int> A(n, INF), id(n);
  for (int i = 0; i < n; ++i) {
    id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i]));
    A[id[i]] = a[i];
  }
  return *max_element(id.begin(), id.end()) + 1;
}

int main() {
  int sx = in();
  int sy = in();
  int gx = in();
  int gy = in();
  int N = in();

  for (int i = 0; i < N; ++i) {
    X[i] = in();
    Y[i] = in();
  }

  if (sx > gx) {
    sx = flip(sx);
    gx = flip(gx);
    for (int i = 0; i < N; ++i) {
      X[i] = flip(X[i]);
    }
  }
  if (sy > gy) {
    sy = flip(sy);
    gy = flip(gy);
    for (int i = 0; i < N; ++i) {
      Y[i] = flip(Y[i]);
    }
  }
  if (gx - sx < gy - sy) {
    swap(sx, sy);
    swap(gx, gy);
    for (int i = 0; i < N; ++i) {
      swap(X[i], Y[i]);
    }
  }

  map<int, int> xpos;
  for (int i = 0; i < N; ++i) {
    xpos[Y[i]] = X[i];
  }

  bool stairs = true;
  for (int y = sy, px = -1; y <= gy; ++y) {
    if (xpos.count(y) == 0) {
      stairs = false;
      break;
    }
    int x = xpos[y];
    if (px != -1 && x != px + 1) {
      stairs = false;
      break;
    }
    px = x;
  }

  if (stairs) {
    double res = 0;
    res += (5 * PI - 20) * (gy - sy);
    res += (10 * PI - 20);
    printf("%.13f\n", res + ((gx - sx) + (gy - sy)) * 100.0);
    return 0;
  }

  vector<pair<int, int>> F;
  for (int i = 0; i < N; ++i) {
    if (sy <= Y[i] && Y[i] <= gy && sx <= X[i] && X[i] <= gx) {
      F.emplace_back(Y[i], X[i]);
    }
  }
  sort(F.begin(), F.end());

  vector<int> xs;
  for (const auto& p : F) {
    xs.push_back(p.second);
  }

  int L = lis(xs);
  double res = (5 * PI - 20) * L;
  printf("%.13f\n", res + ((gx - sx) + (gy - sy)) * 100.0);

  return 0;
}

Submission Info

Submission Time
Task C - Fountain Walk
User japlj
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2941 Byte
Status WA
Exec Time 140 ms
Memory 15348 KB

Compile Error

./Main.cpp: In function ‘int in()’:
./Main.cpp:34:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 int in() { int x; scanf("%d", &x); return x; }
                                  ^
./Main.cpp: In function ‘double fin()’:
./Main.cpp:35:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 double fin() { double x; scanf("%lf", &x); return x; }
                                          ^
./Main.cpp: In function ‘Int lin()’:
./Main.cpp:36:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 Int lin() { Int x; scanf("%lld", &x); return x; }
                                     ^

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 35 ms 4096 KB
subtask_1_10.txt WA 79 ms 8192 KB
subtask_1_11.txt WA 18 ms 2304 KB
subtask_1_12.txt WA 139 ms 15348 KB
subtask_1_13.txt AC 84 ms 8704 KB
subtask_1_14.txt WA 36 ms 4096 KB
subtask_1_15.txt WA 16 ms 2048 KB
subtask_1_16.txt WA 139 ms 15348 KB
subtask_1_17.txt AC 68 ms 7296 KB
subtask_1_18.txt AC 52 ms 5760 KB
subtask_1_19.txt AC 51 ms 5632 KB
subtask_1_20.txt AC 137 ms 15348 KB
subtask_1_21.txt AC 139 ms 15348 KB
subtask_1_22.txt AC 140 ms 15348 KB
subtask_1_23.txt AC 140 ms 15348 KB
subtask_1_24.txt WA 1 ms 256 KB
subtask_1_25.txt WA 1 ms 256 KB
subtask_1_26.txt WA 1 ms 256 KB
subtask_1_27.txt WA 1 ms 256 KB
subtask_1_28.txt AC 109 ms 11364 KB
subtask_1_29.txt AC 112 ms 11264 KB
subtask_1_30.txt AC 140 ms 15348 KB
subtask_1_31.txt AC 105 ms 15348 KB
subtask_1_32.txt AC 115 ms 15348 KB
subtask_1_33.txt AC 112 ms 15348 KB
subtask_1_34.txt AC 86 ms 15348 KB
subtask_1_35.txt AC 98 ms 15348 KB
subtask_1_36.txt AC 140 ms 15348 KB
subtask_1_37.txt AC 114 ms 15348 KB
subtask_1_38.txt AC 108 ms 15348 KB
subtask_1_39.txt AC 111 ms 15348 KB
subtask_1_40.txt AC 107 ms 15348 KB
subtask_1_41.txt AC 109 ms 15348 KB