Submission #887907

#TimeUsernameProblemLanguageResultExecution timeMemory
887907vjudge1Tents (JOI18_tents)C++17
100 / 100
56 ms71040 KiB
//In His Name #include <bits/stdc++.h> //#pragma GCC optimization("O3") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("avx2") using namespace std; #define ll long long #define int ll typedef pair<int, int> pii; #define F first #define S second #define pb push_back #define bug(x) cout << "Ah shit , here we go again : " << x <<endl #define all(x) x.begin() , x.end() const int maxn = 3e3 + 10, MOD = 1e9 + 7; const ll INF = 1e18; int n , m , dp[maxn][maxn]; int32_t main(){ ios_base::sync_with_stdio(false); cin >> n >> m; for(int i = 1 ; i <= n ; i++) dp[i][0] = 1 , dp[i][1] = (4 * i + (i*(i-1)/2) + 1) % MOD; for(int i = 1 ; i <= m ; i++) dp[0][i] = 1 , dp[1][i] = (4 * i + (i*(i-1)/2) + 1) % MOD; dp[0][0] = 1; for(int i = 2 ; i <= n; i++){ for(int j = 2 ; j <= m ; j++){ dp[i][j] = dp[i-1][j] % MOD; dp[i][j] += (4 * j * dp[i-1][j-1]) % MOD; dp[i][j] += (j * (i-1) * dp[i-2][j-1]) % MOD; dp[i][j] += (j * (j-1) / 2 * dp[i-1][j-2]) % MOD; } } cout << (dp[n][m] + MOD - 1) % MOD; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...