Untitled
unknown
python
3 years ago
633 B
1
Indexable
Never
def dfs(x,y,ymax): ary[y][x]+=1 if(y==ymax): return if(maps[y][x]=='S'): dfs(x-1,y+1,ymax) dfs(x+1,y+1,ymax) elif(maps[y][x]=='L'): dfs(x-1,y+1,ymax) elif(maps[y][x]=='R'): dfs(x+1,y+1,ymax) ymax,xmax,enter=input().split() ymax=int(ymax) xmax=int(xmax) enter=int(enter) maps=[] ary=[] for j in range(ymax): tmp=input() maps.append(tmp) tmp=[] for i in range(xmax): tmp.append(int(0)) ary.append(tmp) tmp=[] for i in range(xmax): tmp.append(int(0)) ary.append(tmp) dfs(enter-1,0,ymax) num=input().split() ans=0 for i in range(xmax): ans+=int(num[i])*ary[ymax][i] print(ans)