1、双行道,中间出错了,弄了太大时间 import sys n = int(input()) map = [sys.stdin.readline().strip() for _ in range(2)] class Solution: def __init__(self, n): self.nums = [[-1]*n]*2 def roads(self, n, map, site1=1, site2=1): if site2 == n: if site1 == 2 or map[1][site2-1] is not 'X': return 1 num = 0 if map[0][site2] is not 'X': if self.nums[0][site2] == -1: self.nums[0][site2] = self.roads(n, map, 1, site2+1) num += self.nums[0][site2] if map[1][site2] is not 'X': if self.nums[1][site2] == -1: self.nums[1][site2] = self.roads(n, map, 2, site2+1) num += self.nums[1][site2] return num num = Solution(n).roads(n, map) print(num if num > 0 else -1)
点赞 1

相关推荐

贪食滴🐶:你说熟悉扣篮的底层原理,有过隔扣职业球员的实战经验吗
点赞 评论 收藏
分享
面试摇了我吧:啊哈哈面试提前五个小时发,点击不能参加就是放弃
点赞 评论 收藏
分享
牛客网
牛客企业服务