| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 135272 | mohammedehab2002 | Tents (JOI18_tents) | C++11 | 348 ms | 36088 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string.h>
using namespace std;
#define mod 1000000007
int dp[3005][3005];
int solve(int n,int m)
{
if (!n || !m)
return 1;
if (dp[n][m]!=-1)
return dp[n][m];
int ans=(solve(n-1,m)+4LL*m*solve(n-1,m-1))%mod;
if (m>=2)
ans=(ans+1LL*m*(m-1)/2*solve(n-1,m-2))%mod;
if (n>=2)
ans=(ans+(n-1LL)*m*solve(n-2,m-1))%mod;
return dp[n][m]=ans;
}
int main()
{
int n,m;
cin >> n >> m;
memset(dp,-1,sizeof(dp));
cout << (solve(n,m)-1+mod)%mod;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
