Submission #1190598

#TimeUsernameProblemLanguageResultExecution timeMemory
1190598DedibeatGarden (JOI23_garden)C++20
0 / 100
3095 ms4160 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p)
{
    return os << "(" << p.first << "," << p.second << ")";
}
template<typename T>
void print(T v)
{
    for(auto x : v)
        cout << x << " ";
    cout << "\n";
}
int main()
{
    int n, m, d;
    cin >> n >> m >> d;
    vector<pair<int, int>> A(n), B(m);
    for(auto &[x, y] : A)
    {
        cin >> x >> y;
    }
    for(auto &[x, y] : B)
    {
        cin >> x >> y;
    }
    auto checkA = [&](int xl, int xr, int yl, int yr, int x, int y)
    {
        if((xl <= x && x <= xr) && (yl <= y && y <= yr)) return 1;
        else return 0;
    };

    auto checkB = [&](int xl, int xr, int yl, int yr, int x, int y)
    {
        if((xl <= x && x <= xr) || (yl <= y && y <= yr)) return 1;
        else return 0;
    };

    int ans = 1e9;

    for(int i = -d; i < 2 * d; i++)
    {
        for(int j = -d; j < 2 * d; j++)
        {
            for(int k = i; k < 2 * d; k++)
            {
                for(int s = j; s < 2 * d; s++)
                {
                    int ok = 1;
                    for(auto [x, y] : A)
                    {
                        if(!checkA(i, k, j, s, x, y)) ok = 0;
                    }
                    for(auto [x, y] : B)
                    {
                        if(!checkB(i, k, j, s, x, y)) ok = 0;
                    }
                    if(ok) ans = min(ans, (k - i + 1) * (s - j + 1));
                }
            }
        }
    }

    cout << ans << "\n";
}
#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...