Submission #524812

#TimeUsernameProblemLanguageResultExecution timeMemory
524812pokmui9909Pyramid Base (IOI08_pyramid_base)C++17
25 / 100
1244 ms134064 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int S = (1 << 20); struct Node{ int l, r, mn, len, pfx, sfx, d; Node operator+(const Node &k)const{ Node ret = {l, k.r, min(mn, k.mn), len + k.len, pfx, k.sfx, 0LL}; if(mn == ret.mn) ret.d = max(ret.d, d); if(k.mn == ret.mn) ret.d = max(ret.d, k.d); if(pfx == len && l == k.l) ret.pfx = len + k.pfx; if(k.sfx == k.len && r == k.r) ret.sfx = k.len + sfx; if(r == k.l && r == ret.mn) ret.d = max(ret.d, sfx + k.pfx); return ret; } }; struct SegTree{ Node T[2 * S]; int lazy[2 * S] = {}; void init(int node, int s, int e){ if(s == e){ T[node] = {0, 0, 0, 1, 1, 1, 1}; return; } int lch = 2 * node, rch = 2 * node + 1, m = (s + e) / 2; init(lch, s, m); init(rch, m + 1, e); T[node] = T[lch] + T[rch]; } void propagate(int node, int s, int e){ int lch = 2 * node, rch = 2 * node + 1; if(s != e){ lazy[lch] += lazy[node], lazy[rch] += lazy[node]; } T[node].l += lazy[node]; T[node].r += lazy[node]; T[node].mn += lazy[node]; lazy[node] = 0; } void update(int node, int s, int e, int l, int r, int v){ propagate(node, s, e); if(e < l || s > r) return; if(l <= s && e <= r){ lazy[node] += v; propagate(node, s, e); return; } int lch = 2 * node, rch = 2 * node + 1, m = (s + e) / 2; update(lch, s, m, l, r, v); update(rch, m + 1, e, l, r, v); T[node] = T[lch] + T[rch]; } int query(){ return (T[1].mn == 0 ? T[1].d : 0); } }; SegTree ST; struct Line{ int y1, y2, c; }; vector<Line> L[1000005], R[1000005]; int M, N, P, B; int main(){ cin.tie(0) -> sync_with_stdio(false); cin >> M >> N >> B >> P; for(int i = 1; i <= P; i++){ int x1, y1, x2, y2, c; cin >> x1 >> y1 >> x2 >> y2 >> c; if(B == 0) c = 1; L[x1].push_back({y1, y2, c}); R[x2].push_back({y1, y2, -c}); } int ans = 0; int S = 1, E = 1; ST.init(1, 1, M); for(auto i : L[1]) ST.update(1, 1, N, i.y1, i.y2, i.c); while(S <= E && E <= M){ int v = ST.query(); if(v >= E - S + 1){ ans = max(ans, E - S + 1); E++; for(auto i : L[E]) ST.update(1, 1, N, i.y1, i.y2, i.c); } else { for(auto i : R[S]) ST.update(1, 1, N, i.y1, i.y2, i.c); S++; } } cout << ans; }
#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...