結果

問題 No.1772 Many DELETEQs
ユーザー 沙耶花
提出日時 2021-12-03 00:22:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 609 ms / 3,500 ms
コード長 918 bytes
コンパイル時間 4,036 ms
コンパイル使用メモリ 249,656 KB
最終ジャッジ日時 2025-01-26 02:58:12
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:44:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   44 |                 scanf("%d %d",&x,&y);
      |                 ~~~~~^~~~~~~~~~~~~~~

ソースコード

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