Submission #900516

#TimeUsernameProblemLanguageResultExecution timeMemory
900516guechotjrhhTents (JOI18_tents)C++14
100 / 100
69 ms492 KiB
#include<iostream> #include<vector> using namespace std; #define ll long long int mod = 1e9 + 7; int func(int n, int m) { vector<ll> dp1(m+1, 0), dp2(m+1, 0), dp3(m+1, 0); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp3[j] = dp2[j]; //empty dp3[j] += (1 + dp2[j-1]) * 4 * j; //one, not connected if (j > 1) dp3[j] += (1 + dp2[j - 2]) * (j * (j-1))/2; //2 in the row if (i > 0) dp3[j] += (1 + dp1[j-1]) * j * (i-1);//one col, 2 in the col dp3[j] %= mod; } dp1 = dp2; dp2 = dp3; } return dp2[m]; } int main() { int n, m; cin >> n >> m; cout << func(n, m) << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...