#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=5e3+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
ll n,m,dp[N][N];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
dp[1][0]=1;
REP1(i,n)REP(j,m+1){
if(i==1)continue;
dp[i][j]=(dp[i-1][j]*(j+1)+(j?dp[i-1][j-1]*(i-j):0))%MOD;
}
cout<<dp[n][m-1]<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1536 KB |
Output is correct |
14 |
Correct |
1 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
2304 KB |
Output is correct |
16 |
Correct |
2 ms |
2304 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
1 ms |
1664 KB |
Output is correct |
19 |
Correct |
1 ms |
1024 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1536 KB |
Output is correct |
14 |
Correct |
1 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
2304 KB |
Output is correct |
16 |
Correct |
2 ms |
2304 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
1 ms |
1664 KB |
Output is correct |
19 |
Correct |
1 ms |
1024 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
4352 KB |
Output is correct |
22 |
Correct |
3 ms |
4480 KB |
Output is correct |
23 |
Correct |
5 ms |
7936 KB |
Output is correct |
24 |
Correct |
6 ms |
8320 KB |
Output is correct |
25 |
Correct |
8 ms |
11776 KB |
Output is correct |
26 |
Correct |
9 ms |
12160 KB |
Output is correct |
27 |
Correct |
10 ms |
12160 KB |
Output is correct |
28 |
Correct |
4 ms |
5376 KB |
Output is correct |
29 |
Correct |
1 ms |
1280 KB |
Output is correct |
30 |
Correct |
10 ms |
11904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1536 KB |
Output is correct |
14 |
Correct |
1 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
2304 KB |
Output is correct |
16 |
Correct |
2 ms |
2304 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
1 ms |
1664 KB |
Output is correct |
19 |
Correct |
1 ms |
1024 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
4352 KB |
Output is correct |
22 |
Correct |
3 ms |
4480 KB |
Output is correct |
23 |
Correct |
5 ms |
7936 KB |
Output is correct |
24 |
Correct |
6 ms |
8320 KB |
Output is correct |
25 |
Correct |
8 ms |
11776 KB |
Output is correct |
26 |
Correct |
9 ms |
12160 KB |
Output is correct |
27 |
Correct |
10 ms |
12160 KB |
Output is correct |
28 |
Correct |
4 ms |
5376 KB |
Output is correct |
29 |
Correct |
1 ms |
1280 KB |
Output is correct |
30 |
Correct |
10 ms |
11904 KB |
Output is correct |
31 |
Runtime error |
92 ms |
41976 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |