# UVA 12003 Block List

Source: Internet
Author: User

First, split the block. For the query, the block within the order of two points, for modification, direct violence, attention needs to maintain the original order, and constantly and within the block adjacent elements Exchange can be.

`1#include <algorithm>2#include <iostream>3#include <cstring>4#include <cstdio>5#include <cmath>6 using namespacestd;7 8 Const intN =300000;9 Const intM =650;Ten intA[n]; One intB[m][m]; A intN, M, U, PS, num; -  - voidModifyintPosintval) the { -     intcur = pos/PS; -     if(Cur < num-1 ) -     { +         intp = lower_bound (B[cur], b[cur] + PS, A[pos])-B[cur]; -          while(P +1< PS && B[cur][p +1] <val) +         { AB[CUR][P] = b[cur][p +1]; atp++; -         } -          while(P-1>=0&& B[cur][p-1] >val) -         { -B[CUR][P] = b[cur][p-1]; -p--; in         } -B[CUR][P] =Val; to     } +A[pos] =Val; - } the  * voidUpdateintLintRintVintp) \$ {Panax Notoginseng     intcur = l/ps, ncur = r/ps, k =0; -     if(cur! =ncur) the     { +          for(inti = cur +1; I <= ncur-1; i++ ) A         { theK + = Lower_bound (B[i], b[i] + PS, v)-B[i]; +         } -          for(inti = l; I < (cur +1) * PS; i++ ) \$         { \$             if(A[i] < v) k++; -         } -          for(inti = ncur * PS; I <= R; i++ ) the         { -             if(A[i] < v) k++;Wuyi         } the     } -     Else Wu     { -          for(inti = l; I <= R; i++ ) About         { \$             if(A[i] < v) k++; -         } -     } -Modify (P, U * 1ll * k/(R-l +1 ) ); A } +  the intMain () - { \$      while(SCANF ("%d%d%d", &n, &m, &u)! =EOF) the     { thePS = -; the          for(inti =0; I < n; i++ ) the         { -scanf"%d", &a[i]); inB[i/ps][i% ps] =A[i]; the         } thenum = (n + ps-1) /PS; About          for(inti =0; I < num-1; i++ ) the         { theSort (B[i], B[i] +PS); the         } +          while(m-- ) -         { the             intL, R, V, p;Bayiscanf"%d%d%d%d", &l, &r, &v, &p); theL--, R--, p--; the Update (L, R, V, p); -         } -          for(inti =0; I < n; i++ ) the         { theprintf"%d\n", A[i]); the         } the     } -     return 0; the}`

UVA 12003 Block List

Related Keywords:

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.