QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#236279#7644. Good Splitsucup-team870WA 0ms3840kbC++142.4kb2023-11-03 19:47:322023-11-03 19:47:32

Judging History

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

  • [2023-11-03 19:47:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2023-11-03 19:47:32]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<=r; i++)
#define reps(i,l,r,s) for(int i=l; i<=r; i+=s)
#define per(i,r,l) for(int i=r; i>=l; i--)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int N = 40;
int n, mod, f[N], g[N][N], h[N], C[N][N], dp[N][N], f0[N], ksj[N];

int main() {
    scanf("%d%d", &n, &mod);
    C[0][0] = 1;
    rep (i, 1, 2*n) {
        C[i][0] = 1;
        rep (j, 1, i) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
    }
    f0[0] = 1;
    reps (i, 2, 2*n, 2) {
        reps (j, 0, i-1, 2) {
            f0[i] = (f0[i] + 1ll * f0[i-j-2] * f0[j]) % mod;
        }
    }
    f[0] = 1;
    reps (i, 2, 2*n, 2) {
        reps (j, 0, i, 2) {
            f[i] = (f[i] + 1ll * f0[i-j] * f0[j] % mod * C[i][j]) % mod;
        }
        // cout << i<<' '<<f[i]<<endl;
    }
    g[0][0] = 1;
    rep (i, 1, 2*n) {
        reps (j, 0, 2*n, 2) {
            reps (k, 0, j, 2) {
                g[i][j] = (g[i][j] + 1ll * g[i-1][j-k] * f[k]) % mod;
            }
        }
    }
    h[0] = 1;
    reps (i, 2, 2*n, 2) {
        h[i] = f[i];
        reps (j, 2, i-1, 2) {
            h[i] = (h[i] - 2ll * h[j] * g[j][i-j]);
        }
        if (h[i] < 0) h[i] += mod;
        h[i] = h[i] * 1ll * ((mod+1)/2) % mod;
        // cout << i <<' '<<h[i]<<endl;
    }
    // ksj[0] = 1;
    // reps (i, 2, 2*n, 2) {
    //     reps (j, 2, i, 2) {
    //         ksj[i] = (ksj[i] + 1ll * h[j] * ksj[i-j]) % mod;
    //     }
    // }

    dp[0][0] = 1;
    // reps (i, 1, 2*n, 1) {
    //     reps (j, 0, 2*n, 2) {
    //         reps (k, 0, j, 2) {
    //             dp[i][j] = (dp[i][j] + 1ll * dp[i-1][j-k] * ksj[k]) % mod;
    //         }
    //     }
    // }
    ksj[0] = 1;
    reps(j, 1, 2*n, 1) {
        reps (k, 0, 0, 2) {
            dp[j][0] = (dp[j][0] + 1ll * dp[j-1][0] * ksj[k]) % mod;
        }
    }
    reps (i, 2, 2*n, 2) {
        reps (j, 2, i, 2) {
            ksj[i] = (ksj[i] + 1ll * h[j] * dp[j][i-j]) % mod;
            // if (i == 6) {
            //     cout << h[j] <<' '<<dp[j][i-j]<<"$"<<endl;
            // }
        }
        reps(j, 1, 2*n, 1) {
            reps (k, 0, i, 2) {
                dp[j][i] = (dp[j][i] + 1ll * dp[j-1][i-k] * ksj[k]) % mod;
            }
        }
        cout << ksj[i] << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3836kb

input:

5 998244353

output:

1
3
14
84
592

result:

ok 5 number(s): "1 3 14 84 592"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3840kb

input:

20 998244353

output:

508218871
143923839
199313695
199777663
60772303
110103276
124227094
165807212
241404339
20325934
391439867
203364524
-167086458
303681135
-373177156
334379008
263680171
209337234
-54619997
-62758053

result:

wrong answer 1st numbers differ - expected: '1', found: '508218871'