結果

問題 No.1772 Many DELETEQs
ユーザー 沙耶花沙耶花
提出日時 2021-12-03 00:22:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 449 ms / 3,500 ms
コード長 918 bytes
コンパイル時間 4,348 ms
コンパイル使用メモリ 259,876 KB
実行使用メモリ 191,492 KB
最終ジャッジ日時 2023-09-18 11:42:25
合計ジャッジ時間 8,825 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 374 ms
191,436 KB
testcase_01 AC 373 ms
191,380 KB
testcase_02 AC 373 ms
191,440 KB
testcase_03 AC 447 ms
191,492 KB
testcase_04 AC 449 ms
191,456 KB
testcase_05 AC 449 ms
191,444 KB
testcase_06 AC 426 ms
191,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001

mint dp[4005][4005];
mint sum[8005][4005];
int main(){
	
	
	dp[0][0] = 1;
	
	rep(i,4005){
		rep(j,4005){
			if(i!=4004)dp[i+1][j] += dp[i][j];
			if(j!=4004)dp[i][j+1] += dp[i][j];
			if(i!=4004&&j!=4004)dp[i+1][j+1] += dp[i][j]*2;
		}
	}
	
	int center = 4002;
	
	rep(i,4001){
		rep(j,4001){
			sum[i-j + center][i] += dp[i][j];
		}
	}
	
	rep(i,8005){
		rep(j,4004){
			sum[i][j+1] += sum[i][j];
		}
	}
	
	int q;
	cin>>q;
	
	rep(_,q){
		int x,y;
		scanf("%d %d",&x,&y);
		mint ans = 0;
		
		int t = x-y;
		
		int l = max(0,t);
		int r = min(x,t+y);
		t += center;
		//cout<<l<<','<<r<<endl;
		if(l<=r){
			ans += sum[t][r];
			if(l!=0)ans -= sum[t][l-1];
		}
		
		printf("%d\n",ans.val());
	}
			
	
	return 0;
}
0