QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340225#8047. DFS Order 4djwj233AC ✓1065ms13560kbC++14826b2024-02-28 19:29:202024-02-28 19:29:21

Judging History

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

  • [2024-02-28 19:29:21]
  • 评测
  • 测评结果:AC
  • 用时:1065ms
  • 内存:13560kb
  • [2024-02-28 19:29:20]
  • 提交

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) % P;
        }
    }

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

    return 0;
}
/*
 
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 114514199

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

10 998244353

output:

11033

result:

ok 1 number(s): "11033"

Test #3:

score: 0
Accepted
time: 0ms
memory: 6620kb

input:

100 1000000007

output:

270904395

result:

ok 1 number(s): "270904395"

Test #4:

score: 0
Accepted
time: 897ms
memory: 13016kb

input:

756 1001338769

output:

901942543

result:

ok 1 number(s): "901942543"

Test #5:

score: 0
Accepted
time: 1049ms
memory: 13524kb

input:

793 1009036033

output:

301770320

result:

ok 1 number(s): "301770320"

Test #6:

score: 0
Accepted
time: 915ms
memory: 13216kb

input:

759 1005587659

output:

846376219

result:

ok 1 number(s): "846376219"

Test #7:

score: 0
Accepted
time: 966ms
memory: 13220kb

input:

773 1007855479

output:

1398019

result:

ok 1 number(s): "1398019"

Test #8:

score: 0
Accepted
time: 890ms
memory: 13052kb

input:

751 1006730639

output:

321287237

result:

ok 1 number(s): "321287237"

Test #9:

score: 0
Accepted
time: 978ms
memory: 13280kb

input:

778 1007760653

output:

430322899

result:

ok 1 number(s): "430322899"

Test #10:

score: 0
Accepted
time: 1059ms
memory: 13320kb

input:

798 1007543827

output:

688720826

result:

ok 1 number(s): "688720826"

Test #11:

score: 0
Accepted
time: 1058ms
memory: 13552kb

input:

796 1004841413

output:

258829347

result:

ok 1 number(s): "258829347"

Test #12:

score: 0
Accepted
time: 977ms
memory: 13460kb

input:

775 1005185189

output:

744278608

result:

ok 1 number(s): "744278608"

Test #13:

score: 0
Accepted
time: 1065ms
memory: 13560kb

input:

800 1006012831

output:

508549367

result:

ok 1 number(s): "508549367"

Test #14:

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

input:

1 1001338769

output:

1

result:

ok 1 number(s): "1"

Test #15:

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

input:

2 1001338769

output:

1

result:

ok 1 number(s): "1"

Test #16:

score: 0
Accepted
time: 0ms
memory: 5960kb

input:

9 1009036033

output:

1780

result:

ok 1 number(s): "1780"

Test #17:

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

input:

14 1001338769

output:

43297358

result:

ok 1 number(s): "43297358"

Extra Test:

score: 0
Extra Test Passed