QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#831845#8701. Borderwwjjrr_yohu23 8ms56700kbC++141.8kb2024-12-25 17:20:142024-12-25 17:20:16

Judging History

你现在查看的是最新测评结果

  • [2024-12-25 17:20:16]
  • 评测
  • 测评结果:23
  • 用时:8ms
  • 内存:56700kb
  • [2024-12-25 17:20:14]
  • 提交

answer

//mod!
//N=inf!
//long long!
#include<bits/stdc++.h>

using namespace std;

const int N=2e6+5;
const long long mod1=1e9+7,mod2=1e9+9;

long long n,mi1[N],mi2[N],has1[N],has2[N],ans[N];
long long num[N];
vector<int> f[N]; 
string s,t;

pair<int,int> ask(int l,int r){
	if(l>r) return {0,0};
	int len=r-l+1;
	return{(has1[r]-has1[l-1]*mi1[len]%mod1+mod1)%mod1,(has2[r]-has2[l-1]*mi2[len]%mod2+mod2)%mod2};
}

pair<int,int> ask1(int l,int r,int p){
	if(l>r) return {0,0};
	int len=r-l+1;
	if(l>p||r<p){
		return{(has1[r]-has1[l-1]*mi1[len]%mod1+mod1)%mod1,(has2[r]-has2[l-1]*mi2[len]%mod2+mod2)%mod2};
	}
	else{
		return{(has1[r]-has1[l-1]*mi1[len]%mod1+(t[p]-s[p])*mi1[r-p]%mod1+2*mod1)%mod1,(has2[r]-has2[l-1]*mi2[len]%mod2+(t[p]-s[p])*mi2[r-p]%mod2+mod2)%mod2};
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>s>>t;
	n=s.size();
	s=" "+s; 
	t=" "+t;
	mi1[0]=mi2[0]=1;
	for(int i=1;i<=n;i++) mi1[i]=mi1[i-1]*131%mod1,mi2[i]=mi2[i-1]*131%mod2;
	for(int i=1;i<=n;i++) has1[i]=has1[i-1]*131+s[i],has2[i]=has2[i-1]*131+s[i],has1[i]%=mod1,has2[i]%=mod2;
	for(int i=1;i<=n;i++) num[i]=max(num[i-1],0ll+i*(ask(1,i)==ask(n-i+1,n)));
//	for(int i=1;i<=n;i++) cout<<num[i]<<" ";
//	cout<<"\n";
	for(int i=2;i<=n;i++){
		if(ask(1,n-i+1)==ask(i,n)) continue;
		int lp=0,rp=n-i+1,res,mid;
		while(lp<=rp){
			mid=lp+rp>>1;
			if(ask(1,mid)==ask(i,i+mid-1)) lp=mid+1,res=mid;
			else rp=mid-1; 
		}
//		cout<<i<<" "<<res<<"\n";
		int p=res+1,q=i+res;
		if(ask1(1,n-i+1,p)==ask1(i,n,p)) ans[p]=max(ans[p],n-i+1);
		if(ask1(1,n-i+1,q)==ask1(i,n,q)) ans[q]=max(ans[q],n-i+1);
	}
	for(int i=1;i<=n;i++){
		if(t[i]==s[i]) ans[i]=num[n]; 
		else ans[i]=max(ans[i],num[min(i-1ll,n-i)]);//和t无相交 
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<"\n";
}


詳細信息

Subtask #1:

score: 23
Accepted

Test #1:

score: 23
Accepted
time: 8ms
memory: 55484kb

input:

cbaababaabacbaababaabacbaabacbaababaabacbaaba
dabbababbabaabbafabbgbaabfebaabzababbayaabcac

output:

0
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
17
17
17
17
17
17
17
17
17
17
17
6
6
6
6
6
6
6
6
6
6
6
0
0
0
3
0
1

result:

ok 45 numbers

Test #2:

score: 23
Accepted
time: 8ms
memory: 54920kb

input:

cbaababaabacbaabadbaababaabacbaabacbaaba
aabwaxjbbabtalbabcasbabibbabaabbabaabiac

output:

3
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
23
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
0
0
0
0
0
1

result:

ok 40 numbers

Test #3:

score: 23
Accepted
time: 4ms
memory: 56700kb

input:

cadaabacabacabacabaabacabacadaabacabacaba
bbbbbabtbabababalalbawababababbaoababebdc

output:

2
0
4
0
0
0
0
0
0
0
0
0
0
0
0
15
15
15
15
15
15
15
15
15
15
15
0
0
0
0
0
0
0
0
0
0
0
0
0
4
1

result:

ok 41 numbers

Test #4:

score: 23
Accepted
time: 4ms
memory: 55628kb

input:

dabacbaadcbaadabacbaadabecbaadcbaadabacbaadabacbaa
ababaabbyaarbabfbvdbuaoaaaabbaaabbababaabbababqadd

output:

2
0
0
0
0
0
0
0
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
29
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
0
0
0
0
0
0
2
1

result:

ok 50 numbers

Test #5:

score: 23
Accepted
time: 3ms
memory: 56224kb

input:

edacbcacacbcaecbcacacbcadacbcacacbca
sabaaabtbaaabaaalblbawaeabaaababoaae

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
13
0
0
0
0
0
0
0
0
0
0
0
1

result:

ok 36 numbers

Test #6:

score: 23
Accepted
time: 8ms
memory: 54668kb

input:

cbaababaabacbaabacbaabdbaabacbaabacbaaba
aabbababbaoaabbxbaabbaqabbabltbpagaabcac

output:

3
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
0
0
0
3
0
1

result:

ok 40 numbers

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #7:

score: 0
Wrong Answer
time: 8ms
memory: 54952kb

input:

abacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacababacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacaecabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacababacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacad...

output:

27
0
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75
75...

result:

wrong answer 3139th numbers differ - expected: '717', found: '4623'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%