UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211787#37. 染色yiweixxs151513ms21588kbC++869b2024-10-02 16:43:202024-10-02 16:43:21

answer

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
int n,m,P;
int f[5005][5005];
int main(){
    cin>>n>>m>>P;
    f[1][1]=m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<min(i+1,m);j++){
            for(int k=1;k<=j;k++){
                f[i+1][k]+=f[i][j];
                f[i+1][k]%=P;
            }
            if(j<m-1)f[i+1][j+1]+=f[i][j]*(m-j);
            f[i+1][j+1]%=P;
        }
    }
    int ans=0;
    for(int i=1;i<m;i++){
        ans+=f[n][i];
        ans%=P;
    }
    cout<<ans;
    return 0;
}
/*
1 1
f[i][j] 前i个格子中,最后j格颜色各不相同
j<m-1
    f[i][j]->f[i+1][1~j+1];
j=m-1
    f[i][j]->f[i+1][1~j];
*/



详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 5
Accepted
time: 0ms
memory: 1228kb

input:

5 2 6

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 5
Accepted
time: 0ms
memory: 1236kb

input:

8 8 562455908

output:

16736896

result:

ok 1 number(s): "16736896"

Test #3:

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

input:

1942 7 873185963

output:

-227671448

result:

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

Test #4:

score: 5
Accepted
time: 0ms
memory: 9396kb

input:

2030 10 187301366

output:

171496026

result:

ok 1 number(s): "171496026"

Test #5:

score: 0
Wrong Answer
time: 4ms
memory: 19928kb

input:

4643 9 998244353

output:

211313113

result:

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

Test #6:

score: 0
Wrong Answer
time: 1438ms
memory: 11092kb

input:

1447 3969 998244353

output:

857951918

result:

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

Test #7:

score: 0
Wrong Answer
time: 7ms
memory: 2228kb

input:

226 212 998244352

output:

-234881024

result:

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

Test #8:

score: 0
Wrong Answer
time: 15ms
memory: 2604kb

input:

300 292 779230672

output:

-83699712

result:

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

Test #9:

score: 0
Wrong Answer
time: 11ms
memory: 2448kb

input:

269 228 479932618

output:

-386114586

result:

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

Test #10:

score: 0
Wrong Answer
time: 4ms
memory: 2148kb

input:

216 112 207794912

output:

37211904

result:

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

Test #11:

score: 0
Wrong Answer
time: 9ms
memory: 2556kb

input:

291 261 37264436

output:

-7711475

result:

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

Test #12:

score: 0
Wrong Answer
time: 10ms
memory: 2456kb

input:

273 218 960539553

output:

-171187196

result:

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

Test #13:

score: 0
Time Limit Exceeded

input:

2991 2318 704783019

output:


result:


Test #14:

score: 0
Time Limit Exceeded

input:

4413 790 693631006

output:


result:


Test #15:

score: 0
Time Limit Exceeded

input:

4786 4581 2

output:


result:


Test #16:

score: 0
Time Limit Exceeded

input:

4953 4424 876277826

output:


result:


Test #17:

score: 0
Wrong Answer
time: 15ms
memory: 21588kb

input:

4921 37 699201223

output:

678403637

result:

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

Test #18:

score: 0
Time Limit Exceeded

input:

4991 994 533908193

output:


result:


Test #19:

score: 0
Time Limit Exceeded

input:

5000 5000 640462742

output:


result:


Test #20:

score: 0
Time Limit Exceeded

input:

4935 1005 961254358

output:


result: