제출 #1247261

#제출 시각아이디문제언어결과실행 시간메모리
1247261BoasGarden (JOI23_garden)C++20
0 / 100
3092 ms12404 KiB
#include <iostream>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T1, typename T2>
using indexed_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_set = indexed_map<T, null_type>;

#define loop(x, i) for (int i = 0; i < (x); i++)
#define loop1(x, i) for (int i = 1; i <= (x); i++)
#define rev(x, i) for (int i = (int)(x) - 1; i >= 0; i--)
#define itloop(x) for (auto it = begin(x); x != end(x); it++)
#define itrev(x) for (auto it = rbegin(x); x != rend(x); it++)
// #define int long long
// #define INF ((int64_t)(4e18 + 1))
#define INF32 ((int32_t)(2e9 + 1))
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define removeIn(x, l) l.erase(find(ALL(l), x))
#define pb push_back
#define sz(x) (int)(x).size()
#define F first
#define S second
#define var const auto &
#define foreach(l) for (var e : l)

typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<i32> vi32;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vi32> vvi32;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<iiii> viiii;
typedef vector<vii> vvii;
typedef vector<viii> vviii;
typedef set<int> si;
typedef set<ii> sii;
typedef map<int, int> mii;
typedef set<iii> siii;
typedef vector<si> vsi;
typedef vector<sii> vsii;
typedef vector<vsi> vvsi;
typedef vector<string> vstr;
typedef vector<vector<string>> vvstr;
typedef vector<bool> vb;
typedef vector<vb> vvb;
template <typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}
template <typename... Ts>
istream &operator>>(istream &in, tuple<Ts...> &t)
{
    apply([&in](Ts &...elems)
          { ((in >> elems), ...); }, t);
    return in;
}
template <typename... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t)
{
    apply([&os](const Args &...args)
          { size_t n = 0;  ((os << ' ' << args), ...); }, t);
    return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << p.F << ' ' << p.S;
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (auto &element : vec)
        is >> element;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
    for (auto &element : vec)
        os << element << ' ';
    return os;
}
template <typename... T>
void DBG(T &&...args) { ((cerr << args << ' '), ...) << endl; }
template <typename... T>
void print(T &&...args) { ((cout << args << ' '), ...) << endl; }
template <typename... T>
void read(T &&...args) { ((cin >> args), ...); }

bitset<5000> inTuin;

void solve()
{
    int n, m, D;
    read(n, m, D);
    vii artLines(m);
    vii typeA(n);
    deque<ii> pts1;
    deque<ii> pts2;
    vector<int> xs;
    vector<int> ys;
    for (auto &[x, y] : typeA)
    {
        cin >> x >> y;
        xs.pb(x);
        xs.pb(x + D);
        ys.pb(y);
        ys.pb(y + D);
    }
    sort(ALL(xs));
    xs.erase(unique(ALL(xs)), end(xs));
    sort(ALL(ys));
    ys.erase(unique(ALL(ys)), end(ys));
    for (auto &[x, y] : artLines)
        cin >> x >> y;
    int res = D * D;
    for (int i = 0; i < sz(xs) / 2; i++)
    {
        for (int j = 0; j < sz(ys) / 2; j++)
        {
            auto chooseDir = [&](auto &&self, int ix, int a, int b, int c, int d)
            {
                if (ix == m)
                {
                    res = min(res, (b - a + 1) * (d - c + 1));
                    return;
                }
                auto [x, y] = artLines[ix];
                if (x < a)
                    x += D;
                if (y < c)
                    y += D;
                self(self, ix + 1, min(a, x), max(b, x), c, d);
                self(self, ix + 1, a, b, min(c, y), max(d, y));
            };
            chooseDir(chooseDir, 0, xs[i], xs[i + sz(xs) / 2 - 1], ys[j], ys[j + sz(ys) / 2 - 1]);
        }
    }
    print(res);
}

signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...