摘要:
枚举ak的值 反向枚举使ak尽快到达最短链的n C++ / H E A D / int n,m,a[23333],dep; bool dfs(int x){ if(a[x 1] n||a[x 1]dep){ if(a[x 1]==n) return 1; else return 0; } // re 阅读全文
摘要:
有点小细节需要注意 sum实时维护有效的连续和 C++ / H E A D / ll dp1[maxn],dp2[maxn]; ll a[maxn],n,sum; int main(){ while(~iin(n)){ rep(i,1,n) a[i]=read(); dp1[0]= (1ll 阅读全文
摘要:
```C++
/*H E A D*/
int nxt[maxn];
char P[maxn];
void buildNext(){ nxt[1]=0; int j=0,m=strlen(P+1); rep(i,2,m){ while(j&&P[i]!=P[j+1])j=nxt[j]; if(P[i]==P[j+1])j++; nxt[i]=j; } }
int main(){... 阅读全文
摘要:
循环移位的套路操作就是一份折开变两份 C++ / H E A D / void match(){ int n=strlen(T+1); int m=strlen(P+1); int j=0; rep(i,1,n){ if(flag)break; while(j 0&&(j==m||T[i]!=P[j 阅读全文
摘要:
```C++
/*H E A D*/
int nxt[maxn],f[maxn],ans;
char T[maxn],P[maxn];
void init(){ int m=strlen(P+1); int j=0; nxt[1]=0; rep(i,2,m){ while(j>0&&P[i]!=P[j+1]) j=nxt[j]; if(P[i]==P[j+1])j++; nxt... 阅读全文
摘要:
```C++ / H E A D / int main(){ int T=read(); while(T ){ ll a=read(); ll b=read(); ll c=read(); ll d=read(); ll ans=0; ll x=0,y=0; rrep(i,61,0){ bool p 阅读全文
摘要:
```C++ / H E A D / struct Trie{ int son[maxn i)&1; rrep(i,32,0){ if(!son[now][b[i]]){ son[now][b[i]]=++tot; son[tot][0]=son[tot][1]=0; } now=son[now][ 阅读全文
摘要:
异或关于前缀的特性:[u,v]=[1,u]^[1,v] 注意是路径,假设1为根,prexor[1]不保留数值 C++ / H E A D / int to[maxn =1; } rrep(i,31,0){ if(!son[now][b[i]]) son[now][b[i]]=++tot; now=s 阅读全文