QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#389872#1819. Cleaning Robotblack_moonrise#WA 1ms4508kbC++141.2kb2024-04-14 20:44:072024-04-14 20:44:08

Judging History

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

  • [2024-04-14 20:44:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4508kb
  • [2024-04-14 20:44:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn = 30111;
const int mod = 998244353;
char a[maxn];
int n;
int pw[maxn];
struct DS {
	int offset;
	int L, R;
	int cnt[2];
	DS() {
		L = 1;
		R = 0;
	}
	void add(int x, int coef) {
		cnt[0] += coef * (a[x] == a[x+offset] || a[x] == '?' || a[x+offset]=='?');
		cnt[1] += coef * (a[x] == '?' && a[x+offset]=='?');
	} 
	int query(int x, int y) {
		if (R < L) {
			L = x;
			R = x-1;
		}
		while (R<y) add(++R, 1);
		while (L>x) add(--L, 1);
		while (R>y) add(R--, -1);
		while (L<x) add(L++, -1);
		if (cnt[0] != R-L+1) {
			return 0;
		} else {
			return pw[cnt[1]];
		}
	}
}D[maxn];
int query(int x, int y, int len) {
	assert(x<=y);
	return D[y-x].query(x, x+len-1);
}
int dp[maxn];
int main() {
	pw[0] = 1;
	for (int i=1; i<maxn; i++) pw[i] = 1ll * pw[i-1] * 26 % mod;

	scanf("%s", a+1);
	n = strlen(a+1);
	dp[0] = 1;
	int ans = 0;
	for (int i=0; i<=n/2; i++) {
		ans = (ans + 1ll * dp[i] * query(i+1, i+1, n-i-i)) % mod;
		for (int j=i+1; j<=n/2; j++) {
			dp[j] = (dp[j] + 1ll * dp[i] * query(i+1, n-j+1, j-i)) % mod;
		}
		cout<<dp[i]<<" ";
	}
	cout<<(ans % mod + mod)%mod;
	return 0;
}

详细

Test #1:

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

input:

10 7 1
8 3

output:

1 1 2

result:

wrong answer expected '2', found '1'