QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#389872 | #1819. Cleaning Robot | black_moonrise# | WA | 1ms | 4508kb | C++14 | 1.2kb | 2024-04-14 20:44:07 | 2024-04-14 20:44:08 |
Judging History
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'