# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1033913 |
2024-07-25T07:43:56 Z |
vjudge1 |
Tents (JOI18_tents) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
#define int long long
#define fi first
#define pll pair<long long, long long>
#define se second
#define isz(a) (int)a.size()
using namespace std;
const long long inf = 1e18;
const int maxn = 3e3 + 5;
const int mod = 1e9 + 7;
int n, m, divi;
int cc[maxn][maxn];
long long binpow(int x, int y){
long long ans = 1;
while (y){
if (y & 1) ans = ans * x % mod;
x = x * x % mod; y >>= 1;
}
return ans;
}
int dp(int i, int j){
if (i < 0 || j < 0) return 0;
if (cc[i][j] != -1) return cc[i][j];
int ans = 0;
ans += dp(i - 1, j - 2) * i % mod * j % mod * (j - 1) % mod * divi % mod; ans %= mod;
ans += dp(i - 2, j - 1) * j % mod * i % mod * (i - 1) % mod * divi % mod; ans %= mod;
return cc[i][j] = ans;
}
void solve(){
cin >> n >> m;
for (int i = 1; i <= n; ++i){
for (int j = 1; j <= m; ++j) cc[i][j] = -1;
}
divi = binpow(2, mod - 2);
for (int i = 0; i <= n; ++i) cc[i][0] = 1;
for (int i = 0; i <= m; ++i) cc[0][i] = 1;
cc[1][1] = 4;
cout << dp(n, m) << "\n";
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t = 1; // cin >> t;
while (t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |