Photoshoot

 1 Sec 64 MB |  获取标签
2420
通过人数尝试人数总提交数

 

题目描述

 

输入格式

The first line of input contains the value of N.

The second line contains a string of length N, specifying the initial ordering of the cows from left to right. Each 'H' represents a Holstein, while each 'G' represents a Guernsey.

 

输入的第一行包含 N 的值。

第二行包含一个长为 N 的字符串,给出初始时所有奶牛从左到右的排列方式。每个 'H' 代表一头荷斯坦牛,每个 'G' 代表一头更赛牛。

输出格式

Output the minimum number of reversals needed on a single line.

样例输入 #1

14
GGGHGHHGHHHGHG

样例输出 #1

1

提示

In this example, it suffices to reverse the prefix consisting of the first six cows.

  GGGHGHHGHHHGHG (Before)
-> HGHGGGHGHHHGHG (After)

Before the reversal, four Guernseys were at even positions. After the reversal, six Guernseys are at even positions. It is impossible for there to be more than six Guernseys at even positions.

来源

USACO 2022 US Open Contest, Bronze

 

 您尚未登录,无法进行代码提交