結果
問題 | No.1304 あなたは基本が何か知っていますか?私は知っています. |
ユーザー |
![]() |
提出日時 | 2020-12-01 20:59:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,553 bytes |
コンパイル時間 | 2,405 ms |
コンパイル使用メモリ | 205,492 KB |
最終ジャッジ日時 | 2025-01-16 12:11:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 44 WA * 14 RE * 16 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000000 int N,K,X,Y; vector<int> B; vector<vector<long long>> cnt(1024,vector<long long>(1024,0)); void dfs(int n,int x,int last){ if(n==0){ cnt[last][x]++; return; } rep(i,B.size()){ if(i==last)continue; dfs(n-1,x^B[i],i); } } template <typename T> void fwt(vector<T>& f) { int n = f.size(); for (int i = 1; i < n; i <<= 1) { for (int j = 0; j < n; j++) { if ((j & i) == 0) { T x = f[j], y = f[j | i]; f[j] = x + y, f[j | i] = x - y; } } } } template <typename T> void ifwt(vector<T>& f) { int n = f.size(); for (int i = 1; i < n; i <<= 1) { for (int j = 0; j < n; j++) { if ((j & i) == 0) { T x = f[j], y = f[j | i]; f[j] = (x + y) / 2, f[j | i] = (x - y) / 2; } } } } long long get(vector<long long> v){ fwt(v); rep(i,v.size())v[i] *= v[i]; ifwt(v); long long ret= 0LL; for(int i=X;i<=min(Y,1024);i++)ret += v[i]; return ret; } int main(){ cin>>N>>K>>X>>Y; set<int> A; rep(i,K){ int a; cin>>a; if(A.count(a))continue; A.insert(a); B.push_back(a); } dfs(N/2,0,-1); vector<long long> Cnt(1024,0); rep(i,1024){ rep(j,1024)Cnt[i] += cnt[j][i]; } long long ans = get(Cnt); //cout<<ans<<endl; rep(i,1024){ ans -= get(cnt[i]); } cout<<ans%998244353<<endl; return 0; }