【简要题解】Hihocoder 重复旋律1-8简要题解

编号 名称标签 难度
1403 后缀数组一·重复旋律 Lv.4
1407 后缀数组二·重复旋律2 Lv.4
1415 后缀数组三·重复旋律3 Lv.4
1419 后缀数组四·重复旋律4 Lv.4
1445 后缀自动机二·重复旋律5 Lv.4
1449 后缀自动机三·重复旋律6 Lv.4
1457 后缀自动机四·重复旋律7 Lv.1
1465 后缀自动机五·重复旋律8 Lv.1
1466 后缀自动机六·重复旋律9 Lv.1

后缀数组

思路简单但是实现要想一想?之前我看的是什么lj教程,不如自己xjb强行写一下递归形式的然后改成循环就好了(我自己写的跑得贼慢,什么时候看看别人咋改进的)

关于height数组,它的性质是显然的就不讲了,不过height数组给人的启示是,带有前缀交性质的查询可以将元素按照字典序排序,这样连续一段的前缀交=\((l,R]\)的相邻前缀交了。同时也有\(h[i]\ge h[i-1]-1\)这个结论。

重复旋律1

题目大意是问你满足这个条件的子串的最长长度

条件:在母串出现次数至少为k次(可以重叠出现)

子串=后缀的前缀,现在只要定位height数组任意一个长度为k-1的子段,查询一下其中的最小值,我们是要求这些最小值的最大值。线段树就行了

//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mid ((l+r)>>1)
#define lef l,mid,pos<<1
#define rgt mid+1,r,pos<<1|1
#define DEBUG(s,a) cerr<<#s" = "<<(s)<<" \n"[(a)==1] using namespace std; typedef long long ll; char __buf[1<<18],*__c=__buf,*__ed=__buf;
inline int qr(){
int ret=0,f=0,c=getchar();
while(!isdigit(c))f|=c==45,c=getchar();
while(isdigit(c)) ret=ret*10+c-48,c=getchar();
return f?-ret:ret;
}
const int maxn=1e5+5;
char c[maxn];
int sa[maxn],h[maxn],rk[maxn],seg[maxn<<2],n; void sufsort(char*c,int*sa,int*rk,int*h,int n){
static int temp[maxn<<1],b[maxn];
c[0]='!';
for(int k=0,m=128;(1<<k>>1)<=n;++k){
if(!k) for(int t=1;t<=n;++t) temp[t]=t,rk[t]=c[t],temp[t+n]=0;
int l=1<<k>>1,p=0,q=l;
for(int t=1;t<=n;++t){
if(sa[t]>=n-l+1) temp[++p]=sa[t];
if(sa[t]>l) temp[++q]=sa[t]-l;
}
for(int t=1;t<=n;++t) ++b[rk[t]];
for(int t=1;t<=m;++t) b[t]+=b[t-1];
for(int t=n;t;--t) sa[b[rk[temp[t]]]--]=temp[t];
memset(b,0,(m+1)<<2); memcpy(temp+1,rk+1,n<<2); rk[sa[1]]=1;
for(int t=2;t<=n;++t)
rk[sa[t]]=temp[sa[t]]==temp[sa[t-1]]&&temp[sa[t]+l]==temp[sa[t-1]+l]?rk[sa[t-1]]:rk[sa[t-1]]+1;
m=rk[sa[n]];
}
for(int t=1,l=0;t<=n;++t){
if(l) --l;
if(rk[t]>1) while(c[t+l]==c[sa[rk[t]-1]+l]) ++l;
else l=0;
h[rk[t]]=l;
}
} void build(int l,int r,int pos){
if(l==r) return seg[pos]=h[l],void();
build(lef); build(rgt);
seg[pos]=min(seg[pos<<1],seg[pos<<1|1]);
} int que(int L,int R,int l,int r,int pos){
if(L>r||R<l) return 1e9;
if(L<=l&&r<=R) return seg[pos];
return min(que(L,R,lef),que(L,R,rgt));
} int que(int l,int r){
if(rk[l]>rk[r]) swap(l,r);
return que(rk[l]+1,rk[r],1,n,1);
} int main(){
scanf("%s",c+1); n=strlen(c+1);
sufsort(c,sa,rk,h,n);
build(1,n,1);
int ans=0;
for(int t=1;t<=n;++t)
for(int i=1;i<=n-t;i+=t){
int k=que(i,i+t);
ans=max(ans,k/t+1);
if(i>=t-k%t) ans=max(que(i-t+k%t,i+k%t)/t+1,ans);
}
printf("%d\n",ans);
return 0;
}

重复旋律2

题目大意是问你满足这个条件的子串的最长长度

条件:在母串出现次数至少为k次(不可以重叠出现)

现在问题其实就变成了:

\[\max l \text{ 使得}
\\
\exist i,j \text{ 满足 } i<j-l \and \text{lcp}(i,j)\ge l
\]

显然满足二分性,二分就行。

//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#define DEBUG(s,a) cerr<<#s" = "<<(s)<<" \n"[(a)==1]
#define mid ((l+r)>>1) using namespace std; typedef long long ll;
inline int qr(){
int ret=0,f=0,c=getchar();
while(!isdigit(c))f|=c==45,c=getchar();
while(isdigit(c)) ret=ret*10+c-48,c=getchar();
return f?-ret:ret;
}
const int maxn=1e5+5;
int rk[maxn],sa[maxn],c[maxn],height[maxn],n; inline void sufsort(int*str,int*sa,int*rk,int*height,int n){
static int temp[maxn<<1],buk[maxn];
str[0]=-1;
for(int k=0,m=1000;(1<<k>>1)<=n;++k){
if(!k) for(int t=1;t<=n;++t) temp[t]=t,temp[t+n]=0,rk[t]=str[t];
int l=1<<k>>1,p=0,q=l;
for(int t=1;t<=n;++t){
if(sa[t]>=n-l+1) temp[++p]=sa[t];
if(sa[t]>l) temp[++q]=sa[t]-l;
}
for(int t=1;t<=n;++t) ++buk[rk[t]];
for(int t=1;t<=m;++t) buk[t]+=buk[t-1];
for(int t=n;t;--t) sa[buk[rk[temp[t]]]--]=temp[t];
memset(buk,0,(m+1)<<2); memcpy(temp+1,rk+1,n<<2); rk[sa[1]]=1;
for(int t=1;t<=n;++t)
rk[sa[t]]=temp[sa[t]]==temp[sa[t-1]]&&temp[sa[t]+l]==temp[sa[t-1]+l]?rk[sa[t-1]]:rk[sa[t-1]]+1;
m=rk[sa[n]];
}
for(int t=1,l=0;t<=n;++t){
if(l) --l;
if(rk[t]>1) while(str[t+l]==str[sa[rk[t]-1]+l]) ++l;
else l=0;
height[rk[t]]=l;
}
} bool chek(int k){
for(int l=1,r=1;r<=n;l=++r){
if(height[l]<k) continue;
int Min=sa[l],Max=sa[l];
if(l>1) Min=min(sa[l-1],Min),Max=max(Max,sa[l-1]);
while(r<n&&height[r+1]>=k) ++r,Min=min(Min,sa[r]),Max=max(Max,sa[r]);
if(Max-Min+1>k) return 1;
}
return 0;
} int main(){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
n=qr();
for(int t=1;t<=n;++t) c[t]=qr();
sufsort(c,sa,rk,height,n);
int l=0,r=n;
do
if(chek(mid)) l=mid+1;
else r=mid-1;
while(l<=r);
printf("%d\n",r);
return 0;
}

重复旋律3

问两个串的最长公共子串。

按道理应该可以AC自动机做,但是我没想出来

把两个串顺序连接在一起,中间设放一个分隔符位置设为k,问题就变成了

