CF1285A.Mezo Playing Zoma

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Today, Mezo is playing a game. Zoma, a character in that game, is initially at position x=0x = 0. Mezo starts sending nn commands to Zoma. There are two possible commands:

  • 'L' (Left) sets the position x:=x−1x: =x - 1;
  • 'R' (Right) sets the position x:=x+1x: =x + 1.

Unfortunately, Mezo's controller malfunctions sometimes. Some commands are sent successfully and some are ignored. If the command is ignored then the position xx doesn't change and Mezo simply proceeds to the next command.

For example, if Mezo sends commands "LRLR", then here are some possible outcomes (underlined commands are sent successfully):

  • "LRLR" — Zoma moves to the left, to the right, to the left again and to the right for the final time, ending up at position 00;
  • "LRLR" — Zoma recieves no commands, doesn't move at all and ends up at position 00 as well;
  • "LRLR" — Zoma moves to the left, then to the left again and ends up in position −2-2.

Mezo doesn't know which commands will be sent successfully beforehand. Thus, he wants to know how many different positions may Zoma end up at.

今天,梅佐正在玩一个游戏。游戏中有一个角色佐玛,初始位置为 x=0x = 0。梅佐将向佐玛发送 nn 条指令。指令仅有两种可能:

  • 'L'(左):令位置更新为 x:=x−1x := x - 1;
  • 'R'(右):令位置更新为 x:=x+1x := x + 1。

不幸的是,梅佐的控制器有时会失灵。部分指令能成功发送,而另一些则会被忽略。若某条指令被忽略,则位置 xx 保持不变,梅佐直接继续执行下一条指令。

例如,若梅佐发送指令串 "LRLR",则以下是一些可能的结果(下划线标出成功发送的指令):

  • "LRLR" — 佐玛依次向左、向右、向左、向右移动,最终停在位置 00;
  • "LRLR" — 佐玛未接收到任何指令,全程未移动,最终仍停在位置 00;
  • "LRLR" — 佐玛先向左移动,再向左移动,最终停在位置 −2-2。

梅佐事先并不知道哪些指令会被成功发送。因此,他想知道:佐玛最终可能停在多少个不同的位置上?

输入格式

The first line contains nn (1≤n≤105)(1 \le n \le 10^5) — the number of commands Mezo sends.

The second line contains a string ss of nn commands, each either 'L' (Left) or 'R' (Right).

第一行包含一个整数 nn(1≤n≤1051 \le n \le 10^5)—— Mezo 发送的指令数量。

第二行包含一个长度为 nn 的字符串 ss,其中每个字符为 'L'(左)或 'R'(右)。

输出格式

Print one integer — the number of different positions Zoma may end up at.

输出一个整数——Zoma 可能到达的不同位置的数量。

输入输出样例

  • 输入#1

    4
    LRLR

    输出#1

    5

说明/提示

In the example, Zoma may end up anywhere between −2-2 and 22.

在示例中,Zoma 最终可能位于 −2-2 到 22 之间的任意位置。

输入解题思路,AI测评打分。不知道怎么写?

首页