CSES - Grid Path Description

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://cses.fi/problemset/task/1625
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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 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 ~48~-character string of characters ?, D, U, L and R.

Output

  • Print one integer: the total number of paths.

Example Input

??????R??????U??????????????????????????LD????D?

Example Output

201

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.