Submission #220639

#TimeUsernameProblemLanguageResultExecution timeMemory
220639dolphingarlicPyramid Base (IOI08_pyramid_base)C++14
20 / 100
1406 ms112772 KiB
#include <bits/stdc++.h> #define FOR(i, x, y) for (int i = x; i < y; i++) typedef long long ll; using namespace std; namespace no_remove { struct obst { int x1, y1, x2, y2; }; struct compare_x { bool operator()(const obst &a, const obst &b) const { return tie(a.x1, a.y1) < tie(b.x1, b.y1); } }; struct compare_y { bool operator()(const obst &a, const obst &b) const { return a.y1 < b.y1; } }; void solve(int H, int W) { int N, C; cin >> N; vector<obst> obsts(N); FOR(i, 0, N) cin >> obsts[i].x1 >> obsts[i].y1 >> obsts[i].x2 >> obsts[i].y2 >> C; sort(obsts.begin(), obsts.end(), compare_y()); set<obst, compare_x> edges{obst{0, -1, 0, -1}, obst{H + 1, W + 1, H + 1, W + 1}}; multiset<int> gaps{H}; int ans = 0; int p = 0; FOR(i, -1, N) { int y0 = -1; if (~i) { const obst &o = obsts[i]; y0 = o.y2; auto pos = edges.find(o); assert(pos != edges.end()); auto a = prev(pos); auto b = next(pos); gaps.erase(gaps.find(o.x1 - a->x2 - 1)); gaps.erase(gaps.find(b->x1 - o.x2 - 1)); gaps.insert(b->x1 - a->x2 - 1); edges.erase(pos); } if (p < i) p = i; int y1 = (p == N) ? W : obsts[p].y1; ans = max(ans, min(y1 - y0 - 1, *gaps.rbegin())); while (p < N && obsts[p].y1 - y0 - 1 <= *gaps.rbegin()) { const obst &o = obsts[p]; auto b = edges.lower_bound(o); auto a = prev(b); gaps.erase(gaps.find(b->x1 - a->x2 - 1)); gaps.insert(o.x1 - a->x2 - 1); gaps.insert(b->x1 - o.x2 - 1); edges.insert(b, o); p++; y1 = (p == N) ? W : obsts[p].y1; ans = max(ans, min(y1 - y0 - 1, *gaps.rbegin())); } } cout << ans << '\n'; } } namespace yes_remove { void solve(int H, int W, int B) { } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int H, W, B; cin >> H >> W >> B; if (B) yes_remove::solve(H, W, B); else no_remove::solve(H, W); 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...