Submission #2005754
Source Code Expand
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int N=305; const int mod=1000000007; int n,m; int dp[2][N][N]; int main(){ int i,j,k,now,pre,w; scanf("%d%d",&n,&m); if (m<n){ printf("0\n"); return 0; } now=0; pre=1; dp[0][1][1]=1; for (i=1;i<=m;i++){ now^=1; pre^=1; for (j=1;j<=i;j++) for (k=1;k<=i&&k<=j;k++){ if (!dp[pre][j][k]) continue; w=dp[pre][j][k]; (dp[now][j+1][k]+=1ll*w*(n-j)%mod)%=mod; (dp[now][j][k]+=1ll*w*(j-k)%mod)%=mod; (dp[now][j][j]+=1ll*w*k%mod)%=mod; } memset(dp[pre],0,sizeof(dp[pre])); } printf("%d\n",dp[now][n][n]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | wdyhy |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 727 Byte |
Status | AC |
Exec Time | 50 ms |
Memory | 1024 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:17:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&n,&m); ^
Judge Result
Set Name | sample | all | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt, sample-03.txt |
all | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 1 ms | 1024 KB |
01-03.txt | AC | 11 ms | 1024 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 11 ms | 1024 KB |
01-06.txt | AC | 20 ms | 1024 KB |
01-07.txt | AC | 49 ms | 1024 KB |
01-08.txt | AC | 50 ms | 1024 KB |
01-09.txt | AC | 50 ms | 1024 KB |
01-10.txt | AC | 50 ms | 1024 KB |
sample-01.txt | AC | 1 ms | 1024 KB |
sample-02.txt | AC | 30 ms | 1024 KB |
sample-03.txt | AC | 1 ms | 256 KB |