#P1039. 网格路径描述 (Grid Path Description)
网格路径描述 (Grid Path Description)
Source: CSES Problem Set (Task 1625)
Link: https://cses.fi/problemset/task/1625
Category: Introductory Problems
- Time limit: 1.00 s
- Memory limit: 512 MB
There are paths in a grid from the upper-left square to the lower-left square. Each path corresponds to a -character description consisting of characters D (down), U (up), L (left) and R (right).
For example, the path
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
The only input line has a -character string of characters ?, D, U, L and R.
Output
Print one integer: the total number of paths.
Example
Input:
??????R??????U??????????????????????????LD????D?
Output:
201