Submission #1246321

#TimeUsernameProblemLanguageResultExecution timeMemory
1246321BoasGarden (JOI23_garden)C++20
6 / 100
3094 ms8960 KiB
#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), ...); } void solve() { int n, m, D; read(n, m, D); vvi artLinesHorz(2 * D); vvi artLinesVert(2 * D); vii typeA(n); for (auto &[x, y] : typeA) { cin >> x >> y; } for (int i = n; i < n + m; i++) { int x, y; cin >> x >> y; artLinesHorz[y].pb(i); artLinesHorz[y + D].pb(i); artLinesVert[x].pb(i); artLinesVert[x + D].pb(i); } int res = D * D; loop(2 * D, a) { for (int b = a; b < 2 * D; b++) { vvi artPerYloc(2 * D); loop(n, i) { if (a <= typeA[i].F && typeA[i].F <= b) { artPerYloc[typeA[i].S].pb(i); artPerYloc[typeA[i].S + D].pb(i); } else if (a <= typeA[i].F + D && typeA[i].F + D <= b) { artPerYloc[typeA[i].S].pb(i); artPerYloc[typeA[i].S + D].pb(i); } } loop(2 * D, c) { vb inTuin(n + m); int cnt = 0; auto add = [&](int i) { cnt += !inTuin[i]; inTuin[i] = 1; }; for (int x = a; x <= b; x++) { for (int i : artLinesVert[x]) add(i); } for (int d = c; d < 2 * D; d++) { for (int i : artLinesHorz[d]) add(i); for (int i : artPerYloc[d]) add(i); if (cnt == n + m) res = min(res, (b - a + 1) * (d - c + 1)); if (cnt > n + m) throw; } } } } print(res); } signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); string name = ""; if (sz(name)) { if (!freopen((name + ".in").c_str(), "r", stdin) || !freopen((name + ".out").c_str(), "w", stdout)) return 1; } int t = 1; // read(t); while (t--) 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...