結果

問題 No.1068 #いろいろな色 / Red and Blue and more various colors (Hard)
ユーザー mfbgjsczmfbgjscz
提出日時 2020-05-20 01:48:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,793 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 171,028 KB
実行使用メモリ 11,116 KB
最終ジャッジ日時 2024-04-23 19:44:47
合計ジャッジ時間 7,836 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
10,752 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 33 ms
5,376 KB
testcase_04 AC 22 ms
5,376 KB
testcase_05 AC 26 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 15 ms
5,376 KB
testcase_08 AC 24 ms
5,376 KB
testcase_09 AC 30 ms
5,376 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 AC 14 ms
5,376 KB
testcase_12 AC 8 ms
5,376 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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(25) << 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))
lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
Vec(P,lli,200000,0);    
vector<lli> divide_and_solve(int left,int right){//f_l(x)からf_r(x)までの積
  if(right-left==1){
    Vec(v,lli,2,1);
    v[1]=P[left];
    return v;
  }
  auto vl=divide_and_solve(left,(left+right)/2);
  auto vr=divide_and_solve((left+right)/2,right);
  int ls=vl.size(),rs=vr.size();
  Vec(marge,lli,ls+rs-1,0);
  rep(i,0,ls)rep(j,0,rs){
    marge[i+j]+=(vl[i]*vr[j])%mod;
    marge[i+j]%=mod;
  }
  return marge;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  Vec(Q,lli,M,0);
  P.resize(N);
  rep(i,0,N){
    cin >> P[i];
    P[i]--;
    P[i]%=mod;
  }
  rep(i,0,M)cin >> Q[i];
  auto ans=divide_and_solve(0,N);
  Rev(ans);
  rep(i,0,M)Out(ans[Q[i]]%mod);
}
0