結果
問題 | No.1304 あなたは基本が何か知っていますか?私は知っています. |
ユーザー | pes_magic |
提出日時 | 2020-12-14 22:04:06 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,510 bytes |
コンパイル時間 | 1,253 ms |
コンパイル使用メモリ | 96,672 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 16:29:21 |
合計ジャッジ時間 | 10,253 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 3 ms
6,940 KB |
testcase_04 | WA | - |
testcase_05 | AC | 3 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 5 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 5 ms
6,940 KB |
testcase_10 | AC | 4 ms
6,940 KB |
testcase_11 | AC | 4 ms
6,940 KB |
testcase_12 | AC | 5 ms
6,940 KB |
testcase_13 | AC | 3 ms
6,940 KB |
testcase_14 | AC | 4 ms
6,944 KB |
testcase_15 | AC | 3 ms
6,940 KB |
testcase_16 | AC | 5 ms
6,944 KB |
testcase_17 | AC | 3 ms
6,940 KB |
testcase_18 | AC | 4 ms
6,944 KB |
testcase_19 | AC | 3 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 3 ms
6,940 KB |
testcase_22 | AC | 5 ms
6,944 KB |
testcase_23 | AC | 5 ms
6,940 KB |
testcase_24 | AC | 5 ms
6,944 KB |
testcase_25 | AC | 2 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 3 ms
6,944 KB |
testcase_28 | AC | 3 ms
6,940 KB |
testcase_29 | AC | 3 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | AC | 3 ms
6,944 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 3 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | AC | 3 ms
6,940 KB |
testcase_38 | AC | 2 ms
6,940 KB |
testcase_39 | AC | 2 ms
6,940 KB |
testcase_40 | AC | 3 ms
6,940 KB |
testcase_41 | AC | 3 ms
6,944 KB |
testcase_42 | AC | 3 ms
6,944 KB |
testcase_43 | AC | 3 ms
6,944 KB |
testcase_44 | AC | 2 ms
6,940 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 | WA | - |
06_evil_C_02 | WA | - |
06_evil_C_03 | WA | - |
06_evil_C_04 | WA | - |
06_evil_C_05 | WA | - |
06_evil_C_06 | WA | - |
06_evil_C_07 | WA | - |
06_evil_C_08 | WA | - |
06_evil_C_09 | WA | - |
06_evil_C_10 | AC | 1 ms
6,940 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MOD = 998244353; long long modPow(long long a, long long p){ if(p == 0) return 1; auto res = modPow(a, p/2); res = (res*res)%MOD; if(p%2) res = (res*a)%MOD; return res; } long long calcInv(long long a){ return modPow(a, MOD-2); } int main(){ const int maxSize = 1024; vector<long long> inv(maxSize); vector<long long> fact(maxSize); vector<long long> factInv(maxSize); for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1; for(int i=2;i<maxSize;i++){ inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; fact[i] = fact[i-1] * i % MOD; factInv[i] = factInv[i-1] * inv[i] % MOD; } auto comb = [&](int n, int r){ if(n < r || r < 0) return 0LL; return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD; }; auto perm = [&](int n, int r){ if(n < r || r < 0) return 0LL; return fact[n] * factInv[n-r] % MOD; }; int N, K, X, Y; while(cin >> N >> K >> X >> Y){ X = min(X, 1023); Y = min(Y, 1023); vector<int> A(K); for(auto& t : A) cin >> t; sort(A.begin(), A.end()); A.erase(unique(A.begin(), A.end()), A.end()); vector valid(N+1, vector(1024, 0)); valid[0][0] = 1; for(auto& v : A){ for(int i=N-1;i>=0;i--){ for(int j=0;j<1024;j++) valid[i+1][j^v] = (valid[i+1][j^v] + valid[i][j]) % MOD; } } vector dp(2, vector(A.size()+1, 0LL)); dp[1][0] = 1; for(int i=0;i<N;i++){ vector next(2, vector(A.size()+1, 0LL)); for(int j=0;j<=A.size();j++){ int n0 = A.size() - j; int n1 = j; if(n0 > 0){ next[1][n1+1] += n0 * dp[1][n1] + (n0-1) * dp[0][n1]; next[1][n1+1] %= MOD; } if(n1 > 0){ next[0][n1-1] += n1 * dp[0][n1] + (n1-1) * dp[1][n1]; next[0][n1-1] %= MOD; } } dp = next; } long long res = 0; for(int i=0;i<=N;i++){ if(i >= dp[0].size()) break; auto pat = (dp[0][i] + dp[1][i]) % MOD; for(int j=X;j<=Y;j++){ res += pat * valid[i][j] % MOD * calcInv(comb(A.size(), i)); res %= MOD; } } cout << res << endl; } }