結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー kk
提出日時 2021-04-23 03:28:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 2,638 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 209,988 KB
実行使用メモリ 39,020 KB
最終ジャッジ日時 2023-09-03 04:17:41
合計ジャッジ時間 39,703 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
38,876 KB
testcase_01 AC 45 ms
26,512 KB
testcase_02 AC 27 ms
24,108 KB
testcase_03 AC 287 ms
24,032 KB
testcase_04 AC 38 ms
23,856 KB
testcase_05 AC 31 ms
23,784 KB
testcase_06 AC 28 ms
39,020 KB
testcase_07 AC 34 ms
19,480 KB
testcase_08 AC 66 ms
26,648 KB
testcase_09 AC 34 ms
23,848 KB
testcase_10 AC 32 ms
19,544 KB
testcase_11 AC 34 ms
24,092 KB
testcase_12 AC 33 ms
23,868 KB
testcase_13 AC 30 ms
24,116 KB
testcase_14 AC 32 ms
26,632 KB
testcase_15 AC 31 ms
23,788 KB
testcase_16 AC 32 ms
19,640 KB
testcase_17 AC 49 ms
19,728 KB
testcase_18 AC 32 ms
19,408 KB
testcase_19 AC 28 ms
19,644 KB
testcase_20 AC 27 ms
19,412 KB
testcase_21 AC 51 ms
19,420 KB
testcase_22 AC 33 ms
19,412 KB
testcase_23 AC 34 ms
19,560 KB
testcase_24 AC 34 ms
19,412 KB
testcase_25 AC 121 ms
19,556 KB
testcase_26 AC 67 ms
19,468 KB
testcase_27 AC 66 ms
19,400 KB
testcase_28 AC 81 ms
19,412 KB
testcase_29 AC 65 ms
19,548 KB
testcase_30 AC 96 ms
19,536 KB
testcase_31 AC 156 ms
19,400 KB
testcase_32 AC 66 ms
19,400 KB
testcase_33 AC 117 ms
19,472 KB
testcase_34 AC 68 ms
19,524 KB
testcase_35 AC 98 ms
19,412 KB
testcase_36 AC 133 ms
19,472 KB
testcase_37 AC 99 ms
19,460 KB
testcase_38 AC 98 ms
19,404 KB
testcase_39 AC 174 ms
19,400 KB
testcase_40 AC 100 ms
19,468 KB
testcase_41 AC 172 ms
19,732 KB
testcase_42 AC 102 ms
19,504 KB
testcase_43 AC 99 ms
19,468 KB
testcase_44 AC 134 ms
19,400 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 RE -
04_evil_A_07 RE -
04_evil_A_08 RE -
04_evil_A_09 RE -
04_evil_A_10 RE -
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 TLE -
06_evil_C_02 TLE -
06_evil_C_03 TLE -
06_evil_C_04 TLE -
06_evil_C_05 TLE -
06_evil_C_06 TLE -
06_evil_C_07 TLE -
06_evil_C_08 TLE -
06_evil_C_09 TLE -
06_evil_C_10 AC 18 ms
38,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

template<typename T,T MOD>
struct mod_int{
  T v;
  mod_int(): v(0) {}
  mod_int(T t) { v=t%MOD; if(v<0) v+=MOD; }
  
  mod_int inv() const {
    T a=v, b=MOD, u=1, v=0;
		while (b>0) { T t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
  }
  
  mod_int pow(long long p) const {
    mod_int ret = 1, base(v);
    while (p > 0) {
      if (p & 1)
        ret *= base;
      base *= base;
      p >>= 1;
    }
    return ret;
  }
  
  mod_int& operator+=(const mod_int &a) { v+=a.v; if(v>=MOD)v-=MOD; return *this; }
  mod_int& operator-=(const mod_int &a) { v+=MOD-a.v; if(v>=MOD)v-=MOD; return *this; }
  mod_int& operator*=(const mod_int &a) { v=v*a.v%MOD; return *this; }
  mod_int& operator/=(const mod_int &a) { return (*this)*=a.inv(); }
  
  mod_int operator+(const mod_int &a) const { return mod_int(v)+=a; }
  mod_int operator-(const mod_int &a) const { return mod_int(v)-=a; }
  mod_int operator*(const mod_int &a) const { return mod_int(v)*=a; }
  mod_int operator/(const mod_int &a) const { return mod_int(v)/=a; }
  
  friend mod_int operator+(T x, const mod_int& m) { return mod_int(x)+m; }
  friend mod_int operator-(T x, const mod_int& m) { return mod_int(x)-m; }
  friend mod_int operator*(T x, const mod_int& m) { return mod_int(x)*m; }
  friend mod_int operator/(T x, const mod_int& m) { return mod_int(x)/m; }
  
  mod_int operator-() const{ return v?mod_int(MOD-v):mod_int(v); }
  
  bool operator==(const mod_int &a) const { return v==a.v; }
  bool operator!=(const mod_int &a) const { return v!=a.v; }
  bool operator<(const mod_int &a) const { return v <a.v; }
  
	friend istream& operator>>(istream& is, mod_int& m){ T t; is>>t; m=mod_int(t); return is; }
	friend ostream& operator<<(ostream& os,const mod_int& m){ return os<<m.v; }
};

using mint = mod_int<long long, 998244353>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, k, x, y;
  cin >> n >> k >> x >> y;

  vector<int> a(k);
  for (int i = 0; i < k; i++)
    cin >> a[i];

  vector<vector<mint> > cur(1024, vector<mint>(1025));
  cur[0][1024] = 1;
  for (int t = 0; t < n; t++) {
    vector<vector<mint> > nxt(1024, vector<mint>(1025));
    for (int i = 0; i < 1024; i++) {
      mint sum = 0;
      for (int j = 0; j <= 1024; j++)
        sum += cur[i][j];

      if (sum != 0) {
        for (int j = 0; j < a.size(); j++) {
          nxt[i^a[j]][a[j]] += sum - cur[i][a[j]];
        }
      }
    }
    cur = nxt;
  }

  mint ret = 0;
  for (int i = x; i <= y; i++) {
    for (int j = 0; j < 1024; j++)
      ret += cur[i][j];
  }
  cout << ret << endl;

  return 0;
}
0