-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathda66_f2_new_game_plus.cpp
More file actions
32 lines (25 loc) · 1.14 KB
/
Copy pathda66_f2_new_game_plus.cpp
File metadata and controls
32 lines (25 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 505;
const int MOD = 1e8 + 7;
int table[MAX_N][MAX_N], dp[MAX_N][MAX_N][3];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int R, C;
cin >> R >> C;
for (int i = 1; i <= R; i++) for (int j = 1; j <= C; j++) cin >> table[i][j];
for (int i = 1; i <= R; i++) if (table[i][1] == 0) {
if (i - 1 >= 0 and table[i - 1][2] == 0) dp[i - 1][2][0]++;
if (table[i][2] == 0) dp[i][2][1]++;
if (i + 1 <= R and table[i + 1][2] == 0) dp[i + 1][2][2]++;
}
for (int j = 2; j < C; j++) for (int i = 1; i <= R; i++) if (table[i][j] == 0) {
if (i - 1 >= 0 and table[i - 1][j + 1] == 0) dp[i - 1][j + 1][0] = (dp[i - 1][j + 1][0] + dp[i][j][1] + dp[i][j][2]) % MOD;
if (table[i][j + 1] == 0) dp[i][j + 1][1] = (dp[i][j + 1][1] + dp[i][j][0] + dp[i][j][2]) % MOD;
if (i + 1 <= R and table[i + 1][j + 1] == 0) dp[i + 1][j + 1][2] = (dp[i + 1][j + 1][2] + dp[i][j][0] + dp[i][j][1]) % MOD;
}
int ans = 0;
for (int i = 1; i <= R; i++) ans = (ans + dp[i][C][0] + dp[i][C][1] + dp[i][C][2]) % MOD;
cout << ans;
return 0;
}