# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335384 | mehrdad_sohrabi | Tents (JOI18_tents) | C++14 | 312 ms | 73580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=3e3+100;
ll dp[N][N];
ll mod=1e9+7;
int32_t main(){
ll n,m;
cin >> n >> m;
dp[0][0]=1;
for (int i=1;i<N;i++) dp[0][i]=1,dp[i][0]=1;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
dp[i][j]=dp[i][j-1]+dp[i-1][j-1]*4*i%mod;
if (i>=2) dp[i][j]+=dp[i-2][j-1]*(i*(i-1)/2)%mod;
if (j>=2) dp[i][j]+=dp[i-1][j-2]*i*(j-1)%mod;
dp[i][j]%=mod;
}
}
cout << dp[n][m]-1 << endl;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |