結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー mfbgjsczmfbgjscz
提出日時 2020-05-29 19:17:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 2,086 bytes
コンパイル時間 2,057 ms
コンパイル使用メモリ 179,732 KB
実行使用メモリ 331,520 KB
最終ジャッジ日時 2024-04-23 19:08:53
合計ジャッジ時間 5,849 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 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 2 ms
5,376 KB
testcase_11 AC 211 ms
209,792 KB
testcase_12 AC 142 ms
127,616 KB
testcase_13 AC 276 ms
292,480 KB
testcase_14 AC 152 ms
162,688 KB
testcase_15 AC 66 ms
65,152 KB
testcase_16 AC 63 ms
51,072 KB
testcase_17 AC 12 ms
12,544 KB
testcase_18 AC 167 ms
169,984 KB
testcase_19 AC 167 ms
179,968 KB
testcase_20 AC 92 ms
69,888 KB
testcase_21 AC 357 ms
331,520 KB
testcase_22 AC 356 ms
331,520 KB
testcase_23 AC 356 ms
331,520 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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;
  queue<lli>que;
  Vec(A,lli,N,0);//A'[i]=A[i]-1;
  Vec(RuiP,lli,N+1,1);//前からA_iの累積積
  DV(RuiF,lli,N+1,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;
  }
  rep(i,0,N+1)RuiF[i].resize(N+1);
  while(K--){
    int l,r,p;
    cin >> l >> r >> p;
    sum=0;
    rep(i,l-1,r){
      int ng=-1,ok=N+1;
      while(ok-ng>1){
        int mid=(ok+ng)/2;
        if(A[mid]>i)ok=mid;
        else ng=mid;
      }
      sum^=(RuiP[ok]*RuiF[ok][p]%mod);
    }
    que.push(sum%mod);
  }
  /*rep(i,0,N+1)cout << RuiP[i] << " ";
  Out("");
  rep(i,0,N+1){
    for(auto v:RuiF[i])cout << v << " ";
    Out("");
  }*/
  while(!que.empty()){
    Out(que.front());
    que.pop();
  }
}
0