CSES Problemset/Introductory Problems
Grid Path Description
#1625Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude DesktopThere 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
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.
Sample Test Cases (1)
Example 1ID: sample-1
Input
??????R??????U??????????????????????????LD????D?
Expected Output
201
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 charsTest Bench
Input (stdin)
??????R??????U??????????????????????????LD????D?
Expected Output
201