제출 #44482

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
444822018-04-02 10:22:43aomeTents (JOI18_tents)C++17
100 / 100
200 ms35968 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
const int mod = 1e9 + 7;
int n, m, f[N][N];
void add(int &x, int y) {
x += x + y >= mod ? y - mod : y;
}
int main() {
cin >> n >> m;
f[n][m] = 1;
for (int i = n; i >= 0; --i) {
for (int j = m; j >= 0; --j) {
if (j) {
add(f[i][j - 1], f[i][j]);
if (i) add(f[i - 1][j - 1], 4LL * f[i][j] * i % mod);
if (i > 1) {
add(f[i - 2][j - 1], 1LL * f[i][j] * i * (i - 1) / 2 % mod);
}
if (i && j > 1) {
add(f[i - 1][j - 2], 1LL * f[i][j] * i * (j - 1) % mod);
}
}
else if (i) add(f[i - 1][j], f[i][j]);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...