結果
| 問題 |
No.1189 Sum is XOR
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-08-23 23:01:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 1,409 bytes |
| コンパイル時間 | 679 ms |
| コンパイル使用メモリ | 96,368 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 19:25:50 |
| 合計ジャッジ時間 | 1,994 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
/* -*- 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 */
typedef long long ll;
/* 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 - 1; i >= 0; i--)
addmod(dp[nxt][bits | ai][i + 1], (ll)dp[cur][bits][i] * ci % MOD);
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;
}
tnakao0123