-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoj0203.cpp
More file actions
58 lines (53 loc) · 1.15 KB
/
aoj0203.cpp
File metadata and controls
58 lines (53 loc) · 1.15 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
while(1) {
int x, y;
cin >> y >> x;
if(x==0 && y==0) break;
int field[x][y];
for(int i=0; i<x; i++) {
for(int j=0; j<y; j++) {
cin >> field[i][j];
}
}
int dp[x+1][y];
for(int i=0; i<x+1; i++) {
for(int j=0; j<y; j++) {
dp[i][j] = 0;
}
}
for(int i=0; i<x; i++) {
for(int j=0; j<y; j++) {
if(i==0 && field[i][j] == 0) dp[i][j] = 1;
else {
if(field[i][j] == 0) {
if(0<j && field[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
if(j<y-1 && field[i-1][j+1] == 0) dp[i][j] += dp[i-1][j+1];
}
if(field[i][j] == 2) {
if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
if(field[i+2][j] != 1) dp[i+2][j] += dp[i][j];
}
}
}
}
for(int i=0; i<y; i++) dp[x][i] += dp[x-1][i];
int sum=0;
for(int i=0; i<y; i++) sum += dp[x][i];
cout << sum << endl;
//cout << endl;
//for(int i=0; i<x+1; i++) {
//for(int j=0; j<y; j++) {
//cout << dp[i][j] << ' ';
//}
//cout << endl;
//}
}
return 0;
}