\[\max l \text{ 使得}
\\
\exist i,j \text{ 满足 } i<k\and j>k \and \text{lcp}(i,j)\ge l
\]

显然满足二分性,直接二分就行

//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mid ((l+r)>>1)
#define DEBUG(s,a) cerr<<#s" = "<<(s)<<" \n"[(a)==1] using namespace std; typedef long long ll; char __buf[1<<18],*__c=__buf,*__ed=__buf;
inline int qr(){
int ret=0,f=0,c=getchar();
while(!isdigit(c))f|=c==45,c=getchar();
while(isdigit(c)) ret=ret*10+c-48,c=getchar();
return f?-ret:ret;
}
const int maxn=2e5+5;
int sa[maxn],rk[maxn],height[maxn],n,k;
char c[maxn]; void sufsort(char*str,int*sa,int*rk,int*height,int n){
static int temp[maxn<<1],buk[maxn];
str[0]='~';
for(int k=0,m=1000;(1<<k>>1)<=n;++k){
if(!k) for(int t=1;t<=n;++t) temp[t]=t,temp[t+n]=0,rk[t]=str[t];
int l=1<<k>>1,p=0,q=l;
for(int t=1;t<=n;++t){
if(sa[t]>=n-l+1) temp[++p]=sa[t];
if(sa[t]>l) temp[++q]=sa[t]-l;
}
for(int t=1;t<=n;++t) ++buk[rk[t]];
for(int t=1;t<=m;++t) buk[t]+=buk[t-1];
for(int t=n;t;--t) sa[buk[rk[temp[t]]]--]=temp[t];
memset(buk,0,(m+1)<<2); memcpy(temp+1,rk+1,n<<2); rk[sa[1]]=1;
for(int t=2;t<=n;++t)
rk[sa[t]]=temp[sa[t]]==temp[sa[t-1]]&&temp[sa[t]+l]==temp[sa[t-1]+l]?rk[sa[t-1]]:rk[sa[t-1]]+1;
m=rk[sa[n]];
}
for(int t=1,l=0;t<=n;++t){
if(l) --l;
if(rk[t]>1) while(str[t+l]==str[sa[rk[t]-1]+l]) ++l;
else l=0;
height[rk[t]]=l;
}
} bool chek(int L){
for(int l=1,r=1;r<=n;l=++r){
if(height[l]<L) continue;
int Min=sa[l],Max=sa[l];
if(l>1) Min=min(sa[l-1],Min),Max=max(Max,sa[l-1]);
while(r<n&&height[r+1]>=L) ++r,Min=min(Min,sa[r]),Max=max(Max,sa[r]);
if(Min<k&&Max>k) return 1;
}
return 0;
} int main(){
scanf("%s",c+1);
n=strlen(c+1); c[k=++n]='_';
scanf("%s",c+n);
n=strlen(c+1);
sufsort(c,sa,rk,height,n);
int l=0,r=n;
do
if(chek(mid)) l=mid+1;
else r=mid-1;
while(l<=r);
printf("%d\n",r);
return 0;
}

重复旋律4

题意是问你,母串的某个子段可以被表示成k个相同的串重复k次,给你母串问你最大可能的k

用别的方法描述一下这个问题,就变成了要你在母串中找到一个位置的数列\(P=\{p_i\}\)满足\(P\)是一个等差数列且要求任意两个\(p\)的\(\text{lcp} \ge d\) ,答案是最大的\(|P|\)。

检查一个串是否是由某个串重复很多次得到,只要需要枚举长度i然后比对原串和suf[i]是否相同即可。匹配出来得到的长度\(l\)显然是小于重复长度+i的。这是因为将串平移后和自己匹配的诸多性质。

但是现在还需要枚举一个偏移量,实际上我们不需要枚举这个偏移量,直接枚举每个长度然后枚举这个长度的倍数。我们可以发现,假设最优答案的起始位置的偏移=k,那么我们一定在某次查询时,少算了一个循环。此时可以发现,少算的那个被我们枚举的分界点分开了,具体分界点在哪里,假设查询出来长度为j,分界点就在负偏移j%i处。每次算一下就行,这样就一定会统计到最优答案。

因为每次统计答案的时候,统计出来的值都是真的(就是合法的,不会比答案大),所以每次弄就行。

序列上的等差子序列问题一般和一个复杂度是调和级数\((O(1))\)的经典做法有关...

//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mid ((l+r)>>1)
#define lef l,mid,pos<<1
#define rgt mid+1,r,pos<<1|1
#define DEBUG(s,a) cerr<<#s" = "<<(s)<<" \n"[(a)==1] using namespace std; typedef long long ll; char __buf[1<<18],*__c=__buf,*__ed=__buf;
inline int qr(){
int ret=0,f=0,c=getchar();
while(!isdigit(c))f|=c==45,c=getchar();
while(isdigit(c)) ret=ret*10+c-48,c=getchar();
return f?-ret:ret;
}
const int maxn=1e5+5;
char c[maxn];
int sa[maxn],h[maxn],rk[maxn],seg[maxn<<2],n; void sufsort(char*c,int*sa,int*rk,int*h,int n){
static int temp[maxn<<1],b[maxn];
c[0]='!';
for(int k=0,m=128;(1<<k>>1)<=n;++k){
if(!k) for(int t=1;t<=n;++t) temp[t]=t,rk[t]=c[t],temp[t+n]=0;
int l=1<<k>>1,p=0,q=l;
for(int t=1;t<=n;++t){
if(sa[t]>=n-l+1) temp[++p]=sa[t];
if(sa[t]>l) temp[++q]=sa[t]-l;
}
for(int t=1;t<=n;++t) ++b[rk[t]];
for(int t=1;t<=m;++t) b[t]+=b[t-1];
for(int t=n;t;--t) sa[b[rk[temp[t]]]--]=temp[t];
memset(b,0,(m+1)<<2); memcpy(temp+1,rk+1,n<<2); rk[sa[1]]=1;
for(int t=2;t<=n;++t)
rk[sa[t]]=temp[sa[t]]==temp[sa[t-1]]&&temp[sa[t]+l]==temp[sa[t-1]+l]?rk[sa[t-1]]:rk[sa[t-1]]+1;
m=rk[sa[n]];
}
for(int t=1,l=0;t<=n;++t){
if(l) --l;
if(rk[t]>1) while(c[t+l]==c[sa[rk[t]-1]+l]) ++l;
else l=0;
h[rk[t]]=l;
}
} void build(int l,int r,int pos){
if(l==r) return seg[pos]=h[l],void();
build(lef); build(rgt);
seg[pos]=min(seg[pos<<1],seg[pos<<1|1]);
} int que(int L,int R,int l,int r,int pos){
if(L>r||R<l) return 1e9;
if(L<=l&&r<=R) return seg[pos];
return min(que(L,R,lef),que(L,R,rgt));
} int que(int l,int r){
if(rk[l]>rk[r]) swap(l,r);
return que(rk[l]+1,rk[r],1,n,1);
} int main(){
scanf("%s",c+1); n=strlen(c+1);
sufsort(c,sa,rk,h,n);
build(1,n,1);
int ans=0;
for(int t=1;t<=n;++t)
for(int i=1;i<=n-t;i+=t){
int k=que(i,i+t);
ans=max(ans,k/t+1);
if(i>=t-k%t) ans=max(que(i-t+k%t,i+k%t)/t+1,ans);
}
printf("%d\n",ans);
return 0;
}

重复旋律5

答案=\(\sum len-len[fa]\)

