Submission #7475503
Source Code Expand
#include<bits/stdc++.h> using namespace std; const int P=1000000007; int n,m; long long dp[2][305][305]; int main(){ scanf("%d%d",&n,&m); if(m<n)return puts("0"),0; dp[0][1][1]=1; for(int i=0;i<m;++i){ memset(dp[i+1&1],0,sizeof dp[i+1&1]); for(int j=1;j<=n;++j) for(int k=1;k<=n;++k) if(dp[i&1][j][k]){ (dp[i+1&1][j+1][k]+=dp[i&1][j][k]*(n-j))%=P; (dp[i+1&1][j][k]+=dp[i&1][j][k]*(j-k))%=P; (dp[i+1&1][j][j]+=dp[i&1][j][k]*k)%=P; } } printf("%lld\n",dp[m&1][n][n]); }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | rushcheyo |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 529 Byte |
Status | AC |
Exec Time | 55 ms |
Memory | 1664 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:9: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 | 2 ms | 1664 KB |
01-03.txt | AC | 12 ms | 1664 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 13 ms | 1664 KB |
01-06.txt | AC | 19 ms | 1664 KB |
01-07.txt | AC | 54 ms | 1664 KB |
01-08.txt | AC | 55 ms | 1664 KB |
01-09.txt | AC | 55 ms | 1664 KB |
01-10.txt | AC | 55 ms | 1664 KB |
sample-01.txt | AC | 2 ms | 1664 KB |
sample-02.txt | AC | 29 ms | 1664 KB |
sample-03.txt | AC | 1 ms | 256 KB |