結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー carrot46
提出日時 2020-12-01 12:57:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 3,091 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 179,244 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 10:05:59
合計ジャッジ時間 8,945 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 44 RE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);
template<class T> bool chmin(T &a, const T &b){
if(a > b) {a = b; return true;}
else return false;
}
template<class T> bool chmax(T &a, const T &b){
if(a < b) {a = b; return true;}
else return false;
}
template <unsigned long long mod > class modint{
public:
ll x;
constexpr modint(){x = 0;}
constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){}
constexpr modint set_raw(ll _x){
//_x in [0, mod)
x = _x;
return *this;
}
constexpr modint operator-(){
return x == 0 ? 0 : mod - x;
}
constexpr modint& operator+=(const modint& a){
if((x += a.x) >= mod) x -= mod;
return *this;
}
constexpr modint operator+(const modint& a) const{
return modint(*this) += a;
}
constexpr modint& operator-=(const modint& a){
if((x -= a.x) < 0) x += mod;
return *this;
}
constexpr modint operator-(const modint& a) const{
return modint(*this) -= a;
}
constexpr modint& operator*=(const modint& a){
(x *= a.x)%=mod;
return *this;
}
constexpr modint operator*(const modint& a) const{
return modint(*this) *= a;
}
constexpr modint pow(unsigned long long pw) const{
modint res(1), comp(*this);
while(pw){
if(pw&1) res *= comp;
comp *= comp;
pw >>= 1;
}
return res;
}
//mod
constexpr modint inv() const{
if(x == 2) return (mod + 1) >> 1;
return modint(*this).pow(mod - 2);
}
constexpr modint& operator/=(const modint &a){
(x *= a.inv().x)%=mod;
return *this;
}
constexpr modint operator/(const modint &a) const{
return modint(*this) /= a;
}
};
#define mod1 998244353
using mint = modint<mod1>;
ostream& operator<<(ostream& os, const mint& a){
os << a.x;
return os;
}
using vm = vector<mint>;
int main(){
ll X, Y;
cin>>N>>K>>X>>Y;
vector<vm> dp(N + 1, vm(1024, 0));
vec a(K);
rep(i, K) cin>>a[i];
sort(ALL(a));
a.erase(unique(ALL(a)), a.end());
K = a.size();
dp[0][0] = 1;
rep(i, N){
rep(j, 1024){
if(i >= 2) dp[i][j] -= dp[i-2][j] * (K - (i > 2)); //onaji 3renzoku sudeni nai
if(dp[i][j].x == 0) continue;
rep(k, K) dp[i+1][j ^ a[k]] += dp[i][j];
}
//rep(j, 16) cout<<dp[i][j]<<" \n"[j == 15];
}
mint res(0);
reps(j, X, min(Y + 1, 1024LL)) res += dp[N][j] - dp[N-2][j] * (K - (N > 2));
cout<<res<<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0