Submission #8531641
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define ll long long int n, k, mod, C[333][333], f[333][333], g[333][333]; template<class T1,class T2> void U(T1 &x,T2 y){ x=(x+y)%mod; } int main(){ cin>>n>>k>>mod; for (int i=0;i<=n;++i){ C[i][0]=1; for (int j=1;j<=i;++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod; } for (int i=0;i<=k;++i){ f[1][i]=1; g[1][i]=i+1; } for (int i=2;i<=n+1;++i){ for (int j=0;j<=k;++j){ for (int i1=1;i1<i;++i1){ int i2=i-i1; if (j) U(f[i][j],(ll)C[i-2][i1-1]*f[i1][j]%mod*g[i2][j-1]); } g[i][j]=f[i][j]; if (j) U(g[i][j],g[i][j-1]); } } cout<<f[n+1][k]<<endl; }
Submission Info
Submission Time | |
---|---|
Task | E - Sequence Growing Hard |
User | zhang2333 |
Language | C++14 (GCC 5.4.1) |
Score | 1200 |
Code Size | 662 Byte |
Status | AC |
Exec Time | 323 ms |
Memory | 1408 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1200 / 1200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 323 ms | 1408 KB |
02.txt | AC | 282 ms | 1408 KB |
03.txt | AC | 185 ms | 1152 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 313 ms | 1408 KB |
06.txt | AC | 3 ms | 1408 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 309 ms | 1408 KB |
09.txt | AC | 300 ms | 1408 KB |
10.txt | AC | 175 ms | 1152 KB |
11.txt | AC | 121 ms | 1152 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | AC | 1 ms | 256 KB |
14.txt | AC | 323 ms | 1408 KB |
15.txt | AC | 31 ms | 1408 KB |
16.txt | AC | 213 ms | 1280 KB |
17.txt | AC | 1 ms | 384 KB |
18.txt | AC | 246 ms | 1408 KB |
19.txt | AC | 312 ms | 1408 KB |
20.txt | AC | 67 ms | 1152 KB |
21.txt | AC | 3 ms | 1408 KB |
22.txt | AC | 247 ms | 1408 KB |
23.txt | AC | 281 ms | 1408 KB |
24.txt | AC | 3 ms | 384 KB |
25.txt | AC | 9 ms | 384 KB |
26.txt | AC | 273 ms | 1408 KB |
27.txt | AC | 5 ms | 384 KB |
28.txt | AC | 55 ms | 1408 KB |
29.txt | AC | 225 ms | 1280 KB |
30.txt | AC | 9 ms | 640 KB |
31.txt | AC | 271 ms | 1408 KB |
32.txt | AC | 319 ms | 1408 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 40 ms | 896 KB |