# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
901715 |
2024-01-10T01:19:48 Z |
aqxa |
Tents (JOI18_tents) |
C++17 |
|
69 ms |
432 KB |
// solved
// if u have < --- > , then the 2 cols and 1 row are not usable by any other
// iterate over pairs of H (hor), V (vert).
// count ways to configure only H pairs horizontally (catalan number)
// next count ways to insert V pairs into the horizontal pairs (already fixed): C(H + V + 1, V)
// next count ways to configure the heights (should be exact same thing)
// lastly count ways to do the empty squares. if x col and y rows
// consider u have an array of lenth x and 1 <= a_i <= y
// count the ways to do that (can be precomputed for each x/y)
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
43 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
344 KB |
Output is correct |
17 |
Correct |
10 ms |
348 KB |
Output is correct |
18 |
Correct |
11 ms |
348 KB |
Output is correct |
19 |
Correct |
50 ms |
348 KB |
Output is correct |
20 |
Correct |
39 ms |
348 KB |
Output is correct |
21 |
Correct |
26 ms |
348 KB |
Output is correct |
22 |
Correct |
25 ms |
344 KB |
Output is correct |
23 |
Correct |
13 ms |
348 KB |
Output is correct |
24 |
Correct |
69 ms |
348 KB |
Output is correct |
25 |
Correct |
51 ms |
348 KB |
Output is correct |
26 |
Correct |
59 ms |
348 KB |
Output is correct |
27 |
Correct |
67 ms |
344 KB |
Output is correct |