Submission #393482

# Submission time Handle Problem Language Result Execution time Memory
393482 2021-04-23T15:05:42 Z usachevd0 Aliens (IOI16_aliens) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#ifndef DEBUG
  #include "messy.h"
#endif

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using ld = long double;
template<typename T1, typename T2> bool chkmin(T1& x, T2 y) {
  return y < x ? (x = y, true) : false;
}
template<typename T1, typename T2> bool chkmax(T1& x, T2 y) {
  return y > x ? (x = y, true) : false;
}
void debug_out() {
  cerr << endl;
}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) {
  cerr << ' ' << A;
  debug_out(B...);
}
template<typename T> void mdebug_out(T* a, int n) {
  for (int i = 0; i < n; ++i) cerr << a[i];
  cerr << endl;
}
template<typename T> ostream& operator << (ostream& stream, const vector<T>& v) {
  for (auto& x : v) {
    stream << x << ' ';
  }
  return stream;
}
template<typename T1, typename T2> ostream& operator << (ostream& stream, const pair<T1, T2>& p) {
  return stream << p.first << ' ' << p.second;
}

#ifdef DEBUG
  #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
  #define mdebug(a, n) cerr << #a << ": ", mdebug_out(a, n)
#else
  #define debug(...) 1337
  #define mdebug(a, n) 1337
#endif


const ll INF64 = 1e18;
const int maxN = 100005;

ll squared(ll a) {
  return a * a;
}

struct pt {
  int x, y;

  pt(int _x = 0, int _y = 0): x(_x), y(_y) {}

  pt operator + (const pt& p) const { return pt(x + p.x, y + p.y); }
  pt operator - (const pt& p) const { return pt(x - p.x, y - p.y); }
};
ostream& operator << (ostream& stream, const pt& p) {
  return stream << p.x << ' ' << p.y;
}

ll take_photos(int n, int _m, int K, vector<int> _r, vector<int> _c) {
  vector<pt> points(n);
  for (int i = 0; i < n; ++i) {
    points[i] = {_r[i], _c[i]};
    if (points[i].x > points[i].y) {
      swap(points[i].x, points[i].y);
    }
  }
  sort(all(points), [&](const pt& P, const pt& Q) -> bool {
    if (P.x != Q.x) return P.x < Q.x;
    return P.y > Q.y;
  });
  vector<pt> a;
  for (auto P : points) {
    if (!a.empty() && P.y <= a.back().y) continue;
    while (!a.empty() && P.x == a.back().x) {
      a.pop_back();
    }
    a.push_back(P);
  }
  n = a.size();
  debug(a);
  vector<ll> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    x[i] = a[i].x;
    y[i] = a[i].y;
  }

  vector<ll> I(n, 0);
  for (int i = 1; i < n; ++i) {
    if (x[i] > y[i - 1]) {
      I[i] = 0;
    } else {
      I[i] = squared(y[i - 1] - x[i] + 1);
    }
  }

  vector<vector<ll>> dp(n + 1, vector<ll>(K + 1, INF64));
  fill(all(dp[0]), 0);
  for (int i = 1; i <= n; ++i) {
    for (int k = 1; k <= K; ++k) {
      for (int j = 0; j < i; ++j) {
        chkmin(dp[i][k], dp[j][k - 1] + squared(y[i - 1] - x[j] + 1) - I[j]);
      }
    }
  }
  return dp[n][K];
}

#ifdef DEBUG
int32_t main() {
#ifdef DEBUG
  freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n, m, k;
  cin >> n >> m >> k;
  vector<int> r(n), c(n);
  for (int i = 0; i < n; ++i) cin >> r[i] >> c[i];
  cout << take_photos(n, m, k, r, c) << '\n';

  return 0;
}
#endif

Compilation message

aliens.cpp:3:12: fatal error: messy.h: No such file or directory
    3 |   #include "messy.h"
      |            ^~~~~~~~~
compilation terminated.