Submission #933726

#TimeUsernameProblemLanguageResultExecution timeMemory
933726parlimoosTents (JOI18_tents)C++14
100 / 100
40 ms70708 KiB
//Be Name KHODA #pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define pp pop_back #define lb lower_bound #define ub upper_bound #define cl clear #define bg begin #define arr(x) array<int , x> #define endl '\n' const int MOD = int(1e9) + 7; int n , m; ll dp[3001][3001]; int main(){ cin >> n >> m; dp[n][m] = 1; for(int i = n ; i > 0 ; i--){ for(int j = m ; j >= 0 ; j--){ dp[i][j] %= MOD; dp[i - 1][j] += dp[i][j]; if(m > 0){ dp[i - 1][j - 1] += j * 4 * dp[i][j]; if(i > 1) dp[i - 2][j - 1] += j * (i - 1) * dp[i][j]; } if(m > 1) dp[i - 1][j - 2] += j * (j - 1) / 2 * dp[i][j]; } } ll o = 0; for(int j = m - 1 ; j >= 0 ; j--) o += dp[0][j]; cout << o % MOD; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...