結果

問題 No.1741 Arrays and XOR Procedure
ユーザー ぷらぷら
提出日時 2021-11-12 22:10:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,555 bytes
コンパイル時間 2,269 ms
コンパイル使用メモリ 201,332 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 09:02:52
合計ジャッジ時間 4,235 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 37 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 31 ms
6,940 KB
testcase_06 AC 35 ms
6,940 KB
testcase_07 AC 35 ms
6,944 KB
testcase_08 AC 31 ms
6,940 KB
testcase_09 AC 31 ms
6,940 KB
testcase_10 AC 31 ms
6,944 KB
testcase_11 AC 25 ms
6,940 KB
testcase_12 AC 19 ms
6,944 KB
testcase_13 AC 30 ms
6,944 KB
testcase_14 AC 21 ms
6,944 KB
testcase_15 AC 26 ms
6,940 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 WA -
testcase_18 AC 23 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 WA -
testcase_21 AC 26 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 10 ms
6,944 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 33 ms
6,940 KB
testcase_26 WA -
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 25 ms
6,944 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 15 ms
6,944 KB
testcase_33 AC 18 ms
6,944 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 4 ms
6,940 KB
testcase_37 AC 14 ms
6,940 KB
testcase_38 AC 35 ms
6,944 KB
testcase_39 AC 13 ms
6,940 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 8 ms
6,940 KB
testcase_42 WA -
testcase_43 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int mod = 998244353;
int dp[200001][2];

long long modpow(long long a,long long b) {
    long long ans = 1;
    while(b) {
        if(b & 1) {
            (ans *= a) %= mod;
        }
        (a *= a) %= mod;
        b /= 2;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    dp[0][0] = 1;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        int B;
        cin >> B;
        if(N%2 == 1) {
            if(i == 0 || i+1 == N) {
                for(int j = 0; j < 2; j++) {
                    if(B == 0 || B == -1) {
                        dp[i+1][j] += dp[i][j];
                        dp[i+1][j] %= mod;
                    }
                    if(B == 1 || B == -1) {
                        dp[i+1][j^1] += dp[i][j];
                        dp[i+1][j^1] %= mod;
                    }
                }
            }
            else {
                if(B == -1) {
                    cnt++;
                }
                for(int j = 0; j < 2; j++) {
                    dp[i+1][j] = dp[i][j];
                }
            }
        }
        if(N%2 == 0) {
            for(int j = 0; j < 2; j++) {
                if(B == 0 || B == -1) {
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= mod;
                }
                if(B == 1 || B == -1) {
                    dp[i+1][j^1] += dp[i][j];
                    dp[i+1][j^1] %= mod;
                }
            }
        }
    }
    cout << modpow(2,cnt)*dp[N][1]%mod << endl;
}
0