結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー 蜜蜂
提出日時 2021-03-19 22:55:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,046 bytes
コンパイル時間 1,789 ms
コンパイル使用メモリ 170,900 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-22 03:07:46
合計ジャッジ時間 8,210 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 45 RE * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
 
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;
 
#define fi first
#define se second
#define pb push_bacsize
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)

constexpr ll mod = 998244353;

int main(){
  int n,size,x,y;
  cin>>n>>size>>x>>y;

  vi a(size);
  rep(i,0,size){
    cin>>a[i];
  }
  sort(all(a));

	vvll dp(n+2,vll(1024,0));
	dp[0][0]=1;
  rep(i,0,size){
    dp[1][a[i]]++;
  }

  rep(i,0,1024){
    rep(j,0,size){
      dp[2][i]+=dp[1][(i^a[j])];
    }
    dp[2][i]-=dp[0][i]*size;
  }


	rep(i,3,n+1){
		rep(j,0,1024){
      rep(k,0,size){
        dp[i][j]+=dp[i-1][(j^a[k])];
      }		 
			dp[i][j]-=dp[i-2][j]*(size-1);
      dp[i][j]%=mod;
		}
	}

  ll ans=0;
  rep(i,x,y+1){
    ans+=dp[n][i];
    ans%=mod;
  }

  cout<<ans<<endl;
}
0