QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#687805 | #9463. 基础 ABC 练习题 | kkkgjyismine4 | 0 | 1ms | 3880kb | C++20 | 2.2kb | 2024-10-29 21:22:11 | 2024-10-29 21:22:12 |
answer
#include <bits/stdc++.h>
using namespace std;
#define N 61
#define u32 unsigned int
int n;
u32 f[N*3][N][N][2][2];
char t[N],s1[N],s2[N];
void solve(){
scanf("%d%s%s%s",&n,s1,s2,t+1);
// if(n!=60){puts("-1");return;}
u32 ret=0;
for(int x=0;x<=n;++x)
for(int y=0;x+y<=n;++y){
int z=n+1;
for(int i=x;i<=n;++i)
for(int j=y;i+j<=n;++j)
if(s1[i]=='1'&&s2[j]=='1')z=min(z,i+j);
if(z>n)continue;z=n-z;
for(int i=0;i<=n*3;++i)
for(int j=0,l,r;j<=min(n,i);++j){
l=max(0,(i-j-z+1)/2),r=min(min(n,i),min(x+i-2*j,min(y+j,i-j)));
for(int k=l;k<=r;++k)f[i][j][k][0][0]=f[i][j][k][0][1]=f[i][j][k][1][0]=f[i][j][k][1][1]=0;
}
int o=(!x),o1=(!y);
f[0][0][0][o][o1]=1;
for(int i=0;i<n*3;++i)
for(int j=0,l,r;j<=min(n,i);++j){
// i-j-k<=n
l=max(max(0,i-j-n),(i-j-z+1)/2),r=min(min(n,i),min(x+i-2*j,min(y+j,i-j)));
// cout<<i<<" "<<j<<" "<<l<<" "<<r<<endl;
if(t[i+1]=='?'){
for(int k=l,m=i-j-k,o1,o2;k<=r;++k,--m){
for(int a=0;a<2;++a)
for(int b=0;b<2;++b){
f[i+1][j+1][k][a|(j+1-m==x)][b]+=f[i][j][k][a][b];
f[i+1][j][k+1][a][b|(k-j+1==y)]+=f[i][j][k][a][b];
f[i+1][j][k][a][b]+=f[i][j][k][a][b];
}
}
}else if(t[i+1]=='A'){
for(int k=l,m=i-j-k,o1,o2;k<=r;++k,--m){
for(int a=0;a<2;++a)
for(int b=0;b<2;++b){
f[i+1][j+1][k][a|(j+1-m==x)][b]+=f[i][j][k][a][b];
}
}
}else if(t[i+1]=='B'){
for(int k=l,m=i-j-k,o1,o2;k<=r;++k,--m){
for(int a=0;a<2;++a)
for(int b=0;b<2;++b){
f[i+1][j][k+1][a][b|(k-j+1==y)]+=f[i][j][k][a][b];
}
}
}else{
for(int k=l,m=i-j-k,o1,o2;k<=r;++k,--m){
for(int a=0;a<2;++a)
for(int b=0;b<2;++b){
f[i+1][j][k][a][b]+=f[i][j][k][a][b];
}
}
}
}
for(int i=n*3;i<=n*3;++i)
for(int j=0,l,r;j<=min(n,i);++j){
l=max(max(0,i-j-n),(i-j-z+1)/2),r=min(min(n,i),min(x+i-2*j,min(y+j,i-j)));
for(int k=l,m=i-j-l;k<=r;++k,--m){
if(j==n&&k==n)ret+=f[i][j][k][1][1];
}
}
}
cout<<ret<<endl;
}
int main() {
int t;cin>>t;
while(t--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3788kb
input:
60 1 1 11 11 ABC 2 111 111 CABABC 3 1111 1111 CAABBCBAC 4 11111 11111 BACBBACBACAC 5 111111 111111 CABCCBBAABCCBAA 6 1111111 1111111 ABABABCACBCBCCACBA 7 11111111 11111111 BCAABACBBCBBABCCAACAC 8 111111111 111111111 CCBCBBBCAABCBCAAAAACBCBA 9 1111111111 1111111111 CCCCACABCBABAABCCAABABBCBBA 10 1111...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
wrong answer Your answer is wrong in testcase 1
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #22:
score: 0
Wrong Answer
time: 1ms
memory: 3880kb
input:
60 3 1 11 11 ??? 2 111 111 ?????? 3 1111 1111 ????????? 4 11111 11111 ???????????? 5 111111 111111 ??????????????? 6 1111111 1111111 ?????????????????? 7 11111111 11111111 ????????????????????? 8 111111111 111111111 ???????????????????????? 9 1111111111 1111111111 ??????????????????????????? 10 1111...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
wrong answer Your answer is wrong in testcase 1
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%