結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー SSRSSSRS
提出日時 2020-12-02 00:27:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,656 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 174,180 KB
実行使用メモリ 11,924 KB
最終ジャッジ日時 2023-09-03 03:47:27
合計ジャッジ時間 10,439 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
11,628 KB
testcase_01 AC 50 ms
11,632 KB
testcase_02 AC 51 ms
11,628 KB
testcase_03 AC 50 ms
11,636 KB
testcase_04 AC 54 ms
11,644 KB
testcase_05 AC 50 ms
11,908 KB
testcase_06 AC 50 ms
11,632 KB
testcase_07 AC 50 ms
11,748 KB
testcase_08 AC 49 ms
11,636 KB
testcase_09 AC 52 ms
11,640 KB
testcase_10 AC 51 ms
11,632 KB
testcase_11 AC 54 ms
11,636 KB
testcase_12 AC 51 ms
11,640 KB
testcase_13 AC 52 ms
11,632 KB
testcase_14 AC 50 ms
11,640 KB
testcase_15 AC 52 ms
11,688 KB
testcase_16 AC 52 ms
11,636 KB
testcase_17 AC 52 ms
11,920 KB
testcase_18 AC 53 ms
11,676 KB
testcase_19 AC 53 ms
11,640 KB
testcase_20 AC 51 ms
11,688 KB
testcase_21 AC 51 ms
11,752 KB
testcase_22 AC 49 ms
11,924 KB
testcase_23 AC 52 ms
11,908 KB
testcase_24 AC 50 ms
11,628 KB
testcase_25 AC 50 ms
11,636 KB
testcase_26 AC 50 ms
11,624 KB
testcase_27 AC 52 ms
11,632 KB
testcase_28 AC 54 ms
11,688 KB
testcase_29 AC 54 ms
11,744 KB
testcase_30 AC 54 ms
11,632 KB
testcase_31 AC 51 ms
11,692 KB
testcase_32 AC 49 ms
11,624 KB
testcase_33 AC 52 ms
11,632 KB
testcase_34 AC 54 ms
11,628 KB
testcase_35 AC 51 ms
11,624 KB
testcase_36 AC 51 ms
11,908 KB
testcase_37 AC 51 ms
11,820 KB
testcase_38 AC 51 ms
11,680 KB
testcase_39 AC 51 ms
11,684 KB
testcase_40 AC 55 ms
11,820 KB
testcase_41 AC 49 ms
11,824 KB
testcase_42 AC 50 ms
11,684 KB
testcase_43 AC 51 ms
11,628 KB
testcase_44 AC 50 ms
11,632 KB
04_evil_A_01 RE -
04_evil_A_02 RE -
04_evil_A_03 RE -
04_evil_A_04 RE -
04_evil_A_05 RE -
04_evil_A_06 RE -
04_evil_A_07 RE -
04_evil_A_08 RE -
04_evil_A_09 RE -
04_evil_A_10 RE -
05_evil_B_01 RE -
05_evil_B_02 RE -
05_evil_B_03 RE -
05_evil_B_04 RE -
05_evil_B_05 RE -
05_evil_B_06 RE -
05_evil_B_07 RE -
05_evil_B_08 RE -
05_evil_B_09 RE -
05_evil_B_10 RE -
06_evil_C_01 WA -
06_evil_C_02 WA -
06_evil_C_03 WA -
06_evil_C_04 WA -
06_evil_C_05 WA -
06_evil_C_06 WA -
06_evil_C_07 WA -
06_evil_C_08 WA -
06_evil_C_09 WA -
06_evil_C_10 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
void dfs(vector<vector<long long>> &H, vector<int> &A, int r, int prv, int x){
  if (r == 0){
    H[prv][x]++;
  } else {
    int K = A.size();
    for (int j = 0; j < K; j++){
      if (A[j] != prv){
        dfs(H, A, r - 1, A[j], x ^ A[j]);
      }
    }
  }
}
vector<long long> fwt(vector<long long> A, int N, bool inv){
	for (int i = 0; i < N; i++){
		for (int j = 0; j < (1 << N); j++){
			if (!(j >> i & 1)){
				long long x = A[j];
				long long y = A[j | (1 << i)];
				A[j] = x + y;
				A[j | (1 << i)] = x - y;
				if (inv){
					A[j] /= 2;
					A[j | (1 << i)] /= 2;
				}
			}
		}
	}
	return A;
}
vector<long long> xor_convolution(vector<long long> A, vector<long long> B, int N){
	A = fwt(A, N, false);
	B = fwt(B, N, false);
	vector<long long> C(1 << N);
	for (int i = 0; i < (1 << N); i++){
		C[i] = A[i] * B[i];
	}
	C = fwt(C, N, true);
	return C;
}
int main(){
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  Y = min(Y, 1023);
  vector<int> A(K);
  for (int i = 0; i < K; i++){
    cin >> A[i];
  }
  vector<vector<long long>> H(1024, vector<long long>(1024, 0));
  dfs(H, A, N / 2, -1, 0);
  vector<long long> sum(1024, 0);
  for (int i = 0; i < 1024; i++){
    for (int j = 0; j < 1024; j++){
      sum[j] += H[i][j];
    }
  }
  sum = xor_convolution(sum, sum, 10);
  long long ans = 0;
  for (int i = X; i <= Y; i++){
    ans += sum[i] % MOD;
  }
  ans %= MOD;
  for (int i = 0; i < 1024; i++){
    H[i] = xor_convolution(H[i], H[i], 10);
    for (int j = X; j <= Y; j++){
      ans += MOD - H[i][j] % MOD;
    }
    ans %= MOD;
  }
  cout << ans << endl;
}
0