QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246102#4669. Genetic ModificationsQZJ123456WA 120ms615988kbC++142.1kb2023-11-10 16:14:062023-11-10 16:14:09

Judging History

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

  • [2023-11-10 16:14:09]
  • 评测
  • 测评结果:WA
  • 用时:120ms
  • 内存:615988kb
  • [2023-11-10 16:14:06]
  • 提交

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;
		if(i==1)p=0;
		else p=lst[(s[i-1]-'0')^1];
		if(s[1]=='1'&&s[2]=='0'&&s[3]=='0'&&i==75000)cout<<i<<" ",exit(0);
		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+1)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<=min(n,T);i++){
		if(m<=T&&bsa[i][m]&&ck[i])pos=i;
	}
	for(int i=T+1;i<=n;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: 1ms
memory: 5920kb

input:

BBAAABBAAABAAA
BAAB

output:

YES
2 5 8 11 

result:

ok good solution

Test #2:

score: 0
Accepted
time: 1ms
memory: 7764kb

input:

ABABABABAB
ABAB

output:

NO

result:

ok no solution

Test #3:

score: 0
Accepted
time: 27ms
memory: 306976kb

input:

BBAAAAABBAAAAAABBABAABBBBBAABBBAAABABBABABBBAAABBAAAABBBBBABAABBBAABBBBBBBABBABABBAAAABBAAAABAAAABBABAAAAAAABBBBAAAAAABAABABBAAAAABBBBAABABABAAAAABBBABABBAABABBBBAABAABBBBBABBABABBAAABBAAAABBBABBABAAAABBBAABAAABBBAAAAAAAAAAAAABABBAABBBBABABAABBBBABAABBAAABABBBBAAAAAAAABBAAAABBABABABBBAAABAABBABBAAAA...

output:

NO

result:

ok no solution

Test #4:

score: 0
Accepted
time: 28ms
memory: 85940kb

input:

BABABAABABBABAAAAABAABBAAAAABABABBABABBBBBBBAAAAAAABAAAAABAABBABBABABBBABBBAAAABBBABABBAAAABBBAABBBBBBBAAAABAAAABBBBABBAABAABBBAABBBBABAABABBBBAABABBABBAABAABBBBBAAABBAABABBBBAABABBABAABAAAABBABABAABBBABBBBABABABABAAABBABABABABBABAABBBBABAABBABBBBABABBABBBBBAABBBBBAAABAABAAAABBBBBABBABABABBBBABBBABA...

output:

YES
1 2 4 5 7 8 9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 65 66 67 69 70 71 72 73 74 75 76 77 78 79 81 82 83 85 86 87 88 89 90 91 94 95 96 98 99 100 101 102 103 104 105 106 107 108 110 111 1...

result:

ok good solution

Test #5:

score: -100
Wrong Answer
time: 120ms
memory: 615988kb

input:

BAABBBBBBAAABABABAAAAABAABBAAABBAABBBAABABBBABBABBBABBBBABAABAAAAABBBBBBBABABABAABABAABAABBBBBBABABABABBABBBBAABAABBAAABABBAAAAAAABBAAAAAAAABAAABABBAAABABABBBABAAABBBAABAABBABBBBBBBBBABBBABBBABBAABAABBABABBBBAAAABABAABAABABBABBABBBBBAABABABBBBBABAABBABABAABBABAABABBBBABABBBBBBABBBABABBAAABBAAABBABBA...

output:

75000 

result:

wrong output format Unexpected end of file - int32 expected