6695.Grid Path Description

Time Limit: 1s Memory Limit: 512MB

There are $88418$ paths in a $7 \times 7$ grid from the upper-left square to the lower-left square. Each path corresponds to a $48$ -character description consisting of characters D (down), U (up), L (left) and R (right).

For example, the path

1625-1.png

corresponds to the description DRURRRRRDDDLUULDDDLDRRURDDLLLLLURULURRUULDLLDDDD.

You are given a description of a path which may also contain characters ? (any direction). Your task is to calculate the number of paths that match the description.

Input Format(From the terminal/stdin)

The only input line has a $48$ -character string of characters ? , D , U , L and R .

Output Format(To the terminal/stdout)

Print one integer: the total number of paths.

Sample Input

Copy
??????R??????U??????????????????????????LD????D?
                                                \n

Sample Output

Copy
201
   \n
Source: CSES, Introductory Problems, 1625

Submit

请先 登录

© 2025 FAQs