結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー KKT89
提出日時 2020-12-01 01:54:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 796 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 206,848 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-06-22 02:26:46
合計ジャッジ時間 6,806 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31 WA * 23 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

constexpr ll mod=998244353;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k,x,y; cin >> n >> k >> x >> y;
	vector<int> a(k);
	for(int i=0;i<k;i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()),a.end());
	k=a.size();
	vector<vector<ll>> dp(n,vector<ll>(k,0));
	for(int i=0;i<k;i++){
		dp[0][i]=1;
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<k;j++){
			if(dp[i-1][j]==0)continue;
			for(int nx=0;nx<k;nx++){
				if(j==nx)continue;
				if((a[j]^a[nx])<=y and x<=(a[j]^a[nx])){
					dp[i][nx]+=dp[i-1][j];
					if(dp[i][nx]>=mod){
						dp[i][nx]-=mod;
					}
				}
			}
		}
	}
	ll res=0;
	for(int i=0;i<k;i++){
		res+=dp[n-1][i];
		res%=mod;
	}
	cout << res << endl;
}
0