From ea4d0774312a8409b1fcb618b2d54f8651714d51 Mon Sep 17 00:00:00 2001 From: TooYoungTooSimp <6648049+TooYoungTooSimp@users.noreply.github.com> Date: Tue, 12 Feb 2019 17:38:08 +0800 Subject: [PATCH] Tue, 12 Feb 2019 17:38:08 GMT --- C279991/.tutorial.md | 10 ++++++++++ C279991/W.cpp | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/C279991/.tutorial.md b/C279991/.tutorial.md index 2024cb0..0f844e8 100644 --- a/C279991/.tutorial.md +++ b/C279991/.tutorial.md @@ -107,3 +107,13 @@ multiset的count好像格外的慢呢。或许是通过`distance(lower_bound,upp 看起来像个什么离散化后最短路一样的东西。实际上map套map就可以了。 //(如果强行说正解是树套树会不会显得高级一点?) + +### W - Glass Carving + +跟上面那个U差不多,只是xy轴要分开维护。 + +正版题解上还有一种线性时间复杂度的离线算法,把正序切割改成倒序合并即可。 + +### End + +那么这一堆内容就结束了。 diff --git a/C279991/W.cpp b/C279991/W.cpp index 7c92ea4..ae763c7 100644 --- a/C279991/W.cpp +++ b/C279991/W.cpp @@ -4,5 +4,19 @@ using namespace std; int main() { + int w, h, n, p; + scanf("%d%d%d", &w, &h, &n); + set _s[2] = {{0, w}, {0, h}}; + multiset _ms[2] = {{w}, {h}}; + for (char op[3]; n--; printf("%lld\n", *_ms[0].rbegin() * *_ms[1].rbegin())) + { + scanf("%s%d", op, &p); + auto &s = _s[*op == 'H']; + auto &ms = _ms[*op == 'H']; + auto it = s.upper_bound(p); + auto len1 = *it - p, len2 = p - *--it; + ms.erase(ms.find(len1 + len2)); + s.insert(p), ms.insert(len1), ms.insert(len2); + } return 0; }