結果

問題 No.1741 Arrays and XOR Procedure
ユーザー okuraofvegetablokuraofvegetabl
提出日時 2021-11-12 23:15:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,413 bytes
コンパイル時間 2,406 ms
コンパイル使用メモリ 210,776 KB
実行使用メモリ 14,996 KB
最終ジャッジ日時 2024-11-25 21:27:56
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 2 ms
6,820 KB
testcase_03 AC 50 ms
14,884 KB
testcase_04 AC 2 ms
6,820 KB
testcase_05 AC 37 ms
14,920 KB
testcase_06 AC 45 ms
14,988 KB
testcase_07 AC 41 ms
14,904 KB
testcase_08 AC 29 ms
14,996 KB
testcase_09 AC 37 ms
13,532 KB
testcase_10 AC 38 ms
13,756 KB
testcase_11 AC 30 ms
11,392 KB
testcase_12 AC 24 ms
9,600 KB
testcase_13 AC 36 ms
13,076 KB
testcase_14 AC 26 ms
10,348 KB
testcase_15 AC 35 ms
12,600 KB
testcase_16 AC 4 ms
6,820 KB
testcase_17 AC 14 ms
6,816 KB
testcase_18 AC 27 ms
10,744 KB
testcase_19 AC 3 ms
6,820 KB
testcase_20 AC 42 ms
14,788 KB
testcase_21 AC 32 ms
11,988 KB
testcase_22 AC 29 ms
11,164 KB
testcase_23 AC 13 ms
6,816 KB
testcase_24 AC 4 ms
6,816 KB
testcase_25 AC 40 ms
14,560 KB
testcase_26 AC 18 ms
7,936 KB
testcase_27 WA -
testcase_28 AC 31 ms
11,748 KB
testcase_29 AC 35 ms
12,748 KB
testcase_30 AC 30 ms
11,332 KB
testcase_31 WA -
testcase_32 AC 19 ms
7,936 KB
testcase_33 AC 22 ms
9,132 KB
testcase_34 AC 9 ms
6,816 KB
testcase_35 WA -
testcase_36 AC 6 ms
6,820 KB
testcase_37 AC 17 ms
7,680 KB
testcase_38 AC 40 ms
14,252 KB
testcase_39 AC 15 ms
7,040 KB
testcase_40 AC 2 ms
6,816 KB
testcase_41 AC 9 ms
6,820 KB
testcase_42 AC 4 ms
6,816 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define drep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)

#define popcount __builtin_popcount
#define next __next
#define prev __prev

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

template <class T>
bool chmin(T &a, const T &b) {
  if (a <= b) return false;
  a = b;
  return true;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a >= b) return false;
  a = b;
  return true;
}

template <class T>
using MaxHeap = priority_queue<T>;

template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}

// ----------------- Output ------------------

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ',' << p.second;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &e : v) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

template <class TupleTy, size_t... I>
void dump_tuple(ostream &os, const TupleTy t, std::index_sequence<I...>) {
  (..., (os << (I == 0 ? "" : ",") << std::get<I>(t)));
}

template <class... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
  os << "(";
  dump_tuple(os, t, std::make_index_sequence<sizeof...(Args)>());
  return os << ")";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------------ ACL --------------------

#include <atcoder/modint>
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
using mint = atcoder::static_modint<MOD>;
ostream &operator<<(ostream &os, const mint &v) {
  return os << v.val();
}

// ------------ End of template --------------

#define endl "\n"
using ll = long long;
using pii = pair<int, int>;

const bool multitest = false;

int nCk(int n, int k) {
  int res = 0;
  while (n > 0) {
    int nb = (n & 1);
    n >>= 1;
    int kb = (k & 1);
    k >>= 1;
    if (!(nb < kb)) res++;
  }
  return res % 2;
}

void solve() {
  int N;
  cin >> N;
  vector<int> B(N);
  cin >> B;
  auto dp = vect(N + 1, vect(2, mint(0)));
  dp[0][0] = mint(1);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      if (B[i] == -1) {
        for (int k = 0; k < 2; k++) {
          dp[i + 1][(j + k * nCk(N - 1, i)) % 2] += dp[i][j];
        }
      } else if (B[i] == 1) {
        dp[i + 1][(j + nCk(N - 1, i)) % 2] += dp[i][j];
      } else {
        assert(B[i] == 0);
        dp[i + 1][j] += dp[i][j];
      }
    }
  }
  cout << dp[N][1] << endl;
  return;
}

int main() {
  fastio();
  if (!multitest) {
    solve();
  } else {
    cerr << "[Warning] Multi testcase mode on" << endl;
    int t;
    cin >> t;
    while (t--) solve();
  }
  return 0;
}
0