結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー fumofumofunifumofumofuni
提出日時 2020-12-01 14:38:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 3,500 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 206,236 KB
実行使用メモリ 331,352 KB
最終ジャッジ日時 2023-09-03 03:29:23
合計ジャッジ時間 49,043 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
331,048 KB
testcase_01 AC 131 ms
331,132 KB
testcase_02 AC 132 ms
331,048 KB
testcase_03 AC 135 ms
331,044 KB
testcase_04 AC 142 ms
331,140 KB
testcase_05 AC 133 ms
331,116 KB
testcase_06 AC 132 ms
331,044 KB
testcase_07 AC 137 ms
331,092 KB
testcase_08 AC 151 ms
331,044 KB
testcase_09 AC 140 ms
331,084 KB
testcase_10 AC 137 ms
331,140 KB
testcase_11 AC 135 ms
331,140 KB
testcase_12 AC 134 ms
331,072 KB
testcase_13 AC 134 ms
331,064 KB
testcase_14 AC 135 ms
331,068 KB
testcase_15 AC 134 ms
331,084 KB
testcase_16 AC 134 ms
331,084 KB
testcase_17 AC 134 ms
331,080 KB
testcase_18 AC 136 ms
331,088 KB
testcase_19 AC 136 ms
331,132 KB
testcase_20 AC 132 ms
331,040 KB
testcase_21 AC 134 ms
331,256 KB
testcase_22 AC 133 ms
331,192 KB
testcase_23 AC 135 ms
331,252 KB
testcase_24 AC 139 ms
331,092 KB
testcase_25 AC 135 ms
331,060 KB
testcase_26 AC 146 ms
331,116 KB
testcase_27 AC 162 ms
331,064 KB
testcase_28 AC 139 ms
331,212 KB
testcase_29 AC 143 ms
331,048 KB
testcase_30 AC 137 ms
331,104 KB
testcase_31 AC 133 ms
331,136 KB
testcase_32 AC 162 ms
331,164 KB
testcase_33 AC 133 ms
331,028 KB
testcase_34 AC 158 ms
331,120 KB
testcase_35 AC 135 ms
331,044 KB
testcase_36 AC 133 ms
331,056 KB
testcase_37 AC 134 ms
331,160 KB
testcase_38 AC 133 ms
331,068 KB
testcase_39 AC 134 ms
331,164 KB
testcase_40 AC 136 ms
331,096 KB
testcase_41 AC 137 ms
331,352 KB
testcase_42 AC 137 ms
331,092 KB
testcase_43 AC 136 ms
331,092 KB
testcase_44 AC 134 ms
331,044 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 AC 141 ms
331,108 KB
04_evil_A_07 AC 142 ms
331,208 KB
04_evil_A_08 AC 140 ms
331,144 KB
04_evil_A_09 AC 140 ms
331,100 KB
04_evil_A_10 AC 141 ms
331,104 KB
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 RE -
06_evil_C_02 RE -
06_evil_C_03 RE -
06_evil_C_04 RE -
06_evil_C_05 RE -
06_evil_C_06 RE -
06_evil_C_07 RE -
06_evil_C_08 RE -
06_evil_C_09 RE -
06_evil_C_10 AC 134 ms
331,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=(r)-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int mod = MOD9;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  bool operator==(const mint &p) const { return x == p.x; }
  bool operator!=(const mint &p) const { return x != p.x; }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[40][1024][1024];//j=末尾、k=xor;

int main(){
    rep(i,40)rep(j,1024)rep(k,1024)dp[i][j][k]=0;
    ll n,k,x,y;cin >> n >> k >> x >> y;
    set<ll> st;rep(i,k){
        ll p;cin >> p;st.insert(p);
    }

    if(n==2){
        mint ans=0;
        for(auto p:st){
            for(auto q:st){
                if(p==q)continue;
                ll t=p^q;
                if(x<=t&&t<=y)ans+=1;
            }
        }
        cout << ans <<endl;
        return 0;
    }

    if(n==4){
        mint ans=0;
        mint ep[n+1][1024];rep(i,n+1)rep(j,1024)ep[i][j]=0;
        ep[0][0]=1;
        rep(i,4)rep(j,1024)for(auto p:st)ep[i+1][j^p]+=ep[i][j];
        rep(i,1024)if(x<=i&&i<=y)ans+=ep[4][i];
        rep(i,1024)if(x<=i&&i<=y)ans-=ep[2][i]*3*st.size();
        rep(i,1024)if(x<=i&&i<=y)ans+=ep[2][i]*2;
        if(x==0)ans-=st.size();
        cout << ans <<endl;
        return 0;
    }

    for(auto p:st)dp[0][p][p]=1;
    rep(i,n-1){
        for(auto j:st){
            rep(k,1024){
                for(auto p:st){
                    if(j==p)continue;
                    dp[i+1][p][k^p]+=dp[i][j][k];
                }
            }
        }
    }
    mint ans=0;
    rep(j,1024)rep(k,1024){
        if(x<=k&&k<=y)ans+=dp[n-1][j][k];
    }
    cout << ans <<endl;
}
0