BZOJ1513 [Poi2006]tet-tetris 3D

Source: Internet
Author: User

Bare two-dimensional line tree ... Find rectangle maximum and rectangle overlay

The board is more troublesome to knock up Qaq

1 /**************************************************************2 problem:15133 User:rausen4 language:c++5 result:accepted6 time:24884 Ms7 memory:127268 KB8 ****************************************************************/9  Ten#include <cstdio> One#include <algorithm> A   - using namespacestd; -   theInlineintread (); -   - intN, M; -   + structSEGX { -SEGX *ls, *rs; +     intMX, tag; A       at segx () { -ls = rs = NULL, mx = tag =0; -     } -       -     #defineLen (1 << 16) -Inlinevoid*operator New(size_t) { in         StaticSEGX *mempool, *C; -         if(c = =Mempool) toMempool = (c =NewSegx[len]) +Len; +*c =segx (); -         returnC++; the     } *     #undefLen $      Panax Notoginseng     #defineMid (L + R >> 1) -     voidBuildintLintr) { the         if(L = = r)return; +ls =New() segx, rs =New() segx; ALS-Build (l, mid), RS--build (Mid +1, R); the     } +       -     voidModifyintLintRintLintRintv) { $MX =Max (MX, v); $         if(l <= l && R <=R) { -Tag =Max (tag, v); -             return; the         } -         if(L <= mid) LS--Modify (L, Mid, L, R, v);Wuyi         if(Mid < R) RS-Modify (Mid +1, R, L, R, v); the     } -       Wu     intQueryintLintRintLintR) { -         if(l <= L && R <= R)returnMX; About         intres =tag; $         if(L <= mid) res = max (res, LS-query (L, Mid, L, R)); -         if(Mid < R) res = max (res, RS-and query (mid +1, R, L, R)); -         returnRes; -     } A     #undefMid + }; the   - structSegy { $Segy *ls, *rs; theSEGX *MX, *tag; the       the Segy () { thels = rs = NULL, mx = tag =NULL; -     } in       the     #defineLen (1 << 16) theInlinevoid*operator New(size_t) { About         StaticSegy *mempool, *C; the         if(c = =Mempool) theMempool = (c =NewSegy[len]) +Len; the*c =segy (); +         returnC++; -     } the     #undefLenBayi       the     #defineMid (L + R >> 1) the     voidBuildintLintr) { -MX =New() segx, tag =New() segx; -MX--Build (1, m), tag--Build (1, m); the         if(L = = r)return; thels =New() Segy, rs =New() Segy; theLS-Build (l, mid), RS--build (Mid +1, R); the     } -       the     voidModifyintLintRintLintRintXintYintv) { theMX-Modify (1, M, x, Y, v); the         if(l <= l && R <=R) {94Tag-Modify (1, M, x, Y, v); the             return; the         } the         if(L <= mid) LS--Modify (L, Mid, L, R, X, Y, v);98         if(Mid < R) RS-Modify (Mid +1, R, L, R, X, Y, v); About     } -      101     intQueryintLintRintLintRintXinty) {102         if(l <= L && R <= R)returnMX---Query (1, M, x, y);103         intRES = tag---Query (1, M, x, y);104         if(L <= mid) res = max (res, LS-query (L, Mid, L, R, X, y)); the         if(Mid < R) res = max (res, RS-and query (mid +1, R, L, R, X, y));106         returnRes;107     }108     #undefMid109} *T; the  111 intMain () { the     intx, y, dx, dy, h, Tot;113n = Read (), M = Read (), Tot =read (); theT =New() Segy; theT-Build (1, n); the      while(tot--) {117DX = read (), dy = Read (), h = Read (), x = Read (), y =read ();118T-Modify (1, N, x +1, x + dx, y +1, y + dy, T-and query (1, N, x +1, x + dx, y +1, y + dy) +h);119     } -printf"%d\n", T-A query (1N1N1, M));121     return 0;122 }123  124InlineintRead () { the     Static intx;126     Static Charch;127x =0, ch =GetChar (); -      while(Ch <'0'||'9'<ch)129CH =GetChar (); the      while('0'<= CH && Ch <='9') {131x = x *Ten+ CH-'0'; theCH =GetChar ();133     }134     returnx;135}
View Code

BZOJ1513 [Poi2006]tet-tetris 3D

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.