#PU1323. USACO 2023 US Open Contest, Bronze — Problem 1. FEB

    ID: 1636 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 普及 上传者: 标签>USACO赛事:open23来源:usaco.orgscoring:equal_test_cases枚举前缀和

USACO 2023 US Open Contest, Bronze — Problem 1. FEB

USACO 2023 US Open Contest, Bronze — Problem 1. FEB

题目描述

Bessie and Elsie are plotting to overthrow Farmer John at last! They plan it out over NN (1≤N≤2⋅1051\le N\le 2\cdot 10^5) text messages. Their conversation can be represented by a string SS of length NN where SiS_i is either BB or EE, meaning the iith 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 SS are FF, 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 BBBB or EEEE in SS. 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 SS.

输入格式

The first line will consist of one integer NN. The next line contains SS.

输出格式

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

数据范围

Inputs 4-8: N≤10N\le 10 Inputs 9-20: No additional Problem credits: William Yue and Claire Zhang

样例

样例 1

4
BEEF
2
1
2

样例 2

9
FEBFEBFEB
2
2
3

样例 3

10
BFFFFFEBFE
3
2
4
6