AtCoder Grand Contest 019

Submission #4034636

Source codeソースコード

#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 double PI = (double)acos(-1);
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, Y;
  vector<P> v;

  cin >> x1 >> y1 >> x2 >> y2;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    X.pb(x);
    Y.pb(y);
  }

  if (x1 > x2) {
    x1 = 100000000 - x1;
    x2 = 100000000 - x2;
    for (int i = 0; i < N; i++) X[i] = 100000000 - X[i];
  }
  if (y1 > y2) {
    y1 = 100000000 - y1;
    y2 = 100000000 - y2;
    for (int i = 0; i < N; i++) Y[i] = 100000000 - 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 * 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 * PI;

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

Submission

Task問題 C - Fountain Walk
User nameユーザ名 ぬるぬる
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 900
Source lengthソースコード長 3083 Byte
File nameファイル名
Exec time実行時間 177 ms
Memory usageメモリ使用量 9572 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 900 / 900 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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 53 ms 2156 KB
subtask_1_10.txt AC 110 ms 3940 KB
subtask_1_11.txt AC 29 ms 1396 KB
subtask_1_12.txt AC 176 ms 8164 KB
subtask_1_13.txt AC 117 ms 4068 KB
subtask_1_14.txt AC 54 ms 2156 KB
subtask_1_15.txt AC 26 ms 1276 KB
subtask_1_16.txt AC 177 ms 8548 KB
subtask_1_17.txt AC 96 ms 3436 KB
subtask_1_18.txt AC 75 ms 2796 KB
subtask_1_19.txt AC 74 ms 2796 KB
subtask_1_20.txt AC 164 ms 9060 KB
subtask_1_21.txt AC 177 ms 8036 KB
subtask_1_22.txt AC 176 ms 9444 KB
subtask_1_23.txt AC 176 ms 8036 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 121 ms 5220 KB
subtask_1_29.txt AC 149 ms 5220 KB
subtask_1_30.txt AC 176 ms 8032 KB
subtask_1_31.txt AC 130 ms 9188 KB
subtask_1_32.txt AC 137 ms 8292 KB
subtask_1_33.txt AC 135 ms 8032 KB
subtask_1_34.txt AC 131 ms 9572 KB
subtask_1_35.txt AC 164 ms 9316 KB
subtask_1_36.txt AC 165 ms 8032 KB
subtask_1_37.txt AC 165 ms 9060 KB
subtask_1_38.txt AC 164 ms 8676 KB
subtask_1_39.txt AC 164 ms 8032 KB
subtask_1_40.txt AC 161 ms 8292 KB
subtask_1_41.txt AC 161 ms 8932 KB