cswork / OA打开练习工作台

GuidewireOA #1

Minimum Boys Next to Girls

估计中等可在线判题

考点(AI 标注)贪心调度字符串

Place the minimum number of boys in empty seats so that every girl has at least one directly adjacent seat occupied by a boy.

This site's standard input/output format and additional bounds are as described in this problem.

输入格式

One line containing a string s (1≤|s|≤2×10^5) consisting only of G and -.

输出格式

Output the minimum number of boys; output -1 if it is impossible.

样例 1

输入:

-G-GG--

输出:

2

样例 2

输入:

G-G

输出:

1

样例 3

输入:

G

输出:

-1