結果

問題 No.1771 A DELETEQ
コンテスト
ユーザー 👑 Nachia
提出日時 2021-12-03 00:27:49
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 70 ms / 3,500 ms
コード長 865 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,105 ms
コンパイル使用メモリ 78,460 KB
実行使用メモリ 66,176 KB
最終ジャッジ日時 2026-06-24 11:29:52
合計ジャッジ時間 4,200 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}




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

0