結果
| 問題 | No.1772 Many DELETEQs |
| ユーザー |
hitonanode
|
| 提出日時 | 2021-11-23 20:00:50 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 163 ms / 3,500 ms |
| コード長 | 1,188 bytes |
| 記録 | |
| コンパイル時間 | 5,157 ms |
| コンパイル使用メモリ | 264,748 KB |
| 実行使用メモリ | 74,840 KB |
| 最終ジャッジ日時 | 2026-06-24 10:11:28 |
| 合計ジャッジ時間 | 8,277 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
ソースコード
#include "testlib.h"
#include <iostream>
#include <vector>
#include <atcoder/modint>
using namespace std;
constexpr int D = 4000;
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
vector dp(D + 1, vector<atcoder::modint998244353>(D + 1)); // dp[x][y]: 最少で AB x 個 BA y 個で作れる列の個数
dp[0][0] = 1;
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];
}
}
for (int i = 1; i < int(dp.size()); ++i) {
for (int j = 1; j < int(dp[i].size()); ++j) dp[i][j] += dp[i - 1][j - 1];
}
int Q = inf.readInt(1, 200000);
inf.readEoln();
cin.tie(nullptr);
ios::sync_with_stdio(false);
while (Q--) {
int x = inf.readInt(1, 4000);
inf.readSpace();
int y = inf.readInt(1, 4000);
inf.readEoln();
cout << dp.at(x).at(y).val() << '\n';
}
inf.readEof();
}
hitonanode