走方格(walk)
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
【题目描述】
一个无穷大的二维平面,Bob 开始站在 (0,0) 点。
Alice 命令他走 n 步,Alice 的命令为 'U', 'D', 'L', 'R' 中的一种,分别表示上、下、左、右。Bob 收到一个命令后,会朝着 Alice 给出的方向走一个单位。
Bob 想知道,在走完这 n 步后,他一共到过多少个格子。
【输入格式】
第一行一个整数 n,意义如上所述。
接下来一行为一个长度为 n 的字符串,每个字符为 'U', 'D', 'L', 'R' 中的一个。
【输出格式】
一行一个整数,表示答案。
【样例输入1】
5
UDUDU
【样例输出1】
2
【样例输入2】
5
ULDLU
【样例输出2】
6
【数据范围】
对于 60% 的数据,满足 1≤n≤1000。
对于 100% 的数据,满足 1≤n≤10^5^。
2024-10-23CSP-J模拟赛
- Status
- Done
- Rule
- IOI
- Problem
- 4
- Start at
- 2024-10-23 8:30
- End at
- 2024-10-31 16:30
- Duration
- 200 hour(s)
- Host
- Partic.
- 16