Submission #5555040
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define sz(x) ((int)(x).size()) #define all(x) x.begin(),x.end() #define dmp(x) cerr<<#x<<":"<<x<<endl #define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i) #define rep(i,b) FOR(i,0,b) #define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i) #define per(i,b) ROF(i,0,b) template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} int dp[2][333][333]; signed main(){ int n,m,mod=1000000007; cin>>n>>m; dp[0][1][n-1]=1; for(int i=0;i<m;i++){ int ii=i%2; int ni=(i+1)%2; fill_n(*dp[ni],333*333,0); for(int j=0;j<=n;j++){ for(int k=0;k<n;k++){ if(dp[ii][j][k]==0)continue; dp[ni][n-k][k]+=dp[ii][j][k]*j%mod; dp[ni][n-k][k]%=mod; dp[ni][j][k]+=dp[ii][j][k]*(n-k-j)%mod; dp[ni][j][k]%=mod; if(k>0){ dp[ni][j][k-1]+=dp[ii][j][k]*k%mod; dp[ni][j][k-1]%=mod; } } } } cout<<dp[m%2][n][0]<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | shake |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 1125 Byte |
Status | AC |
Exec Time | 82 ms |
Memory | 1920 KB |
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 | 2 ms | 1152 KB |
01-02.txt | AC | 2 ms | 1920 KB |
01-03.txt | AC | 16 ms | 1920 KB |
01-04.txt | AC | 2 ms | 1152 KB |
01-05.txt | AC | 16 ms | 1920 KB |
01-06.txt | AC | 28 ms | 1920 KB |
01-07.txt | AC | 80 ms | 1920 KB |
01-08.txt | AC | 82 ms | 1920 KB |
01-09.txt | AC | 82 ms | 1920 KB |
01-10.txt | AC | 82 ms | 1920 KB |
sample-01.txt | AC | 2 ms | 1920 KB |
sample-02.txt | AC | 44 ms | 1920 KB |
sample-03.txt | AC | 25 ms | 1920 KB |