# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
203197 |
2020-02-19T19:13:57 Z |
tri |
Tents (JOI18_tents) |
C++14 |
|
107 ms |
71080 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
#define pb push_back
#define f first
#define s second
const int MAXN = 3005;
const ll MOD = 1e9 + 7;
ll dp[MAXN][MAXN];
int main() {
int N, M;
cin >> N >> M;
memset(dp, 0, sizeof(dp));
for (int i = 0; i < N; i++) {
dp[i][0] = 1;
}
for (int j = 0; j < M; j++) {
dp[0][j] = 1;
}
for (int r = 1; r <= N; r++) {
for (int c = 1; c <= M; c++) {
// nothing in top row
ll sum = dp[r - 1][c];
// one unpaired in top row, 4 possible orientations, all columns
sum = (sum + 4 * c * dp[r - 1][c - 1]) % MOD;
// two in same column
if (r >= 2) {
sum = (sum + c * (r - 1) * dp[r - 2][c - 1]) % MOD;
}
//two in same row
if (c >= 2) {
sum = (sum + c * (c - 1) / 2 * dp[r - 1][c - 2]) % MOD;
}
dp[r][c] = sum;
}
}
cout << dp[N][M] << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
71032 KB |
Output is correct |
2 |
Correct |
40 ms |
71032 KB |
Output is correct |
3 |
Correct |
40 ms |
71032 KB |
Output is correct |
4 |
Correct |
39 ms |
71032 KB |
Output is correct |
5 |
Correct |
40 ms |
71036 KB |
Output is correct |
6 |
Correct |
39 ms |
71032 KB |
Output is correct |
7 |
Correct |
40 ms |
71032 KB |
Output is correct |
8 |
Correct |
41 ms |
71032 KB |
Output is correct |
9 |
Correct |
40 ms |
71032 KB |
Output is correct |
10 |
Correct |
40 ms |
71032 KB |
Output is correct |
11 |
Correct |
48 ms |
71080 KB |
Output is correct |
12 |
Correct |
39 ms |
71032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
71032 KB |
Output is correct |
2 |
Correct |
40 ms |
71032 KB |
Output is correct |
3 |
Correct |
40 ms |
71032 KB |
Output is correct |
4 |
Correct |
39 ms |
71032 KB |
Output is correct |
5 |
Correct |
40 ms |
71036 KB |
Output is correct |
6 |
Correct |
39 ms |
71032 KB |
Output is correct |
7 |
Correct |
40 ms |
71032 KB |
Output is correct |
8 |
Correct |
41 ms |
71032 KB |
Output is correct |
9 |
Correct |
40 ms |
71032 KB |
Output is correct |
10 |
Correct |
40 ms |
71032 KB |
Output is correct |
11 |
Correct |
48 ms |
71080 KB |
Output is correct |
12 |
Correct |
39 ms |
71032 KB |
Output is correct |
13 |
Correct |
40 ms |
71032 KB |
Output is correct |
14 |
Correct |
39 ms |
71032 KB |
Output is correct |
15 |
Correct |
80 ms |
71032 KB |
Output is correct |
16 |
Correct |
43 ms |
71032 KB |
Output is correct |
17 |
Correct |
49 ms |
71032 KB |
Output is correct |
18 |
Correct |
52 ms |
71032 KB |
Output is correct |
19 |
Correct |
89 ms |
71032 KB |
Output is correct |
20 |
Correct |
76 ms |
71032 KB |
Output is correct |
21 |
Correct |
64 ms |
71032 KB |
Output is correct |
22 |
Correct |
64 ms |
71032 KB |
Output is correct |
23 |
Correct |
56 ms |
71032 KB |
Output is correct |
24 |
Correct |
107 ms |
71032 KB |
Output is correct |
25 |
Correct |
90 ms |
71032 KB |
Output is correct |
26 |
Correct |
92 ms |
71032 KB |
Output is correct |
27 |
Correct |
102 ms |
71032 KB |
Output is correct |