QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245919#4669. Genetic ModificationslingyingWA 1ms3868kbC++141.3kb2023-11-10 14:39:072023-11-10 14:39:08

Judging History

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

  • [2023-11-10 14:39:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3868kb
  • [2023-11-10 14:39:07]
  • 提交

answer

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

const int N=1e5+5,M=8e4+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]='0';
	m=strlen(t+1);
	if(m>80000)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]-'0'];
		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
*/

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3868kb

input:

BBAAABBAAABAAA
BAAB

output:

NO

result:

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