//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector> using namespace std; typedef long long ll;
inline int qr(){
int ret=0,f=0,c=getchar();
while(!isdigit(c))f|=c==45,c=getchar();
while(isdigit(c)) ret=ret*10+c-48,c=getchar();
return f?-ret:ret;
}
const int maxn=1000000+5;
int fa[maxn<<1],len[maxn<<1],trans[maxn<<1][26],siz[maxn<<1],last=1,cnt=1;
vector<int> e[maxn<<1];
char buf[maxn]; void insert(int c){
int u=++cnt,v=last;
len[u]=len[v]+1;
while(v&&!trans[v][c]) trans[v][c]=u,v=fa[v];
if(!v) fa[u]=1;
else {
int x=trans[v][c];
if(len[x]==len[v]+1) fa[u]=x;
else {
int y=++cnt;
for(int t=0;t<26;++t) trans[y][t]=trans[x][t];
fa[y]=fa[x]; fa[x]=fa[u]=y; len[y]=len[v]+1;
while(v&&trans[v][c]==x) trans[v][c]=y,v=fa[v];
}
}
siz[u]=1; last=u;
} ll ans;
int main(){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
//freopen("out.out","w",stdout);
#endif
scanf("%s",buf);
for(int t=0,ed=strlen(buf);t<ed;++t) insert(buf[t]-'a');
for(int t=1;t<=cnt;++t) ans+=len[t]-len[fa[t]];
printf("%lld\n",ans);
return 0;
}

重复旋律6

每个状态对于\([len[fa]+1,len[i]]\)都有\(|endpos|\)的贡献(取max),弄个线段树就行了

//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> #define mid ((l+r)>>1)
#define lef l,mid,pos<<1
#define rgt mid+1,r,pos<<1|1
#define getchar() (__c==__ed?(__ed=__buf+fread(__c=__buf,1,1<<19,stdin),*__c++):*__c++)
using namespace std; typedef long long ll; char __buf[1<<19],*__c=__buf,*__ed=__buf; const int maxn=2e6+6;
int fa[maxn],len[maxn],siz[maxn],trans[maxn][26],cnt=1,last=1;
int head[maxn],seg[maxn<<1],tag[maxn<<1],n;
struct E{int to,nx;}e[maxn<<1]; void add(int fr,int to){
static int cnt=0;
e[++cnt]={to,head[fr]}; head[fr]=cnt;
e[++cnt]={fr,head[to]}; head[to]=cnt;
} void insert(int c){
int u=++cnt,v=last;
len[u]=len[v]+1;
while(v&&!trans[v][c]) trans[v][c]=u,v=fa[v];
if(!v) fa[u]=1;
else {
int x=trans[v][c];
if(len[x]==len[v]+1) fa[u]=x;
else {
int y=++cnt;
for(int t=0;t<26;++t) trans[y][t]=trans[x][t];
fa[y]=fa[x]; fa[x]=fa[u]=y; len[y]=len[v]+1;
while(v&&trans[v][c]==x) trans[v][c]=y,v=fa[v];
}
}
siz[u]=1; last=u;
} void pd(int pos){
if(tag[pos]){
seg[pos<<1]=max(seg[pos<<1],tag[pos]);
seg[pos<<1|1]=max(seg[pos<<1|1],tag[pos]);
tag[pos<<1]=max(tag[pos<<1],tag[pos]);
tag[pos<<1|1]=max(tag[pos<<1|1],tag[pos]);
tag[pos]=0;
}
} void pp(int pos){seg[pos]=max(seg[pos<<1],seg[pos<<1|1]);} void ans(int l,int r,int pos){
if(l==r) return printf("%d\n",seg[pos]),void();
pd(pos); ans(lef); ans(rgt);
} void upd(int v,int L,int R,int l,int r,int pos){
if(L>r||R<l) return;
if(L<=l&&r<=R) return seg[pos]=max(seg[pos],v),tag[pos]=max(tag[pos],v),void();
pd(pos); upd(v,L,R,lef); upd(v,L,R,rgt);
} void dfs(int now,int last){
for(int t=head[now];t;t=e[t].nx)
if(e[t].to!=last)
dfs(e[t].to,now),siz[now]+=siz[e[t].to];
upd(siz[now],len[last]+1,len[now],1,n,1);
} int main(){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
for(char c=getchar();isalpha(c);c=getchar()) ++n,insert(c-'a');
for(int t=1;t<=cnt;++t) add(t,fa[t]);
dfs(1,0); ans(1,n,1);
return 0;
}

重复旋律7

考虑串之间插入分隔符,随后将分隔符对于的辅助点直接从DAG上删掉,然后把从1不可达的点删掉,在这个图上跑一个DP即可。

//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<assert.h>
#include<algorithm>
#include<vector>
#include<queue> using namespace std; typedef long long ll;
inline int qr(){
int ret=0,f=0,c=getchar();
while(!isdigit(c))f|=c==45,c=getchar();
while(isdigit(c)) ret=ret*10+c-48,c=getchar();
return f?-ret:ret;
}
const int maxn=1.5e6+5;//shall be 4e6 ?
const int mod=1e9+7;
int fa[maxn],trans[11][maxn],len[maxn],n,cnt=1,last=1,head[maxn],dr[maxn];
int dp[maxn],f[maxn];
bool is[maxn]; inline int MOD(const int&x){return x>=mod?x-mod:x;}
inline int MOD(const int&x,const int&y){return 1ll*x*y%mod;} struct E{int to,nx,w;}e[maxn*11];
void add(int fr,int to,int w){static int cnt=0;e[++cnt]={to,head[fr],w};head[fr]=cnt;++dr[to];
//cerr<<fr<<' '<<to<<' '<<w<<endl;
} void insert(int c){
int u=++cnt,v=last;
len[u]=len[v]+1;
while(v&&!trans[c][v]) trans[c][v]=u,v=fa[v];
if(!v) fa[u]=1;
else {
int x=trans[c][v];
if(len[x]==len[v]+1) fa[u]=x;
else {
int y=++cnt;
for(int t=0;t<=10;++t) trans[t][y]=trans[t][x];
fa[y]=fa[x]; fa[x]=fa[u]=y; len[y]=len[v]+1;
while(v&&trans[c][v]==x) trans[c][v]=y,v=fa[v];
}
}
last=u;
} queue<int> q;
void topo(){
q.push(1);
f[1]=1;
while(q.size()){
int now=q.front();
q.pop();
for(int t=head[now];t;t=e[t].nx){
if(e[t].w<10) f[e[t].to]=MOD(f[e[t].to]+f[now]),dp[e[t].to]=MOD(MOD(MOD(dp[now],10)+MOD(e[t].w,f[now]))+dp[e[t].to]);
if(--dr[e[t].to]==0) q.push(e[t].to);
}
}
} int main(){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
//freopen("out.out","w",stdout);
#endif
n=qr();
for(int t=1,c;t<=n;++t){
c=getchar();
while(!isdigit(c)) c=getchar();
while( isdigit(c)) insert(c-48),c=getchar();
insert(10);
}
for(int i=0;i<=10;++i)
for(int t=1;t<=cnt;++t)
if(trans[i][t]) add(t,trans[i][t],i);
topo();
int ans=0;
for(int t=1;t<=cnt;++t) ans=MOD(ans+dp[t]);
printf("%d\n",ans);
return 0;
}

重复旋律8,9

懒得更了...

【简要题解】Hihocoder 重复旋律1-9简要题解的更多相关文章

  1. HihoCoder 重复旋律

    あの旋律を何度も繰り返しでも.あの日見た光景を再現できない 无论将那段旋律重复多少次,也无法重现那一日我们看到的景象 もし切ないならば.時をまきもどしてみるかい? 若是感到惆怅的话,要试着让时光倒流吗 ...

  2. 后缀数组之hihocoder 重复旋律1-4

    蒟蒻知道今天才会打后缀数组,而且还是nlogn^2的...但基本上还是跑得过的: 重复旋律1: 二分答案,把height划分集合,height<mid就重新划分,这样保证了每个集合中的LCP&g ...

  3. hihocoder #1419 : 后缀数组四·重复旋律4

    #1419 : 后缀数组四·重复旋律4 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为长度为 N 的数构 ...

  4. 【hihoCoder 1419】重复旋律4

    Description 小 Hi 平时的一大兴趣爱好就是演奏钢琴. 我们知道一个音乐旋律被表示为长度为 N的数构成的数列. 小 Hi 在练习过很多曲子以后发现很多作品中的旋律有重复的部分. 我们把一段 ...

  5. hihoCoder 1403 后缀数组一·重复旋律(后缀数组+单调队列)

    #1403 : 后缀数组一·重复旋律 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为长度为 N 的数构成 ...

  6. 【题解】Comet OJ Round 70 简要题解

    [题解]Comet OJ Round 70 简要题解 A 将放在地上的书按照从小到大排序后,问题的本质就变成了合并两个序列使得字典序最小.可以直接模拟归并排序.直接用循环和std::merge实现这个 ...

  7. hihoCoder 后缀自动机三·重复旋律6

    后缀自动机三·重复旋律6 时间限制:15000ms 单点时限:3000ms 内存限制:512MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为一段数构成的数列. 现在小Hi ...

  8. hihoCoder #1445 : 后缀自动机二·重复旋律5

    #1445 : 后缀自动机二·重复旋律5 时间限制:10000ms 单点时限:2000ms 内存限制:256MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为一段数构成的数 ...

  9. hihoCoder 后缀数组 重复旋律

    #1403 : 后缀数组一·重复旋律 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为长度为 N 的数构成 ...

随机推荐

  1. pytorch旧版安装

    https://pytorch.org/get-started/previous-versions 可以直接下载文件 用 pip 直接在下载目录安装就可以了

  2. @bzoj - 2388@ 旅行规划

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 请你维护一个序列,支持两种操作: (1)某个区间 [x, y] ...

  3. oracle函数 log(x,y)

    [功能]返回以x为底的y的对数 [参数]x,y,数字型表达式, [条件]x,y都必须大于0 [返回]数字 [示例] select power(4,2),log(16,2),1/log(16,4) fr ...

  4. autocomplete="off" inpu属性

    input 的属性autocomplete 默认为on 其含义代表是否让浏览器自动记录之前输入的值 很多时候,需要对客户的资料进行保密,防止浏览器软件或者恶意插件获取到 可以在input中加入auto ...

  5. WPF Converter(转)

    WPF Binding 用于数据有效性校验的关卡是它的 ValidationRules 属性,用于数据类型转换的关卡是它的 Converter 属性.下面是实例: 1. Binding 的数据校验 & ...

  6. H3C 配置PAP验证

  7. vector容器、

    一.  vector  向量容器1. 创建   vector  对象(1)不指定容器大小vector<int> V;(2)指定容器大小vector<int> V(10);(3) ...

  8. HDU 1072

    题意:给你一个迷宫,2代表你当前的位置,0代表墙,1代表可走的路,3代表出口,4代表的是炸弹的重置点,一开始炸弹的倒计时设置为6,每走一步时间减少1,倒计时到0的时候走到3或者4都不可以,问走出迷宫的 ...

  9. CodeForces 620E"New Year Tree"(DFS序+线段树+状态压缩)

    传送门 •题意 给你一颗 n 个节点的树,每个节点被染上了颜色: 有 m 次操作,每次操作的类型有两种 1 v c : 将以 v 为根的子树的结点全部涂成 c 2 v : 询问以 v 为根的子树的结点 ...

  10. laravel 常用文档

    [ Laravel 5.6 文档 ] 快速入门 —— 目录结构  laravel学院 http://laravelacademy.org/post/8657.html Laravel 的缓存系统    ...