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&nbs***bsp;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)