結果

問題 No.1772 Many DELETEQs
ユーザー 👑 NachiaNachia
提出日時 2021-12-03 00:30:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 162 ms / 3,500 ms
コード長 1,306 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 78,124 KB
実行使用メモリ 66,072 KB
最終ジャッジ日時 2023-09-18 11:53:54
合計ジャッジ時間 2,928 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
65,872 KB
testcase_01 AC 94 ms
66,072 KB
testcase_02 AC 94 ms
65,840 KB
testcase_03 AC 160 ms
66,004 KB
testcase_04 AC 162 ms
65,868 KB
testcase_05 AC 160 ms
65,844 KB
testcase_06 AC 138 ms
65,996 KB
権限があれば一括ダウンロードができます

ソースコード

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