結果
| 問題 |
No.1771 A DELETEQ
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2021-11-23 12:00:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 112 ms / 3,500 ms |
| コード長 | 1,096 bytes |
| コンパイル時間 | 684 ms |
| コンパイル使用メモリ | 76,856 KB |
| 最終ジャッジ日時 | 2025-01-26 00:37:02 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 RE * 3 MLE * 8 |
ソースコード
#include <atcoder/modint>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;
template <int md> std::istream &operator>>(std::istream &is, atcoder::static_modint<md> &x) {
long long t;
return is >> t, x = t, is;
}
template <int md> std::ostream &operator<<(std::ostream &os, const atcoder::static_modint<md> &x) { return os << x.val(); }
using mint = atcoder::modint998244353;
int main() {
int X, Y;
cin >> X >> Y;
vector dp(X + 1, vector<mint>(Y + 1)); // dp[x][y]: 最小で AB x 個 BA y 個で作れる列の個数
dp[0][0] = 1;
mint ret = 0;
for (int i = 0; i < int(dp.size()); ++i) {
for (int j = 0; j < int(dp[i].size()); ++j) {
// AA 始まり / BB 始まり
if (i and j) dp[i][j] += dp[i - 1][j - 1] * 2;
// AB 始まり
if (i) dp[i][j] += dp[i - 1][j];
// BA 始まり
if (j) dp[i][j] += dp[i][j - 1];
if (j - i == Y - X) ret += dp[i][j];
}
}
cout << ret.val() << '\n';
}
hitonanode