Submission #993115
Source Code Expand
#include <cstdio> typedef long long ll; const ll mod=1000000007ll; void ad(ll &a,ll b){a+=b;a%=mod;} int main() { int n,m; scanf("%d%d",&n,&m); static ll dp[310][310][310]={0}; dp[1][1][0]=1; for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ for(int k=0;j+k<=n;k++){ //printf("%d %d %d %lld\n",i,j,k,dp[i][j][k]); ad(dp[i+1][j][k],dp[i][j][k]*k%mod); ad(dp[i+1][j+k][0],dp[i][j][k]*j%mod); if(j+k+1<=n){ ad(dp[i+1][j][k+1],dp[i][j][k]*(n-j-k)%mod); } } } } printf("%lld\n",dp[m+1][n][0]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | Huziwara |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 574 Byte |
Status | AC |
Exec Time | 494 ms |
Memory | 218624 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:12:22: 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 128 KB |
01-02.txt | AC | 1 ms | 128 KB |
01-03.txt | AC | 5 ms | 2048 KB |
01-04.txt | AC | 3 ms | 896 KB |
01-05.txt | AC | 15 ms | 7936 KB |
01-06.txt | AC | 118 ms | 65280 KB |
01-07.txt | AC | 472 ms | 210688 KB |
01-08.txt | AC | 489 ms | 217216 KB |
01-09.txt | AC | 492 ms | 217856 KB |
01-10.txt | AC | 494 ms | 218624 KB |
sample-01.txt | AC | 1 ms | 128 KB |
sample-02.txt | AC | 212 ms | 109568 KB |
sample-03.txt | AC | 249 ms | 109440 KB |