아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

FEB

시간 제한2초메모리 제한1024 MB

요약
B, E, F로 이루어진 문자열에서 각 F를 B 또는 E로 바꿀 때 가능한 인접한 같은 문자 쌍 개수의 모든 값을 구한다.
난이도

보통10점 중 7점

유형
문자열, 그리디, 수학, 구현
정답자
아직 제출이 없습니다

문제

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 S_iS\_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.

예제3

  1. 예제 1

    입력
    4
    BEEF
    
    예상 출력
    2
    1
    2
    
  2. 예제 2

    입력
    9
    FEBFEBFEB
    
    예상 출력
    2
    2
    3
    
  3. 예제 3

    입력
    10
    BFFFFFEBFE
    
    예상 출력
    3
    2
    4
    6