Submission #1817202
Source Code Expand
#include<bits/stdc++.h> using namespace std; const int mod=1000000007; const int maxn=305; long long dp[maxn][maxn][maxn];// 已经有i天了,连接了j个点的双联通 k个点还没有双联通 的方案数。 int main() { memset(dp,0,sizeof(dp)); dp[1][1][0]=1; int n,m; scanf("%d%d",&n,&m); m++; if(m<n){ puts("0"); return 0; } for(int i=1;i<=m;i++) { for(int j=1;j<=n;j++) { for(int k=0;k+j<=n;k++) { if(dp[i][j][k]==0) continue; dp[i+1][j+k][0]=(dp[i+1][j+k][0]+dp[i][j][k]*j)%mod; dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k]*k)%mod; dp[i+1][j][k+1]=(dp[i+1][j][k+1]+dp[i][j][k])%mod; } } } long long ans=dp[m][n][0]; for(int i=2;i<n;i++) ans=(ans*i)%mod; printf("%lld\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | munaiyi |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 935 Byte |
Status | AC |
Exec Time | 136 ms |
Memory | 221952 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:11:24: 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 | 78 ms | 221952 KB |
01-02.txt | AC | 78 ms | 221952 KB |
01-03.txt | AC | 78 ms | 221952 KB |
01-04.txt | AC | 78 ms | 221952 KB |
01-05.txt | AC | 78 ms | 221952 KB |
01-06.txt | AC | 89 ms | 221952 KB |
01-07.txt | AC | 134 ms | 221952 KB |
01-08.txt | AC | 135 ms | 221952 KB |
01-09.txt | AC | 136 ms | 221952 KB |
01-10.txt | AC | 135 ms | 221952 KB |
sample-01.txt | AC | 78 ms | 221952 KB |
sample-02.txt | AC | 103 ms | 221952 KB |
sample-03.txt | AC | 78 ms | 221952 KB |