結果
問題 | No.1068 #いろいろな色 / Red and Blue and more various colors (Hard) |
ユーザー | otamay6 |
提出日時 | 2020-05-29 22:29:19 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,113 bytes |
コンパイル時間 | 2,066 ms |
コンパイル使用メモリ | 179,236 KB |
実行使用メモリ | 359,316 KB |
最終ジャッジ日時 | 2024-11-06 05:53:31 |
合計ジャッジ時間 | 32,230 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 30 ms
10,624 KB |
testcase_04 | AC | 23 ms
8,960 KB |
testcase_05 | AC | 25 ms
9,984 KB |
testcase_06 | AC | 19 ms
8,192 KB |
testcase_07 | AC | 18 ms
7,680 KB |
testcase_08 | AC | 24 ms
9,344 KB |
testcase_09 | AC | 27 ms
10,368 KB |
testcase_10 | AC | 12 ms
6,820 KB |
testcase_11 | AC | 17 ms
7,680 KB |
testcase_12 | AC | 11 ms
6,816 KB |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | RE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | AC | 1,204 ms
359,272 KB |
testcase_30 | AC | 1,178 ms
359,316 KB |
testcase_31 | AC | 2 ms
6,820 KB |
ソースコード
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(auto& (a): (b)) #define all(v) (v).begin(),(v).end() #define len(v) (int)(v).size() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define cmx(x,y) x=max(x,y) #define cmn(x,y) x=min(x,y) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<<endl #define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl #define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl #define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl #define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl #define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl #define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl using namespace std; typedef pair<int,int> P; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<double> vd; typedef vector<P> vp; typedef vector<string> vs; const int MAX_N = 200005; #define MOD 998244353 #define root 5 unsigned int add(const unsigned int x, const unsigned int y) { return (x + y < MOD) ? x + y : x + y - MOD; } unsigned int sub(const unsigned int x, const unsigned int y) { return (x >= y) ? (x - y) : (MOD - y + x); } unsigned int mul(const unsigned int x, const unsigned int y) { return (unsigned long long)x * y % MOD; } unsigned int mod_pow(unsigned int x, unsigned int n) { unsigned int res = 1; while(n > 0){ if(n & 1){ res = mul(res, x); } x = mul(x, x); n >>= 1; } return res; } unsigned int inverse(const unsigned int x) { return mod_pow(x, MOD - 2); } void ntt(vector<int>& a, const bool rev = false) { unsigned int i, j, k, l, p, q, r, s; const unsigned int size = a.size(); if(size == 1) return; vector<int> b(size); r = rev ? (MOD - 1 - (MOD - 1) / size) : (MOD - 1) / size; s = mod_pow(root, r); vector<unsigned int> kp(size / 2 + 1, 1); for(i = 0; i < size / 2; ++i) kp[i + 1] = mul(kp[i], s); for(i = 1, l = size / 2; i < size; i <<= 1, l >>= 1){ for(j = 0, r = 0; j < l; ++j, r += i){ for(k = 0, s = kp[i * j]; k < i; ++k){ p = a[k + r], q = a[k + r + size / 2]; b[k + 2 * r] = add(p, q); b[k + 2 * r + i] = mul(sub(p, q), s); } } swap(a, b); } if(rev){ s = inverse(size); for(i = 0; i < size; i++){ a[i] = mul(a[i], s); } } } vector<int> convolute(const vector<int>& a, const vector<int>& b) { const int size = (int)a.size() + (int)b.size() - 1; int t = 1; while (t < size) { t <<= 1; } vector<int> A(t, 0), B(t, 0); for (int i = 0; i < (int)a.size(); i++) { A[i] = a[i]; } for (int i = 0; i < (int)b.size(); i++) { B[i] = b[i]; } ntt(A), ntt(B); for (int i = 0; i < t; i++) { A[i] = mul(A[i], B[i]); } ntt(A, true); A.resize(size); return A; } bool used[MAX_N]; int inv[MAX_N],fac[MAX_N],finv[MAX_N]; void make() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for(int i=2;i<MAX_N;i++){ inv[i] = MOD - (ll)inv[MOD%i] * (MOD/i) % MOD; fac[i] = (ll)fac[i-1] * i % MOD; finv[i] = (ll)finv[i-1] * inv[i] % MOD; } } int comb(int a,int b) { if(a<b){ return 0; } return fac[a] * ((ll)finv[b] * finv[a-b] % MOD) % MOD; } int main() { int N,Q; cin>>N>>Q; vector<int> A(N); for(int i=0;i<N;++i) cin>>A[i]; vector<vector<vector<int>>> f(30,vector<vector<int>>(N+1,vector<int>(1,1))); rep(i,N) f[0][i] = {A[i]-1,1}; int dan = 0,cnt = N; while(cnt>=2){ int l = 0; while(2*l<cnt){ f[dan+1][l] = convolute(f[dan][2*l], f[dan][2*l+1]); l++; } dan++; cnt = (cnt+1)/2; } rep(_,Q){ int B;cin>>B; cout<<f[dan][0][B]<<"\n"; } }