QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687878#9463. 基础 ABC 练习题kkkgjyismine40 407ms14308kbC++201.9kb2024-10-29 21:41:032024-10-29 21:41:06

Judging History

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

  • [2024-10-29 21:41:06]
  • 评测
  • 测评结果:0
  • 用时:407ms
  • 内存:14308kb
  • [2024-10-29 21:41:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 65
#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!=50){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){
					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)));
					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];
								}
						}
					}
				}
			ret+=f[n*3][n][n][1][1];
	}
	cout<<ret<<endl;
}
int main() {
	int t,ss;cin>>t>>ss;
	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: 187ms
memory: 14308kb

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:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

wrong answer Your answer is wrong in testcase 50

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 407ms
memory: 14216kb

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:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2328720080
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

wrong answer Your answer is wrong in testcase 50

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%