Submission #220815

#TimeUsernameProblemLanguageResultExecution timeMemory
220815qkxwsmPyramid Base (IOI08_pyramid_base)C++14
30 / 100
5099 ms118648 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define y1 asdf #define y2 asdfasd #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define SZ(x) ((int) (x).size()) #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; const int MAXN = 1130013; int N, M, K, B; struct rect { int cost; int x1, y1, x2, y2; }; rect arr[MAXN]; vpi ins[MAXN], del[MAXN]; int seg[2 * MAXN], lazy[2 * MAXN]; void push(int w, int L, int R) { if (lazy[w] == 0) return; seg[w] += lazy[w]; if (L != R) { lazy[w << 1] += lazy[w]; lazy[w << 1 | 1] += lazy[w]; } lazy[w] = 0; return; } void update(int w, int L, int R, int a, int b, int v) { push(w, L, R); if (b < L || R < a) return; if (a <= L && R <= b) { lazy[w] += v; push(w, L, R); return; } int mid = (L + R) >> 1; update(w << 1, L, mid, a, b, v); update(w << 1 | 1, mid + 1, R, a, b, v); seg[w] = min(seg[w << 1], seg[w << 1 | 1]); } bool check(int x) { //[ai...ai + x - 1][bi...bi + x - 1]. //in a segment tree, store: //mins, dp[x][y] = longest lengths of mins //0...x - 2 FOR(i, 0, N) { ins[i].clear(); del[i].clear(); } FOR(i, 0, K) { pii p = {max(0, arr[i].y1 - x + 1), arr[i].y2}; ins[max(0, arr[i].x1 - x + 1)].PB(p); del[arr[i].x2].PB(p); } // int sz = M - x; sz = (1 << (33 - __builtin_clz(sz))); // fill(seg, seg + sz + 1, 0); // fill(lazy, lazy + sz + 1, 0); fill(seg, seg + 2 * MAXN, 0); fill(lazy, lazy + 2 * MAXN, 0); // cerr << "TEST " << x << endl; FOR(i, 0, N - x + 1) { // cerr << "pos " << i << endl; for (auto p : ins[i]) { update(1, 0, M - x + 1, p.fi, p.se, 1); // cerr << "+1 " << p.fi << ',' << p.se << endl; } // cerr << "seg1 " << seg[1] << endl; if (seg[1] == 0) return true; for (auto p : del[i]) { update(1, 0, M - x + 1, p.fi, p.se, -1); // cerr << "-1 " << p.fi << ',' << p.se << endl; } } return false; } int32_t main() { cout << fixed << setprecision(12); cerr << fixed << setprecision(4); ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> M >> B >> K; FOR(i, 0, K) { cin >> arr[i].x1 >> arr[i].y1 >> arr[i].x2 >> arr[i].y2 >> arr[i].cost; arr[i].x1--; arr[i].y1--; arr[i].x2--; arr[i].y2--; } int lo = 0, hi = min(N, M); while(hi > lo) { int mid = (hi + lo + 1) >> 1; if (check(mid)) lo = mid; else hi = mid - 1; } cout << lo << '\n'; return 0; }
#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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...