QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#832775#8701. BorderGGrun0 3ms53816kbC++171.7kb2024-12-26 07:27:272024-12-26 07:27:27

Judging History

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

  • [2024-12-26 07:27:27]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:53816kb
  • [2024-12-26 07:27:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mk make_pair
#define ps push_back
const int N=1e6+10,inf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f,mod=1145141113;
inline ll read(){
	char c=getchar();ll x=0;bool f=0;
	while(!isdigit(c))f=c=='-'?1:0,c=getchar();
	while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f?-x:x;
}
const ull B=233;
string s1,s2;
ull hx[N],ci[N];
int ans[N],n;
inline ull hs(int l,int r){return (hx[r]-hx[l-1]*ci[r-l+1]%mod+mod)%mod;}
inline int cmp(int len){
	int l=0,r=len,mid,ans=0;
	while(l<=r){
		mid=l+r>>1;
		if(hs(1,mid)==hs(n-mid+1,n))ans=mid,l=mid+1;
		else r=mid-1;
	}
	return ans+1;
}
vector<int> va[N],vb[N];
signed main(){

	#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
	#endif

	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>s1>>s2;
	n=s1.size();
	ci[0]=1;
	for(int i=1;i<=n;++i)
		hx[i]=(hx[i-1]*B+s1[i-1])%mod,ci[i]=ci[i-1]*B%mod;
	int tag=0;
	for(int i=1;i<n;++i){
		int pos=cmp(i);
		// cout<<i<<' '<<pos<<endl;
		if(pos>i){
			tag=i;
			if(i*2<n)va[i+1].ps(i),vb[n-i+1].ps(i);
		}
		else{
			char c=s1[pos-1];s1[pos-1]=s1[n-i+pos-1];
			int man=cmp(i);
			if(man>i){
				if(s2[pos-1]==s1[pos-1])ans[pos]=i;
				if(s2[n-i+pos-1]==c)ans[n-i+pos]=i;
			}
			s1[pos-1]=c;
		}
	}
	// return 0;
	multiset<int> s;
	for(int i=1;i<=n;++i){
		for(auto j:va[i]){
			// cout<<j<<"INS\n"<<endl;
			s.insert(j);
		}
		for(auto j:vb[i]){
			auto it=s.lower_bound(j);
			s.erase(it);
		}
		if(s.size())ans[i]=max(ans[i],*s.rbegin());
		if(s1[i-1]==s2[i-1])ans[i]=max(ans[i],tag);
		cout<<ans[i]<<'\n';
	}
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 53816kb

input:

cbaababaabacbaababaabacbaabacbaababaabacbaaba
dabbababbabaabbafabbgbaabfebaabzababbayaabcac

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

wrong answer 7th numbers differ - expected: '6', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%