結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー 沙耶花沙耶花
提出日時 2020-05-29 22:13:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 2,754 ms
コンパイル使用メモリ 208,196 KB
実行使用メモリ 144,640 KB
最終ジャッジ日時 2024-04-23 22:51:15
合計ジャッジ時間 4,963 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 167 ms
91,904 KB
testcase_12 AC 109 ms
56,576 KB
testcase_13 AC 230 ms
127,616 KB
testcase_14 AC 128 ms
71,552 KB
testcase_15 AC 52 ms
29,696 KB
testcase_16 AC 47 ms
23,680 KB
testcase_17 AC 10 ms
7,552 KB
testcase_18 AC 133 ms
74,752 KB
testcase_19 AC 138 ms
79,232 KB
testcase_20 AC 67 ms
31,744 KB
testcase_21 AC 272 ms
144,384 KB
testcase_22 AC 268 ms
144,640 KB
testcase_23 AC 270 ms
144,640 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

int main(){
	
	int N,Q;
	cin>>N>>Q;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++)scanf("%lld",&A[i]);
	sort(A.rbegin(),A.rend());
	
	vector<vector<int>> dp(N+1,vector<int>(N+1,0));
	dp[0][0] = 1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=N;j++){
			dp[i+1][j] = mod(dp[i+1][j] + mod(dp[i][j]*mod(A[i]-1)));
			if(j!=N)dp[i+1][j+1] = mod(dp[i+1][j+1]+dp[i][j]);
		}
	}
	
	
	
	sort(A.begin(),A.end());
	
	vector<int> S(N+1,1);
	for(int i=0;i<N;i++){
		S[i+1] = mod(S[i]*A[i]);
	}
	
	for(int i=0;i<Q;i++){
		int l,r,p;
		cin>>l>>r>>p;
		int ans = 0;
		int t = 0;
		for(int j=l;j<=r;j++){
			int ind = distance(lower_bound(A.begin(),A.end(),j),A.end());
			int t = dp[ind][p];
			t = mod(t * S[N-ind]);
			ans ^=t;
			
		}
		cout<<mod(ans)<<endl;
	}
	
	return 0;
}
0