이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
#define uid(a, b) uniform_int_distribution<int>(a, b)(mt)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 2e8+1;
const int mod = 1e9+7;
const int maxn = 3000 + 5;
mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
ll wt[maxn][maxn];
ll go(int n, int m){
if(n < 0 || m < 0)return 0;
if(n == 0)return 1;
if(wt[n][m])return wt[n][m];
wt[n][m] = (go(n - 1, m) + go(n - 1, m - 1) * 4 * m + go(n - 1, m - 2) * m * (m - 1) / 2 + go(n - 2, m - 1) * m * (n - 1)) % mod;
return wt[n][m];
}
void solve() {
int n, m;
cin >> n >> m;
cout << go(n, m) - 1;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int times = 1; //cin >> times;
for(int i = 1; i <= times; i++) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |