結果

問題 No.1958 Bit Game
ユーザー ___Johniel___Johniel
提出日時 2022-05-29 19:04:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 668 ms / 2,000 ms
コード長 2,498 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 172,280 KB
実行使用メモリ 10,564 KB
最終ジャッジ日時 2023-10-21 00:09:21
合計ジャッジ時間 18,231 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 650 ms
10,564 KB
testcase_01 AC 653 ms
10,564 KB
testcase_02 AC 652 ms
10,564 KB
testcase_03 AC 668 ms
10,564 KB
testcase_04 AC 662 ms
10,564 KB
testcase_05 AC 652 ms
10,564 KB
testcase_06 AC 654 ms
10,564 KB
testcase_07 AC 649 ms
10,564 KB
testcase_08 AC 653 ms
10,564 KB
testcase_09 AC 653 ms
10,564 KB
testcase_10 AC 222 ms
7,132 KB
testcase_11 AC 338 ms
8,188 KB
testcase_12 AC 304 ms
8,980 KB
testcase_13 AC 443 ms
8,452 KB
testcase_14 AC 419 ms
8,188 KB
testcase_15 AC 169 ms
9,508 KB
testcase_16 AC 93 ms
8,452 KB
testcase_17 AC 539 ms
9,772 KB
testcase_18 AC 431 ms
9,772 KB
testcase_19 AC 175 ms
8,716 KB
testcase_20 AC 583 ms
8,188 KB
testcase_21 AC 243 ms
9,508 KB
testcase_22 AC 348 ms
7,132 KB
testcase_23 AC 146 ms
7,924 KB
testcase_24 AC 581 ms
9,244 KB
testcase_25 AC 217 ms
7,924 KB
testcase_26 AC 515 ms
8,188 KB
testcase_27 AC 130 ms
9,244 KB
testcase_28 AC 577 ms
8,716 KB
testcase_29 AC 324 ms
7,660 KB
testcase_30 AC 11 ms
6,780 KB
testcase_31 AC 11 ms
6,780 KB
testcase_32 AC 13 ms
6,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder/1958/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))
// #define endl "\n"

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 998244353;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, x, y;
  while (cin >> n >> x >> y) {
    vec<lli> a(x), b(y);
    cin >> a >> b;

    lli z = 0;
    for (int i = 0; i < 61; ++i) {
      const lli w = 1LL << i;
      vec<lli> s(2, 0);
      vec<lli> t(2, 0);
      each (j, a) ++s[!!(j & w)];
      each (j, b) ++t[!!(j & w)];
      const int N = 2 * 1e5 + 3;
      static lli dp[N][2];
      fill(&dp[0][0], &dp[N - 1][2 - 1] + 1, 0);
      dp[0][0] = 1;
      for (int j = 0; j < n; ++j) {
        for (int x = 0; x < 2; ++x) {
          for (int y = 0; y < 2; ++y) {
            for (int z = 0; z < 2; ++z) {
              lli u = dp[j][x];
              (u *= s[y]) %= mod;
              (u *= t[z]) %= mod;
              (dp[j + 1][(x | y) & z] += u) %= mod;
            }
          }
        }
      }
      (z += dp[n][1] * (w % mod) % mod) %= mod;
    }
    cout << z << endl;
  }

  return 0;
}
0