QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#246060#4669. Genetic ModificationslingyingML 217ms1019136kbC++141.3kb2023-11-10 15:59:122023-11-10 15:59:13

Judging History

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

  • [2023-11-10 15:59:13]
  • 评测
  • 测评结果:ML
  • 用时:217ms
  • 内存:1019136kb
  • [2023-11-10 15:59:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=1e5+5,M=9e4+5;

int n,m;
int sum[N],L[N];
char s[N],t[N];
bitset<M> tmp,base;
bitset<M> f[N],g[2];

bool check(int l,int r)
{
	if(l>r)return 1;
	else return sum[r]-sum[l-1]==0||sum[r]-sum[l-1]==(r-l+1);
}

int main()
{
	for(int i=0;i<M;i++)base[i]=0;
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);
	s[++n]='A';
	m=strlen(t+1);
        if(m>90000)return puts("NO"),0;
	for(int i=1;i<=n;i++)sum[i]=s[i]-'A';
	for(int i=1;i<=n;i++)sum[i]+=sum[i-1];
	for(int i=1;i<=m;i++)g[0][i]=t[i]=='A';
	for(int i=1;i<=m;i++)g[1][i]=t[i]=='B';
	g[0][++m]=1;
	f[0][0]=1;
	int lst=-1;
	for(int i=1;i<=n;i++)
	{
		int l=1,r=i-1;
		while(l<r)
		{
			int mid=l+r>>1;
			if(check(mid,i-1))r=mid;
			else l=mid+1;
		}
		L[i]=l-1;
		if(l-1==lst)f[i]=tmp;
		else
		{
			tmp&=base;
			for(int j=l-1;j<i;j++)tmp|=f[j];
			f[i]=tmp;
			lst=l-1;
		}
		f[i]<<=1;
		f[i]&=g[s[i]-'A'];
		tmp|=f[i];
		//for(int j=1;j<=m;j++)cout<<i<<"   ---   "<<j<<"   ---   "<<f[i][j]<<endl;
	}
	if(!f[n][m])return puts("NO"),0;
	puts("YES");
	m--;
	int now=n;
	vector<int> vt;
	for(int t=m;t>=1;t--)
	{
		int p;
		for(int j=now-1;j>=L[now];j--)
			if(f[j][t]){p=j;break;}
		vt.push_back(p);
		now=p;
	}
	reverse(vt.begin(),vt.end());
	for(int x:vt)cout<<x<<' ';
	return 0;
}

/*
0001101101
0110
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3920kb

input:

BBAAABBAAABAAA
BAAB

output:

YES
2 5 8 11 

result:

ok good solution

Test #2:

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

input:

ABABABABAB
ABAB

output:

NO

result:

ok no solution

Test #3:

score: 0
Accepted
time: 111ms
memory: 544040kb

input:

BBAAAAABBAAAAAABBABAABBBBBAABBBAAABABBABABBBAAABBAAAABBBBBABAABBBAABBBBBBBABBABABBAAAABBAAAABAAAABBABAAAAAAABBBBAAAAAABAABABBAAAAABBBBAABABABAAAAABBBABABBAABABBBBAABAABBBBBABBABABBAAABBAAAABBBABBABAAAABBBAABAAABBBAAAAAAAAAAAAABABBAABBBBABABAABBBBABAABBAAABABBBBAAAAAAAABBAAAABBABABABBBAAABAABBABBAAAA...

output:

NO

result:

ok no solution

Test #4:

score: 0
Accepted
time: 38ms
memory: 148016kb

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: 0
Accepted
time: 217ms
memory: 1019136kb

input:

BAABBBBBBAAABABABAAAAABAABBAAABBAABBBAABABBBABBABBBABBBBABAABAAAAABBBBBBBABABABAABABAABAABBBBBBABABABABBABBBBAABAABBAAABABBAAAAAAABBAAAAAAAABAAABABBAAABABABBBABAAABBBAABAABBABBBBBBBBBABBBABBBABBAABAABBABABBBBAAAABABAABAABABBABBABBBBBAABABABBBBBABAABBABABAABBABAABABBBBABABBBBBBABBBABABBAAABBAAABBABBA...

output:

NO

result:

ok no solution

Test #6:

score: -100
Memory Limit Exceeded

input:

BBAABBAAABBBBAAABABBBABBBAABABAABBBABABBBAABBBBBBABBBAABABBBAAAAABABBABAABBAABABAABBAAABBBABAABBBAABAABABABBBBAABBBBBBBBBBBABBABABABBABBAAAAAAABAABABAABBABBABABBBBBAABBABBAABAABBBABBABBAABBBAAABBAAABABBBBBAAAABBAAABBAABABBABAABBBBAABBBAAAAAABBBAAAAABBBAAAABAABAAABBBAAABABBBABBBBBBBBAABABBABBBABAABAA...

output:

NO

result: