Submission #994542
Source Code Expand
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) using namespace std; //kaewasuretyuui typedef long long ll; typedef pair<int,int> pii; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef pair<int,pii> pip; typedef vector<pip>vip; const double PI=acos(-1); const double EPS=1e-8; const int inf=1e8; int main(){ ll n,m; cin>>n>>m; if(n>m){ cout<<0<<endl; return 0; } vi dp(n+2); dp[1]=1; ll MOD=1000000007; rep(i,m){ vi ndp(n+2); rep(j,n+1){ if(j!=n)(ndp[j+1]+=dp[j]*(n-j))%=MOD; (ndp[j]+=dp[j]*(j-(j==n?1:0)))%=MOD; } ndp[n+1]=(dp[n+1]*n+dp[n])%MOD; dp=ndp; // rep(j,n+2)cout<<" "<<dp[j];cout<<endl; } cout<<dp[n+1]<<endl; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | ixmel_rd |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1209 Byte |
Status | WA |
Exec Time | 3 ms |
Memory | 256 KB |
Judge Result
Set Name | sample | all | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 3 ms | 256 KB |
01-02.txt | AC | 2 ms | 256 KB |
01-03.txt | AC | 3 ms | 256 KB |
01-04.txt | AC | 3 ms | 256 KB |
01-05.txt | WA | 2 ms | 256 KB |
01-06.txt | WA | 3 ms | 256 KB |
01-07.txt | WA | 3 ms | 256 KB |
01-08.txt | WA | 3 ms | 256 KB |
01-09.txt | WA | 3 ms | 256 KB |
01-10.txt | AC | 3 ms | 256 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | WA | 3 ms | 256 KB |
sample-03.txt | AC | 2 ms | 256 KB |