package main import . "fmt" func main() { var h,w int Scan(&h,&w) f:=make([][]byte,h) for i:=range f { var s string Scan(&s) f[i]=[]byte(s) } ps:=[]int{0,0,1} var ans int for len(ps)>0 { n:=len(ps)-3 x,y,c:=ps[n],ps[n+1],ps[n+2] ps=ps[:n] if x+10 { ps=append(ps,x+1,y,c-1) } } if y+10 { ps=append(ps,x,y+1,c-1) } } if x+1==w&&y+1==h { ans++ } } Println(ans) }