結果
| 問題 |
No.3215 Make K types-able
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-25 21:45:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,838 bytes |
| コンパイル時間 | 1,923 ms |
| コンパイル使用メモリ | 198,448 KB |
| 実行使用メモリ | 33,116 KB |
| 最終ジャッジ日時 | 2025-07-25 21:45:13 |
| 合計ジャッジ時間 | 4,760 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 998244353;
const int N = 200005;
const int INF = 0x3f3f3f3f;
ll powmod(ll x, ll y) {
ll res = 1;
while (y) {
if (y & 1) res = res * x % mod;
y >>= 1;
x = x * x % mod;
}
return res;
}
ll pw[N], c[N], c2[N];
ll f[N][15];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _;
cin >> _;
vector<pair<int, int>> qu;
int maxn = 0, maxk = 0;
for (int i = 0; i < _; i++) {
int n, k;
cin >> n >> k;
maxn = max(maxn, n);
maxk = max(maxk, k - 1);
qu.push_back({n, k});
}
pw[0] = 1;
for (int i = 1; i <= maxn; i++) pw[i] = pw[i - 1] * 2 % (mod - 1);
for (int i = 2; i <= maxn; i++) {
ll e = pw[i - 1] - 2;
if (e < 0) e += mod - 1;
c[i] = e;
}
for (int i = 2; i <= maxn; i++) c2[i] = powmod(2, c[i]);
if (maxk >= 1) f[1][1] = 1;
for (int h = 2; h <= maxn; h++) {
for (int k = 0; k <= maxk; k++) {
ll s = 0;
for (int i = 0; i <= k; i++) {
ll A = (i == 0 ? (1ll * c2[h] + f[h - 1][0]) % mod : f[h - 1][i]);
ll B = (k - i == 0 ? (1ll * c2[h] + f[h - 1][0]) % mod : f[h - 1][k - i]);
s = (s + A * B) % mod;
}
f[h][k] = s;
}
}
for (auto [n, k] : qu) {
if (k - 1 < 0 || k - 1 > maxn) {
cout << "0\n";
continue;
}
if (k >= 2) {
cout << f[n][k - 1] << "\n";
} else {
ll ans = f[n][0];
if (n >= 2) {
ans = (ans + c2[n]) % mod;
} else {
ans = (ans + 1) % mod;
}
cout << ans << "\n";
}
}
return 0;
}