BZOJ3207: The flower God's mocking plan Ⅰ

Source: Internet
Author: User

Title: http://www.lydsy.com/JudgeOnline/problem.php?id=3207

The line tree can be persisted.

Hash each number and then hash the number of questions.

Then you can do subtraction when you ask.

#include <cstring>#include<iostream>#include<algorithm>#include<cstdio>#defineRep (i,l,r) for (int i=l;i<=r;i++)#defineDown (i,l,r) for (int i=l;i>=r;i--)#defineCLR (x, y) memset (x,y,sizeof (×))#defineMAXN 200500#defineSeed 419LL#defineMM 1000000007#definell unsigned long longusing namespacestd;structData{ll x;intId,l,r;} A[MAXN],Q[MAXN*3];intsum[maxn* +],ls[maxn* +],rs[maxn* +],root[maxn*3],num[maxn];ll C[MAXN];intSs,cnt,n,m,k,cnt2;intRead () {intx=0, f=1;CharCh=GetChar ();  while(!isdigit (CH)) {if(ch=='-') f=-1; Ch=GetChar ();}  while(IsDigit (CH)) {x=x*Ten+ch-'0'; Ch=GetChar ();} returnx*F;} llGet(intx) {ll ans=0; Rep (I,x,x+k-1) ans=ans*seed+C[i]; returnans;}BOOLCMP (data a,data b) {returna.x<b.x;}voidAddintLintRintXint&y,intval) {y=++Cnt2; Sum[y]=sum[x]+1; if(L==R)return; Ls[y]=LS[X]; rs[y]=Rs[x]; intMid= (L+R)/2; if(val<=mid) Add (l,mid,ls[x],ls[y],val); ElseAdd (mid+1, R,rs[x],rs[y],val);}intAskintLintRintTintval) {    if(L==R)returnSum[t]; intMid= (L+R)/2; if(Val<=mid)returnAsk (L,mid,ls[t],val); Else returnAsk (mid+1, R,rs[t],val);}intMain () {n=read (); M=read (); k=read (); Rep (I,1, N) scanf ("%lld",&C[i]); Rep (I,1, n-k+1) A[i].id=i,a[i].x=Get(i); CNT=n-k+1; Rep (I,1, M) {Q[I].L=read ()-1; Q[i].r=read ()-k+1; Rep (J,1, k) scanf ("%lld",&C[j]); CNT++; A[cnt].id=cnt; a[cnt].x=Get(1); } sort (A+1, A +1+cnt,cmp); SS=1; num[a[1].id]=1; Rep (I,2, CNT) {        if(a[i].x!=a[i-1].x) ss++; Num[a[i].id]=SS; } Rep (I,1, n-k+1) Add (1, ss,root[i-1],root[i],num[i]); Rep (I,1, M) {        if(Ask (1, ss,root[q[i].r],num[i+n-k+1])-ask (1, ss,root[q[i].l],num[i+n-k+1]) >0) puts ("No"); ElsePuts"Yes"); }    return 0;}

BZOJ3207: The flower God's mocking plan Ⅰ

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.