QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245934#4669. Genetic ModificationsQZJ123456WA 47ms307072kbC++142.0kb2023-11-10 14:41:152023-11-10 14:41:20

Judging History

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

  • [2023-11-10 14:41:20]
  • 评测
  • 测评结果:WA
  • 用时:47ms
  • 内存:307072kb
  • [2023-11-10 14:41:15]
  • 提交

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(){
	scanf("%s",s+1);scanf("%s",t+1);
	n=strlen(s+1),m=strlen(t+1);
	for(int i=1;i<=n;i++)if(s[i]=='A')s[i]='0';else s[i]='1';
	for(int i=1;i<=m;i++)if(t[i]=='A')t[i]='0';else t[i]='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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 6020kb

input:

BBAAABBAAABAAA
BAAB

output:

YES
2 5 8 11 

result:

ok good solution

Test #2:

score: 0
Accepted
time: 0ms
memory: 5876kb

input:

ABABABABAB
ABAB

output:

NO

result:

ok no solution

Test #3:

score: 0
Accepted
time: 47ms
memory: 307072kb

input:

BBAAAAABBAAAAAABBABAABBBBBAABBBAAABABBABABBBAAABBAAAABBBBBABAABBBAABBBBBBBABBABABBAAAABBAAAABAAAABBABAAAAAAABBBBAAAAAABAABABBAAAAABBBBAABABABAAAAABBBABABBAABABBBBAABAABBBBBABBABABBAAABBAAAABBBABBABAAAABBBAABAAABBBAAAAAAAAAAAAABABBAABBBBABABAABBBBABAABBAAABABBBBAAAAAAAABBAAAABBABABABBBAAABAABBABBAAAA...

output:

NO

result:

ok no solution

Test #4:

score: -100
Wrong Answer
time: 29ms
memory: 85668kb

input:

BABABAABABBABAAAAABAABBAAAAABABABBABABBBBBBBAAAAAAABAAAAABAABBABBABABBBABBBAAAABBBABABBAAAABBBAABBBBBBBAAAABAAAABBBBABBAABAABBBAABBBBABAABABBBBAABABBABBAABAABBBBBAAABBAABABBBBAABABBABAABAAAABBABABAABBBABBBBABABABABAAABBABABABABBABAABBBBABAABBABBBBABABBABBBBBAABBBBBAAABAABAAAABBBBBABBABABABBBBABBBABA...

output:

NO

result:

wrong answer you didn't find a solution but jury did