結果

問題 No.1772 Many DELETEQs
ユーザー 👑 Nachia
提出日時 2021-12-03 00:30:56
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 158 ms / 3,500 ms
コード長 1,306 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 112,224 KB
最終ジャッジ日時 2025-01-26 02:58:55
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/modint>

using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)

using m32 = atcoder::modint998244353;

m32 dp[4001][4001];

/*
int main(){
    int x,y; cin >> x >> y;
    if(4000 < x || 4000 < y) exit(0);
    dp[x][y] = 1;
    m32 ans = 0;
    for(int xx=x; xx>=0; xx--) for(int yy=y; yy>=0; yy--){
        m32 p = dp[xx][yy];
        if(xx == yy) ans += p;
        if(xx != 0) dp[xx-1][yy] += p;
        if(yy != 0) dp[xx][yy-1] += p;
        if(xx != 0 && yy != 0) dp[xx-1][yy-1] += p * 2;
    }
    cout << ans.val() << endl;
    return 0;
}
*/
int main(){
    const int z = 4000;
    dp[0][0] = 1;
    rep(xx,z+1) rep(yy,z+1){
        if(xx != z) dp[xx+1][yy] += dp[xx][yy];
        if(yy != z) dp[xx][yy+1] += dp[xx][yy];
        if(xx != z && yy != z) dp[xx+1][yy+1] += dp[xx][yy] * 2;
    }
    rep(xx,z) rep(yy,z) dp[xx+1][yy+1] += dp[xx][yy];
    int Q; cin >> Q;
    while(Q--){
        int x,y; cin >> x >> y;
        cout << dp[x][y].val() << "\n";
    }
    return 0;
}




struct ios_do_not_sync {
    ios_do_not_sync() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;

0