QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#340222#8047. DFS Order 4djwj233WA 994ms13684kbC++14822b2024-02-28 19:26:542024-02-28 19:26:55

Judging History

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

  • [2024-02-28 19:26:55]
  • 评测
  • 测评结果:WA
  • 用时:994ms
  • 内存:13684kb
  • [2024-02-28 19:26:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fo(v,a,b) for(int v = a; v <= b; v++)
#define fr(v,a,b) for(int v = a; v >= b; v--)
#define cl(a,v) memset(a, v, sizeof(a))

typedef long long ll;

const int N = 810;

int n; ll P, f[N][N], C[N][N];

int main()
{
    scanf("%d%lld", &n, &P);
    fo(i, 0, n) {
        C[i][0] = 1;
        fo(j, 1, i) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
    }

    n--;
    fo(i, 0, n) f[0][i] = 1;
    fo(x, 1, n) fo(y, 0, n - x) {
        fo(i, 0, x - 1)
            f[x][y] = (f[x][y] + C[x - 1 + y][i] * f[i][0] % P * f[x - 1 - i][y]) % P;
        fo(i, 0, x - 2) {
            int j = x - 1 - i;
            f[x][y] = (f[x][y] + P - f[i][j + y] * f[j][y]) % P;
        }
    }

    printf("%lld\n", f[n][0]);

    return 0;
}
/*
 
*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5980kb

input:

4 114514199

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 6060kb

input:

10 998244353

output:

11033

result:

ok 1 number(s): "11033"

Test #3:

score: 0
Accepted
time: 3ms
memory: 6656kb

input:

100 1000000007

output:

270904395

result:

ok 1 number(s): "270904395"

Test #4:

score: 0
Accepted
time: 837ms
memory: 13024kb

input:

756 1001338769

output:

901942543

result:

ok 1 number(s): "901942543"

Test #5:

score: 0
Accepted
time: 973ms
memory: 13684kb

input:

793 1009036033

output:

301770320

result:

ok 1 number(s): "301770320"

Test #6:

score: 0
Accepted
time: 852ms
memory: 13308kb

input:

759 1005587659

output:

846376219

result:

ok 1 number(s): "846376219"

Test #7:

score: 0
Accepted
time: 903ms
memory: 13116kb

input:

773 1007855479

output:

1398019

result:

ok 1 number(s): "1398019"

Test #8:

score: 0
Accepted
time: 823ms
memory: 13044kb

input:

751 1006730639

output:

321287237

result:

ok 1 number(s): "321287237"

Test #9:

score: 0
Accepted
time: 906ms
memory: 13360kb

input:

778 1007760653

output:

430322899

result:

ok 1 number(s): "430322899"

Test #10:

score: 0
Accepted
time: 994ms
memory: 13408kb

input:

798 1007543827

output:

688720826

result:

ok 1 number(s): "688720826"

Test #11:

score: 0
Accepted
time: 988ms
memory: 13312kb

input:

796 1004841413

output:

258829347

result:

ok 1 number(s): "258829347"

Test #12:

score: -100
Wrong Answer
time: 927ms
memory: 13144kb

input:

775 1005185189

output:

-260906581

result:

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