QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#397673 | #8546. Min or Max 2 | comeintocalm# | WA | 1ms | 3872kb | C++17 | 1.1kb | 2024-04-24 15:48:23 | 2024-04-24 15:48:23 |
Judging History
answer
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;
const int mo = 998244353;
const int MAXN = 3e3 + 5;
#define inc(t1) ((t1) >= mo ? ((t1) -= mo) : 0)
int T, n, m;
char s[MAXN];
int ok[MAXN];
int f[MAXN][MAXN];
int r[MAXN], l[MAXN];
int main() {
int i,j,k;
cin >> n;
f[0][1] = 1;
r[0] = 1;
for (i = 1; i <= n; ++i) {
cin >> s + 1;
int ret = 0, flg = 0;
r[i] = 1, l[i] = n;
for (j = 1; j <= n; ++j)
if (s[j] == '0') r[i] = j, flg = 1;
for (j = n; j >= 1; --j)
if (s[j] == '0') l[i] = j;
for (j = r[i - 1]; j <= l[i]; ++j)
if (s[j] != '1') f[i][j] += f[i - 1][j], inc (f[i][j]);
for (j = r[i - 1]; j <= n; ++j) {
if (s[j] != '0') ret += f[i - 1][j];
if (s[j] != '1') f[i][j] += ret, inc (f[i][j]);
if (s[j] == '0') ret = f[i][j];
else if (s[j] == '?') ret += f[i][j], inc (ret);
}
if (!flg) {
for (j = 1; j <= n; ++j) f[i][j] += f[i - 1][j], inc (f[i][j]);
}
//for (j = r[i]; j <= n; ++j) f[i][j] += f[i - 1][j], inc (f[i][j]);
}
int ans = 0;
for (j = 1; j <= n; ++j) ans += f[n][j], inc (ans);
printf ("%d", ans);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3872kb
input:
4 2 1 2 2 1 5 2 4 1 5 3 2 4 1 5 3 5 1 2 3 4 5 5 4 3 2 1 8 5 8 3 4 2 7 1 6 4 6 3 8 5 1 2 7
output:
399
result:
wrong answer 1st numbers differ - expected: '2', found: '399'