結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー mfbgjsczmfbgjscz
提出日時 2020-05-29 17:44:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,807 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 177,192 KB
実行使用メモリ 144,384 KB
最終ジャッジ日時 2024-04-25 14:51:44
合計ジャッジ時間 5,863 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(A,lli,N,0);//A'[i]=A[i]-1;
  Vec(RuiP,lli,N+1,1);//前からA_iの累積積
  DV(RuiF,lli,N,0,0);//後ろから多項式の累積積
  rep(i,0,N)cin >> A[i];
  Sort(A);
  rep(i,0,N)RuiP[i+1]=RuiP[i]*A[i]%mod;
  RuiF[N].pb(1);
  rrep(i,N,0){
    H=RuiF[i+1].size();
    RuiF[i].resize(H+1);
    rep(j,0,H)RuiF[i][j]=RuiF[i+1][j]*(A[i]-1)%mod;
    rep(j,0,H)RuiF[i][j+1]=(RuiF[i][j+1]+RuiF[i+1][j])%mod;
  }
  while(K--){
    int l,r,p;
    cin >> l >> r >> p;
    int ng=0,ok=N+1;
    while(ok-ng>1){
      int mid=(ok+ng)/2;
      if(A[mid]>l)ok=mid;
      else ng=mid;
    }
    sum=0;
    rep(i,l-1,r)sum^=RuiP[ok]*RuiF[ok][p]%mod;
    Out(sum%mod);
  }
}
0