[bzoj1227] [SDOI2009] The pious master of the tomb

Source: Internet
Author: User

Finally filled in this million-years giant pit .... I have heard of this problem since second day ... And never dared to write Qaq.

It's not very annoying now (but I'm still writing trouble.)

Discretization of a wave, pre-processing the number of combinations of what?

To maintain the number of legitimate scenarios for the current row, above and below the nodes of each column.

Then for the current line on the two adjacent evergreen tree, the left and right of the legal scheme number, multiply the middle empty column of the total number of legitimate schemes.

Single-point modification, interval query. I actually ran to write a line-segment tree ... Too lazy to change.

1#include <cstdio>2#include <iostream>3#include <cstring>4#include <algorithm>5 #defineUI unsigned int6 using namespacestd;7 Const intmaxn=100233,mxnode=maxn<<1;8 structzs{intV,id;} X[MAXN],Y[MAXN];9 structpoi{intx, y;} A[MAXN];Ten intLc[mxnode],rc[mxnode],num1[mxnode],num2[mxnode],tot; One intMp[maxn],st[maxn],top; AUI sm[mxnode],ans,sm,c[maxn][ One]; - inti,j,k,n,m,kk,l,r,p; -    the    - intRA,FH;CharRx; -InlineintRead () { -Rx=getchar (), ra=0, fh=1; +      while((rx<'0'|| Rx>'9') &&rx!='-') rx=GetChar (); -     if(rx=='-') fh=-1, rx=GetChar (); +      while(rx>='0'&&rx<='9') ra*=Ten, ra+=rx- -, Rx=getchar ();returnTalfh; A } at voidBuildintAintb) { -     intx=++tot; -     if(a==b) {Num2[x]=mp[a];return;} -     intMid=a+b>>1; -lc[x]=tot+1, build (A,mid), rc[x]=tot+1, Build (mid+1, b); - } in voidChangeintXintAintb) { -     if(a==b) { toNUM1[X]++,NUM2[X]--, sm[x]=c[num1[x]][kk]*C[NUM2[X]][KK]; +         return; -     } the     intMid=a+b>>1; *     if(p<=mid) Change (LC[X],A,MID);ElseChange (rc[x],mid+1, b); $sm[x]=sm[lc[x]]+Sm[rc[x]];Panax Notoginseng } - voidQueryintXintAintb) { the     if(l<=a&&r>=b) { +SM+=SM[X];return; A     } the     intMid=a+b>>1; +     if(l<=mid) query (LC[X],A,MID); -     if(r>mid) query (rc[x],mid+1, b); $ } $   -   - BOOLCMP (ZS A,zs b) {returna.v<B.V;} the BOOLCMPA (poi A,poi b) {returna.x<b.x| | (a.x==b.x&&a.y<b.y);} - intMain () {WuyiN=read (), m=read (); then=read (); -      for(i=1; i<=n;i++) X[i].v=read (), Y[i].v=read (), x[i].id=y[i].id=i; Wukk=read (); -      for(i=0; i<=n;i++) c[i][0]=1; About      for(i=1; i<=n;i++) for(j=1; j<=kk;j++) c[i][j]=c[i-1][j]+c[i-1][j-1]; $ //for (i=1;i<=n;i++) printf ("C (%d%d)%u\n", I,kk,c[i][kk]); return 233; -       -Sort (x+1, x+1+N,CMP), sort (y+1, y+1+N,CMP);intcntx=0, cnty=0; -      for(i=1; i<=n;a[x[i].id].x=cntx,i++) A         if(x[i].v!=x[i-1].v| | i==1) cntx++; +      for(i=1; i<=n;a[y[i].id].y=cnty,mp[cnty]++,i++) the         if(y[i].v!=y[i-1].v| | i==1) cnty++; -Sort (A +1, A +1+N,cmpa); $Build1, cnty); the       the      for(i=1; i<=N;) { the         intr=i-1, top=0; the          while(r<n&&a[r+1].x==a[i].x) R++,st[++top]=p=a[r].y,change (1,1, Cnty);//, printf ("%d", P);p UTS (""); -         if(Top>= (kk<<1)) in          for(j=kk;j<=top-kk;j++)if(st[j]+1<st[j+1]) thesm=0, l=st[j]+1, r=st[j+1]-1, Query (1,1, Cnty), theans+=sm*c[j][kk]*c[top-J] [KK]; Abouti=r+1; the     } theprintf"%d\n",ans<<1>>1); the}
View Code

[bzoj1227] [SDOI2009] The pious master of the tomb

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.