結果

問題 No.1189 Sum is XOR
ユーザー tnakao0123tnakao0123
提出日時 2020-08-23 22:52:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,372 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 93,804 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 18:38:44
合計ジャッジ時間 1,729 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1189.cc:  No.1189 Sum is XOR - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int BN = 10;
const int BBITS = 1 << BN;
const int MOD = 998244353;

/* typedef */

/* global variables */

int cs[BBITS], dp[2][BBITS][BN + 1];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  if (k > BN) {
    puts("0");
    return 0;
  }

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    cs[ai]++;
  }

  dp[0][0][0] = 1;
  int cur = 0, nxt = 1;

  for (int ai = 0; ai < BBITS; ai++) {
    int ci = cs[ai];
    if (ci > 0) {
      memcpy(dp[nxt], dp[cur], sizeof(dp[cur]));

      for (int bits = 0; bits < BBITS; bits++)
	if (! (ai & bits))
	  for (int i = k - ci; i >= 0; i--)
	    addmod(dp[nxt][bits | ai][i + ci], dp[cur][bits][i]);
      swap(cur, nxt);
    }
  }

  int sum = 0;
  for (int bits = 0; bits < BBITS; bits++) addmod(sum, dp[cur][bits][k]);

  printf("%d\n", sum);
  return 0;
}
0