#63657. [ USACO 2023 Open Bronze]FEB

[ USACO 2023 Open Bronze]FEB

暂无测试数据。

英文题面

Bessie and Elsie are plotting to overthrow Farmer John at last! They plan it out over $N(1\leq N\leq 2⋅10^5)$ text messages. Their conversation can be represented by a string $S$ of length $N$ where $S_i$ is either B or E, meaning the i-th message was sent by Bessie or Elsie, respectively. However, Farmer John hears of the plan and attempts to intercept their conversation. Thus, some letters of $S$ are F, meaning Farmer John obfuscated the message and the sender is unknown.

The excitement level of a non-obfuscated conversation is the number of times a cow double-sends - that is, the number of occurrences of substring BB or EE in $S$ . You want to find the excitement level of the original message, but you don’t know which of Farmer John’s messages were actually Bessie’s / Elsie’s. Over all possibilities, output all possible excitement levels of $S$.

译文

贝茜(Bessie)和艾尔西(Elsie)终于密谋推翻约翰农夫!他们通过 $N(1\leq N\leq 2⋅10^5)$ 条文本消息计划这件事。他们的对话可以由长度为 $N$ 的字符串 $S$ 表示,其中 $S_i$ 要么是 B 表示这是贝茜发送的第 $i$ 条消息,要么是 E 表示这是艾尔西发送的第 $i$ 条消息。然而,约翰农夫得知了计划并试图截取他们的对话。因此,一些字母在字符串 $S$ 中被替换成了 F,表示农夫约翰混淆了消息,发送者不确定。

在非混淆的对话中,兴奋度是指“重复发送”的次数,也就是字符串 $S$ 中子串 BBEE 的出现次数。您想找到原始消息的兴奋度,但您不知道农夫约翰的哪些消息实际上是贝茜 / 艾尔西发出的。在所有可能性中,输出字符串 $S$ 所有可能的兴奋度。

输入格式

The first line will consist of one integer $N$. The next line contains $S$. 第一行包含整数 $N$。

第二行包含字符串$S$。

输出格式

First output $K$, the number of distinct excitement levels possible. On the next $K$ lines, output the excitement levels, in increasing order.

首先输出$K$,代表所有可能的等级,接下来$K$行每行一个数,按照递增顺序输出所有的可能的兴奋度。

数据范围

  • Inputs 4-8: N≤10

  • Inputs 9-20: No additional constraints.

  • 输入4-8:$N\leq 10$

  • 输入 9-20: 没有额外限制

4
BEEF
2
1
2

9
FEBFEBFEB
2
2
3

10
BFFFFFEBFE
3
2
4
6