bzoj2754 [SCOI2012] The name on the Meow planet

Source: Internet
Author: User

Topic links

AC Automatic Machine

Because the input is the disgusting number, with the map forcibly with the log ...

Due to the unclear length, the vector was used to force the time to increase ...

Due to the weight, the array is used to save the Force plus constant ...

Slow down.

1#include <algorithm>2#include <iostream>3#include <cstdlib>4#include <cstring>5#include <cstdio>6#include <string>7#include <cmath>8#include <ctime>9#include <queue>Ten#include <stack> One#include <map> A#include <Set> - #defineRre (i,r,l) for (int i= (r); i>= (l); i--) - #defineRe (I,L,R) for (int i= (l); i<= (R); i++) the #defineClear (A, B) memset (A,b,sizeof (a)) - #defineInOut (x) printf ("%d", (x)) - #defineDouin (x) scanf ("%lf", &x) - #defineStrin (x) scanf ("%s", (x)) + #defineLLin (x) scanf ("%lld", &x) - #defineOP operator + #defineCSC Main Atypedef unsignedLong LongULL; attypedefConst intCInt; -typedefLong LongLL; - using namespacestd; - voidInin (int&ret) - { -ret=0;intf=0;CharC=GetChar (); in      while(c<'0'|| C>'9'){if(c=='-') f=1; c=GetChar ();} -      while(c>='0'&&c<='9') (ret*=Ten) +=c-'0', c=GetChar (); toret=f?-Ret:ret; + } - intN,m,ed=1, pre[100010]; thevector<int>name[20020],sum[100050]; *map<int,int>ch[100010]; $map<int,int>:: iterator it;Panax Notoginseng voidAddintID) - { the     intx;inin (x); +     inttemp=1; ARe (I,1, X) the     { +         intC;inin (c); -         if(!ch[temp].count (c)) ch[temp][c]=++ed,temp=Ed; $         Elsetemp=Ch[temp][c]; $     } - sum[temp].push_back (ID); - } thequeue<int>h; - intv[100010],topv,m[100020],topm;Wuyi intans1[100010],ans2[100010]; the BOOLvv[100010],mm[100020]; - voidGetfail () Wu { - //For (It=ch[0].begin (); It!=ch[0].end (); it++) About //H.push (it->second); $H.push (1); -      while(!h.empty ()) -     { -         intx=H.front (); H.pop (); A          for(It=ch[x].begin (); It!=ch[x].end (); it++) +         { the             intI=it->first,v=it->second; -             intk=Pre[x]; $              while(!ch[k].count (i)) k=Pre[k]; thepre[v]=Ch[k][i]; the H.push (v); the         } the     } - } in voidGET (intIdintx) the { the      for(intI=x;i;i=pre[i])if(!Vv[i]) About     { thevv[i]=1; v[++topv]=i; theRe (J,0,(int) Sum[i].size ()-1)if(!Mm[sum[i][j]]) the         { +mm[sum[i][j]]=1, m[++topm]=Sum[i][j]; -ans1[sum[i][j]]++; theans2[id]++;Bayi}Else ; the}Else  Break; the } - voidFindintx) - { the     inttemp=1; theRe (I,0,(int) Name[x].size ()-1) the     { the         intC=Name[x][i]; -          while(!ch[temp].count (c)) temp=Pre[temp]; thetemp=Ch[temp][c]; the GET (x,temp); the     }94Re (I,1, TOPV) vv[v[i]]=0; theRe (I,1, TOPM) mm[m[i]]=0; thetopv=topm=0; the }98 intMain () About { -Re (i,-1,10000) ch[0][i]=1;101 inin (n), Inin (m);102Re (I,1, N)103     {104         intx, y; the inin (x);106Re (J,1, X) inin (y), name[i].push_back (y);107Name[i].push_back (-1);108 inin (x);109Re (J,1, X) inin (y), name[i].push_back (y); the     }111Re (I,1, M) the Add (i);113 Getfail (); theRe (I,1, N) the find (i); theRe (I,1, m) printf ("%d\n", Ans1[i]);117printf"%d", ans2[1]);118Re (I,2, N) printf ("%d", Ans2[i]);119      return 0; -}

bzoj2754 [SCOI2012] The name on the Meow planet

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.