# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1127660 | VinhLuu | Tents (JOI18_tents) | C++20 | 176 ms | 70804 KiB |
#include <bits/stdc++.h>
#define ll long long
#define all(lpv) lpv.begin(), lpv.end()
#define pot(x, y) lower_bound(x.begin(), x.end(), y) - x.begin() + 1
using namespace std;
#define lpv
#ifndef lpv
#include "AC.h"
#endif // lpv
#define int long long
const int N = 3e3 + 5;
const int mod = 1e9 + 7;
int lt(int u,int v) {
if(!v) return 1;
int x = u, kq = 1;
while(v) {
if(v & 1) kq = kq * x % mod;
x = x * x % mod;
v /= 2;
}
return kq;
}
void get(int &x,int y) {
x = (x + y) % mod;
}
int f[N][N], g[N][N], ft[N], inv[N];
int C(int u,int v) {
if(!u || u == v) return 1;
return ft[v] * inv[v - u] % mod * inv[u] % mod;
}
#ifdef lpv
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "v"
if(fopen(task ".inp","r")) {
freopen(task ".inp","r",stdin);
freopen(task ".out","w",stdout);
}
int n, m; cin >> n >> m;
for(int i = 0; i <= n; i ++) {
for(int j = 0; j <= m; j ++) {
if(!i || !j) {f[i][j] = 1; continue;}
get(f[i][j], f[i - 1][j - 1] * 4 % mod * j % mod);
get(f[i][j], f[i - 1][j]);
if(i >= 2) get(f[i][j], f[i - 2][j - 1] * (i - 1) % mod * j % mod);
if(j >= 2) get(f[i][j], f[i - 1][j - 2] * ((j * (j - 1) / 2) % mod) % mod);
}
}
cout << (f[n][m] - 1 + mod) % mod;
}
#endif // lpv
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |