Submission #1914351
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<(n);i++) #define pb push_back #define all(v) (v).begin(),(v).end() #define fi first #define se second typedef vector<int>vint; typedef pair<int,int>pint; typedef vector<pint>vpint; template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;} template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;} const int mod=1000000007; int dp[2][333][333]; int N,M; inline void add(int &a,int b){ a+=b; if(a>=mod)a-=mod; } signed main(){ cin>>N>>M; dp[0][1][0]=1; rep(i,M){ rep(j,N+1){ rep(k,N+1){ if(dp[i&1][j][k]==0)continue; int o=N-j-k; add(dp[(i+1)&1][j][k+1],dp[i&1][j][k]*o%mod); add(dp[(i+1)&1][j][k],dp[i&1][j][k]*k%mod); add(dp[(i+1)&1][j+k][0],dp[i&1][j][k]*j%mod); dp[i&1][j][k]=0; } } } cout<<dp[M&1][N][0]<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | latte0119 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 1076 Byte |
Status | AC |
Exec Time | 96 ms |
Memory | 1792 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 | 3 ms | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 1 ms | 256 KB |
01-06.txt | AC | 19 ms | 768 KB |
01-07.txt | AC | 94 ms | 1792 KB |
01-08.txt | AC | 96 ms | 1792 KB |
01-09.txt | AC | 96 ms | 1792 KB |
01-10.txt | AC | 96 ms | 1792 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 45 ms | 1024 KB |
sample-03.txt | AC | 21 ms | 1024 KB |