結果

問題 No.1741 Arrays and XOR Procedure
ユーザー monkukui2monkukui2
提出日時 2021-11-12 22:18:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 2,850 bytes
コンパイル時間 4,128 ms
コンパイル使用メモリ 163,080 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-17 02:03:50
合計ジャッジ時間 10,024 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 265 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 258 ms
4,380 KB
testcase_06 AC 263 ms
4,380 KB
testcase_07 AC 150 ms
4,384 KB
testcase_08 AC 34 ms
4,380 KB
testcase_09 AC 164 ms
4,380 KB
testcase_10 AC 169 ms
4,384 KB
testcase_11 AC 130 ms
4,380 KB
testcase_12 AC 98 ms
4,384 KB
testcase_13 AC 157 ms
4,380 KB
testcase_14 AC 109 ms
4,380 KB
testcase_15 AC 150 ms
4,380 KB
testcase_16 AC 9 ms
4,380 KB
testcase_17 AC 51 ms
4,380 KB
testcase_18 AC 113 ms
4,380 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 181 ms
4,384 KB
testcase_21 AC 139 ms
4,384 KB
testcase_22 AC 130 ms
4,380 KB
testcase_23 AC 46 ms
4,384 KB
testcase_24 AC 11 ms
4,380 KB
testcase_25 AC 180 ms
4,380 KB
testcase_26 AC 73 ms
4,380 KB
testcase_27 AC 8 ms
4,380 KB
testcase_28 AC 134 ms
4,380 KB
testcase_29 AC 152 ms
4,380 KB
testcase_30 AC 132 ms
4,380 KB
testcase_31 AC 8 ms
4,384 KB
testcase_32 AC 73 ms
4,380 KB
testcase_33 AC 90 ms
4,384 KB
testcase_34 AC 33 ms
4,380 KB
testcase_35 AC 3 ms
4,384 KB
testcase_36 AC 15 ms
4,380 KB
testcase_37 AC 69 ms
4,384 KB
testcase_38 AC 176 ms
4,384 KB
testcase_39 AC 57 ms
4,384 KB
testcase_40 AC 3 ms
4,380 KB
testcase_41 AC 28 ms
4,380 KB
testcase_42 AC 7 ms
4,384 KB
testcase_43 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "atcoder/all"
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>
#include <cstddef>
#include <type_traits>
#include <vector>

using namespace std;
const long long int INF = numeric_limits<long long int>::max() / 4;
const int inf = numeric_limits<int>::max() / 4;
const long long int MOD1000000007 = 1000000007;
const long long int MOD998244353 = 998244353;
const double MATH_PI = 3.1415926535897932;

template<typename T1, typename T2>
inline void chmin(T1 &a, const T2 &b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, const T2 &b) { if (a < b) a = b; }

#define lint long long int
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define VI vector<int>
#define VLL vector<long long>
#define VC vector<char>
#define VB vector<bool>
#define PI pair<int, int>
#define PLL pair<long long, long long>
#define VPI vector<pair<int, int>>
#define VPLL vector<pair<long long, long long>>
#define VVI vector<vector<int>>
#define VVPI vecor<vector<pair<int, int>>>
#define VVPILL vector<vector<pair<int, long long>>>

#define SUM(v) accumulate(ALL(v), 0LL)
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))

using mint = atcoder::modint998244353;

struct CombModP {
    vector<vector<long long>> com;
    long long p;
    CombModP(long long _p) : p(_p) {
        init(p);
    }
    void init(long long p) {
        com.assign(p, vector<long long>(p));
        com[0][0] = 1;
        for (int i = 1; i < p; i++) {
            com[i][0] = 1;
            for (int j = i; j > 0; j--) {
                com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]) % p;
            }
        }
    }
    long long nCk(long long n, long long k) {
        long long ret = 1;
        while (n > 0) {
            int ni = n % p;
            int ki = k % p;
            ret *= com[ni][ki];
            ret %= p;
            n /= p;
            k /= p;
        }
        return ret;
    }
};

int main() {

    CombModP com(2);
    int n; cin >> n;

    vector<mint> dp(2, 0);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        vector<mint> ndp(2, 0);
        for (int j = 0; j < 2; j++) {
            if (a == 0 or a == -1) {
                ndp[j] += dp[j];
            }
            if (a == 1 or a == -1) {
                ndp[(j + com.nCk(n - 1, i)) % 2] += dp[j];
            }
        }
        swap(dp, ndp);
    }
    cout << dp[1].val() << endl;
    return 0;
}
0