제출 #717012

#제출 시각아이디문제언어결과실행 시간메모리
717012AmirAli_H1Tents (JOI18_tents)C++17
100 / 100
108 ms70880 KiB
// In the name of Allah #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define all(x) (x).begin(),(x).end() #define len(x) ((ll) (x).size()) #define F first #define S second #define pb push_back #define sep ' ' #define endl '\n' #define Mp make_pair #define debug(x) cerr << #x << ": " << x << endl; #define kill(x) cout << x << '\n', exit(0); #define set_dec(x) cout << fixed << setprecision(x); #define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout); int n, m; const int maxn = 3000 + 4; const int mod = 1e9 + 7; ll dp[maxn][maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) dp[i][j] = 1; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j - 2 >= 0) dp[i][j] += (1ll * (j * (j - 1) / 2)) % mod * dp[i - 1][j - 2] % mod; if (i - 2 >= 0) dp[i][j] += (1ll * j * (i - 1)) % mod * dp[i - 2][j - 1] % mod; dp[i][j] += (4ll * j) % mod * dp[i - 1][j - 1] % mod; dp[i][j] %= mod; } } cout << (dp[n][m] - 1 + mod) % mod << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...