QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245922 | #4669. Genetic Modifications | lingying | WA | 1ms | 5876kb | C++14 | 1.3kb | 2023-11-10 14:39:36 | 2023-11-10 14:39:38 |
Judging History
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5876kb
input:
BBAAABBAAABAAA BAAB
output:
NO
result:
wrong answer you didn't find a solution but jury did