Submission #869342

#TimeUsernameProblemLanguageResultExecution timeMemory
869342sleepntsheepTents (JOI18_tents)C++17
100 / 100
112 ms36436 KiB
#include <iostream> #include <cassert> #include <cstring> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,tune=native") using namespace std; #define ALL(x) x.begin(), x.end() #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); using ll = long long; #define N 3050 const ll M = 1000000007; int h, w; int dp[N][N]; int main() { ShinLena; cin >> h >> w; for (int i = 0; i < N; ++i) dp[0][i] = dp[i][0] = 1; for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j) { (dp[i][j] += dp[i-1][j] + (4ll * j * dp[i-1][j-1] % M)) %= M; if (i > 1) (dp[i][j] += (1ll*(i-1)*j%M) * dp[i-2][j-1] % M) %= M; if (j > 1) (dp[i][j] += (1ll*j*(j-1)%M*500000004%M) * dp[i-1][j-2] % M) %= M; } cout << (dp[h][w] + M - 1) % M << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...