QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245904#4669. Genetic ModificationsQZJ123456RE 0ms0kbC++141.9kb2023-11-10 14:33:362023-11-10 14:33:37

Judging History

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

  • [2023-11-10 14:33:37]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-11-10 14:33:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bitset<50005>bsa[50005],cura,bs1a,bs2a;
bitset<100005>bsb[50005],curb,bs1b,bs2b;
char s[100005],t[100005];bool ck[100005];
int lst[2],n,m;
const int T=50000;
vector<int>out;
int main(){
	freopen("sequence.in","r",stdin);
	freopen("sequence.out","w",stdout);
	scanf("%s",s+1);scanf("%s",t+1);
	n=strlen(s+1),m=strlen(t+1);
	bs1a.reset(),bs2a.reset(),bsa[0].reset();
	bs1b.reset(),bs2b.reset(),bsb[0].reset();
	for(int i=1;i<=min(m,T);i++)if(t[i]=='0')bs2a[i]=1;else bs1a[i]=1;
	for(int i=1;i<=m;i++)if(t[i]=='0')bs2b[i]=1;else bs1b[i]=1;
	bsa[0][0]=1;
	int lls=-1;
	for(int i=1;i<=n;i++){
		int p=lst[(s[i-1]-'0')^1];
		if(p!=lls){
			if(p<=50000&&i>50001){
				cura.reset();
				curb.reset();
				for(int j=p;j<i;j++){
					if(j<=T)cura|=bsa[j];
					else{
						if(j==T)for(int l=0;l<=T;l++)curb[l]=cura[l];
						curb|=bsb[j-T];
					}
				}
			}
			if(i<=50001){
				cura.reset();
				for(int j=p;j<i;j++)cura|=bsa[j];
			}
			if(p>50000){
				curb.reset();
				for(int j=p;j<i;j++)curb|=bsb[j-T];
			}
			lls=p;
		}
		if(i<=T){
			if(s[i]=='0')bsa[i]=bs2a;
			else bsa[i]=bs1a;
			bsa[i]&=(cura<<1);
			lst[s[i]-'0']=i;
			cura|=bsa[i];
		}
		else{
			if(i==T+1)for(int j=0;j<=T;j++)curb[j]=cura[j];
			if(s[i]=='0')bsb[i-T]=bs2b;
			else bsb[i-T]=bs1b;
			bsb[i-T]&=(curb<<1);
			lst[s[i]-'0']=i;
			curb|=bsb[i-T];
		}
	}
	ck[n]=1;
	for(int i=n-1;i;i--){
		if(s[i+1]==s[n])ck[i]=1;
		else break;
	}
	int pos=-1;
	for(int i=1;i<=50000;i++){
		if(m<=T&&bsa[i][m]&&ck[i])pos=i;
	}
	for(int i=1;i<=50000;i++){
		if(bsb[i][m]&&ck[i+T])pos=i+T;
	}
	if(pos==-1){
		puts("NO");
		return 0;
	}
	puts("YES");
	out.push_back(pos);
	for(int i=m-1;i;i--){
		pos--;
		while(pos){
			if(pos<=T&&bsa[pos][i])break;
			if(pos>T&&bsb[pos-T][i])break;
			pos--;
		}
		out.push_back(pos);
	}
	reverse(out.begin(),out.end());
	for(auto to:out)printf("%d ",to);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

BBAAABBAAABAAA
BAAB

output:


result: