QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#553238#7558. Abstractucup-team1231#WA 0ms3392kbC++142.4kb2024-09-08 11:06:072024-09-08 11:06:08

Judging History

你现在查看的是最新测评结果

  • [2024-09-08 11:06:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3392kb
  • [2024-09-08 11:06:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef long long ll;
const int MOD=998244353;
#define sz(t) int((t).size())
vi operator + (const vi&A,const vi&B) {
    vi C(max(sz(A),sz(B)));
    for(int i=0;i<sz(A);++i) C[i]=A[i];
    for(int i=0;i<sz(B);++i) (C[i]+=B[i])%=MOD;
    return C;
}
int K;
ll qp(ll a,ll b) {
    ll x=1; a%=MOD;
    while(b) {
        if(b&1) x=x*a%MOD;
        a=a*a%MOD; b>>=1;
    }
    return x;
}
const int SZ = 1000005;
ll w[2][SZ];
void fftinit(int n) {
    for(K=1;K<n;K<<=1);
    ll ww=qp(3,(MOD-1)/K);
    w[0][0]=1;
    for(int i=1;i<=K;++i)
        w[0][i]=w[0][i-1]*ww%MOD;
    for(int i=0;i<=K;++i) w[1][i]=w[0][K-i];
}
void fft(int*a,int o) {
    for(int i=0;i<K;++i) {
        int br=i,s=0;
        for(int j=1;j<K;j<<=1)
            s=s*2+br%2,br/=2;
        if(i<s) swap(a[i],a[s]);
    }
    for(int i=2;i<=K;i<<=1)
        for(int l=0;l<K;l+=i)
            for(int j=0;j<(i/2);++j) {
                int &p=a[j+l],&q=a[l+j+(i/2)];
                ll t=q*(ll)w[o][K/i*j]%MOD;
                q=(p-t+MOD)%MOD;
                p=(p+t)%MOD;
            }
    if(!o) return;
    ll rk=qp(K,MOD-2);
    for(int i=0;i<K;++i) a[i]=a[i]*(ll)rk%MOD;
}
vi operator * (const vi&A,const vi&B) {
    if(A.empty()) return A;
    if(B.empty()) return B;
    int u=sz(A)+sz(B)-1;
    vi C(u);
    static int ta[SZ],tb[SZ];
    fftinit(u);
    for(int i=0;i<K;++i) ta[i]=(i<sz(A))?A[i]:0;
    for(int i=0;i<K;++i) tb[i]=(i<sz(B))?B[i]:0;
    fft(ta,0);fft(tb,0);
    for(int i=0;i<K;++i) ta[i]=ta[i]*(ll)tb[i]%MOD;
    fft(ta,1);
    for(int i=0;i<u;++i) C[i]=ta[i];
    return C;
}

int fac[SZ], ifac[SZ];
void init(int n) {
    fac[0] = 1;
    for(int i = 1; i <= n; i++) fac[i] = 1LL * fac[i - 1] * i % MOD;
    ifac[n] = qp(fac[n], MOD - 2);
    for(int i = n; i >= 1; i--) ifac[i - 1] = 1LL * ifac[i] * i % MOD;
}
vi comp(vi A) {
    int n = A.size() - 1;
    vi B(n + 1);
    for(int i = 0; i <= n; i++) A[i] = 1LL * A[i] * fac[i] % MOD;
    reverse(A.begin(), A.end());
    for(int i = 0; i <= n; i++) B[i] = ifac[i];

    vi C = A * B;
    C.resize(n + 1);
    reverse(C.begin(), C.end());
    for(int i = 0; i <= n; i++) C[i] = 1LL * C[i] * ifac[i] % MOD;
    return C;
}

int pw[10];

int main() {
    pw[0] = 1;
    for(int i = 0; i < 5; i++) pw[i + 1] = pw[i] * 26;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3392kb

input:

3 2
1 1 1
1 2
2 3

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements