QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#765817#9489. 0100 InsertionfanchuanyuWA 122ms11864kbC++14955b2024-11-20 15:20:542024-11-20 15:20:55

Judging History

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

  • [2024-11-20 15:20:55]
  • 评测
  • 测评结果:WA
  • 用时:122ms
  • 内存:11864kb
  • [2024-11-20 15:20:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int dp[2][506][1015][2];

void mk(int &a, int b) {
	(a += b);
	a -= (a >= mod ? mod : 0);
}

signed main() {
	int n;
	string s;
	cin >> n >> s;
	s = ' ' + s;
	dp[(n + 1) & 1][0][505][0] = 1;
	for (int i = n; i; i--) {
		memset(dp[i & 1], 0, sizeof(dp[i & 1]));
		if (s[i] != '0')
			for (int j = 0; j <= ((n - i + 1) + 2) / 3; j++)
				for (int k = 506 - (n - i + 1); k <= 505 + j; k++)
					if (k - 502 <= j + 1)
						mk(dp[i & 1][max(j, k - 502)][k + 3][1], dp[i & 1 ^ 1][j][k][0]);
		if (s[i] != '1')
			for (int j = 0; j <= ((n - i + 1) + 2) / 3; j++)
				for (int k = 506 - (n - i + 1); k <= 505 + j; k++)
					for (int tp : {
					            0, 1
					        })
						mk(dp[i & 1][j][k - 1][0], dp[i & 1 ^ 1][j][k][tp]);
	}
	int ans = 0;
	for (int i = 0; i <= 505; i++) {
		ans += dp[1][i][505][0];
	}
	cout << ans << '\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 11564kb

input:

8
0??0?100

output:

2

result:

ok "2"

Test #2:

score: 0
Accepted
time: 3ms
memory: 11624kb

input:

4
?10?

output:

1

result:

ok "1"

Test #3:

score: 0
Accepted
time: 3ms
memory: 11612kb

input:

28
???????????0???0??????1???0?

output:

2023

result:

ok "2023"

Test #4:

score: 0
Accepted
time: 3ms
memory: 11616kb

input:

4
????

output:

1

result:

ok "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 11624kb

input:

8
11111111

output:

0

result:

ok "0"

Test #6:

score: -100
Wrong Answer
time: 122ms
memory: 11864kb

input:

500
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

1634094412

result:

wrong answer 1st words differ - expected: '870731023', found: '1634094412'