-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path17070.cpp
57 lines (50 loc) · 1007 Bytes
/
17070.cpp
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
#include <stdio.h>
#include <stdlib.h>
int result;
int size;
int house[16][16]={0,};
void pipe(int x, int y, int vec){
if(x==size-1 && y==size-1){
result++;
return;
}
if(vec==0){
if(y+1<size && house[x][y+1]==0){
pipe(x,y+1,0);
}
if(x+1<size && y+1<size && (house[x+1][y+1]==0 && house[x][y+1]==0 && house[x+1][y]==0)){
pipe(x+1, y+1, 2);
}
}
else if(vec==1){
if(x+1<size && house[x+1][y]==0){
pipe(x+1, y, 1);
}
if(x+1<size && y+1<size && (house[x+1][y+1]==0 && house[x][y+1]==0 && house[x+1][y]==0)){
pipe(x+1, y+1, 2);
}
}
else{
if(y+1<size && house[x][y+1]==0){
pipe(x, y+1, 0);
}
if(x+1<size && house[x+1][y]==0){
pipe(x+1, y, 1);
}
if(x+1<size && y+1<size && (house[x+1][y+1]==0 && house[x][y+1]==0 && house[x+1][y]==0)){
pipe(x+1, y+1, 2);
}
}
}
int main(){
int i,j;
result=0;
scanf("%d",&size);
for(i=0;i<size;i++){
for(j=0;j<size;j++){
scanf("%d",&house[i][j]);
}
}
pipe(0,1,0);
printf("%d\n",result);
}