# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
44654 | PowerOfNinjaGo | Tents (JOI18_tents) | C++17 | 511 ms | 36224 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int md = 1e9+7;
const int maxn = 3e3+5;
int dp[maxn][maxn];
void add(int &a, int b)
{
a += b;
if(a>= md) a-= md;
}
int mul(int a, int b)
{
return (1LL*a*b)%md;
}
int solve(int n, int m)
{
if(n == 0 || m == 0) return 1;
if(dp[n][m] != -1) return dp[n][m];
int &res = dp[n][m];
res = 0;
add(res, mul(4*m, solve(n-1, m-1)));
if(n>= 2) add(res, mul(m*(n-1), solve(n-2, m-1)));
if(m>= 2) add(res, mul(m*(m-1)/2, solve(n-1, m-2)));
add(res, solve(n-1, m));
return res;
}
int main()
{
int n, m; cin >> n >> m;
memset(dp, -1, sizeof dp);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |