結果
| 問題 |
No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2020-05-29 22:13:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 290 ms / 2,000 ms |
| コード長 | 921 bytes |
| コンパイル時間 | 2,173 ms |
| コンパイル使用メモリ | 208,412 KB |
| 最終ジャッジ日時 | 2025-01-10 17:34:33 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | for(int i=0;i<N;i++)scanf("%lld",&A[i]);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#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;
}
沙耶花