QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#852463#9995. 乒乓球赛CelebrateWA 1ms5720kbC++141.7kb2025-01-11 11:59:022025-01-11 11:59:04

Judging History

This is the latest submission verdict.

  • [2025-01-11 11:59:04]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5720kb
  • [2025-01-11 11:59:02]
  • Submitted

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 1e5 + 10, mod = 998244353;
int n, a[N], b[N], dp[N][30];

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i <= n; i++) {
        memset(dp[i], 0, sizeof(dp[i]));
    }
    int key = 15;
    dp[0][key] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = key - 11; j <= key + 11; j++) {
            dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1]) % mod;
        }
        if (a[i] != -1 && a[i] + b[i] != i) {
            cout << "0\n"; return;
        }
        for (int j = -11; j <= 11; j++) {
            if (abs(i - j) & 1) {
                dp[i][j + key] = 0;
                continue;
            }
            int x = (i + j) / 2, y = (i - j) / 2;
            if (x < 0 || y < 0) {
                dp[i][j + key] = 0;
            }
            else if (max(x, y) >= 11 && abs(x - y) >= 2) {
                if (i < n) {
                    dp[i][j + key] = 0;
                }
            }
            else {
                if (i == n) {
                    dp[i][j + key] = 0;
                }
            }
        }
        if (a[i] != -1) {
            int t = a[i] - b[i];
            for (int j = key - 11; j <= key + 11; j++) {
                if (j - key != t && j - key != -t) {
                    dp[i][j] = 0;
                }
            }
        }
    }
    cout << (dp[n][key + 2] + dp[n][key - 2]) % mod << endl;
}

int main() {
    // freopen("in.in", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T; cin >> T;
    while (T--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7
11
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
11
-1 -1
1 1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
11
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
1 11
22
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-...

output:

0
0
0
0
369512
0
864

result:

wrong answer 1st lines differ - expected: '2', found: '0'