//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= (int)y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef complex<int> point;
const int nmax = 3005;
const ll linf = 1e18;
const ll mod = 1e9+7;
const int inf = INT_MAX;
ll n, m;
ll f[nmax][nmax];
ll rec( ll x , ll y){
if( x < 0 || y < 0) return 0;
if( x == 0 || y == 0) return 1;
if(f[x][y]) return f[x][y];
f[x][y] = rec(x-1,y) + rec(x-1,y-1)*4LL*y % mod + rec(x-1,y-2)*(y *(y-1) / 2LL) % mod + rec(x-2,y-1)*y*(x-1)%mod;
f[x][y] %= mod;
return f[x][y];
}
int main(){
//
fast;
cin >> n >> m;
cout << (rec(n,m)+ mod - 1) % mod <<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
1280 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
6 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
768 KB |
Output is correct |
8 |
Correct |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
896 KB |
Output is correct |
10 |
Correct |
6 ms |
1792 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
8 ms |
2048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
1280 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
6 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
768 KB |
Output is correct |
8 |
Correct |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
896 KB |
Output is correct |
10 |
Correct |
6 ms |
1792 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
8 ms |
2048 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
10 ms |
9856 KB |
Output is correct |
15 |
Correct |
205 ms |
47356 KB |
Output is correct |
16 |
Correct |
7 ms |
1664 KB |
Output is correct |
17 |
Correct |
22 ms |
6912 KB |
Output is correct |
18 |
Correct |
48 ms |
13688 KB |
Output is correct |
19 |
Correct |
230 ms |
53368 KB |
Output is correct |
20 |
Correct |
192 ms |
42316 KB |
Output is correct |
21 |
Correct |
104 ms |
25532 KB |
Output is correct |
22 |
Correct |
109 ms |
30840 KB |
Output is correct |
23 |
Correct |
68 ms |
26616 KB |
Output is correct |
24 |
Correct |
292 ms |
59048 KB |
Output is correct |
25 |
Correct |
221 ms |
49272 KB |
Output is correct |
26 |
Correct |
245 ms |
54648 KB |
Output is correct |
27 |
Correct |
306 ms |
57112 KB |
Output is correct |