#P9183. [USACO23OPEN] FEB B
[USACO23OPEN] FEB B
题目描述
Bessie and Elsie are plotting to overthrow Farmer John at last! They plan it out
over text messages. Their conversation can be
represented by a string of length where is either B or E,
meaning the 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 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 . 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
.
输入格式
The first line will consist of one integer .
The next line contains .
输出格式
First output , the number of distinct excitement levels possible. On the next lines, output the excitement levels, in increasing order.
题目大意
题目描述
贝西和埃尔希正在密谋最终推翻他们的主人——农夫约翰!他们通过 条短信进行计划。他们的对话可以用一个长度为 的字符串 来表示。
其中 是字母 B 或 E,这意味着第 条消息分别由贝西或埃尔希发送的。
然而,农夫约翰听说了这个消息,并试图拦截他们的谈话。因此,字符串 的一些字母是 F,这意味着农夫约翰混淆了信息,发件人未知(贝西、埃尔希都有可能)。
注:约翰没有发送信息!他只是在干扰奶牛间的通话!
未混淆对话的兴奋程度是一只奶牛重复发送信息的次数。也就是说,子串 BB 或 EE 在 中出现的次数。你想找到原始信息的兴奋程度,但你不知道约翰的信息中哪一条实际上是贝西或埃尔希的。在所有可能的情况下,从小到大输出所有可能的兴奋程度。
输入格式
第一行:一个整数 (通话长度)。
第二行:一个字符串 (通话内容)。
输出格式
第一行:输出一个整数 ,为不同兴奋程度的可能数量。
随后 行:每行一个整数,为每种兴奋程度。注意按照从小到大的顺序输出。
数据范围
。
- 测试点 4~8:
- 测试点 9~20:无额外限制。
4
BEEF
2
1
2
9
FEBFEBFEB
2
2
3
10
BFFFFFEBFE
3
2
4
6
提示
.
- Inputs 4-8: .
- Inputs 9-20: No additional constraints.