QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#708529#8552. Sticksucup-team1264#WA 0ms3748kbC++201.4kb2024-11-03 23:12:282024-11-03 23:12:30

Judging History

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

  • [2024-11-03 23:12:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3748kb
  • [2024-11-03 23:12:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<vector<char>> g(n + 1, vector<char>(n + 1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> g[i][j];
        }
    }
    vector cdp(n + 1, vector<array<i64, 2>>(n + 1, {0, 1}));
    vector dp(n + 1, vector<i64>(n + 1, 1));
    for (int i = 1; i <= n; i++) {
        for (int j = n; j >= 1; j--) {
            cdp[i][j] = {0, 0};
            if (g[i][j] != '0') {
                (cdp[i][j][1] += cdp[i - 1][j][1]) %= MOD;
            }
            if (g[i][j] != '1') {
                (cdp[i][j][0] += cdp[i - 1][j][0] + cdp[i - 1][j][1]) %= MOD;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        int len = 0;
        while (len < n && g[i][len] != '0') len++;
        for (int j = 1; j <= n; j++) {
            dp[i][j] = 0;
            if (j != 1) (dp[i][j] = dp[i][j - 1] * (cdp[i][j][0] + cdp[i][j][1])) %= MOD;
            if (j - 1 <= len) {
                (dp[i][j] += dp[i - 1][j - 1] * cdp[i][j][0]) %= MOD;
            }
        }
        for (int j = 1; j <= n; j++) {
            if (j <= len) {
                (dp[i][j] += dp[i - 1][j]) %= MOD;
            }
        }
    }
    cout << dp[n][n] << "\n";
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3532kb

input:

2
??
??

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3748kb

input:

5
??1??
?1??0
??0??
???1?
??1??

output:

1576

result:

wrong answer 1st numbers differ - expected: '3144', found: '1576'