比赛 EYOI与SBOI开学欢乐赛9th 评测结果 AAAAAAAAAA
题目名称 Photoshoot 最终得分 100
用户昵称 op_组撒头屯 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2022-09-30 21:28:45
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int N=200000+5;
int n,a[N],cnt=0;
char s[N];
int main(){
	freopen ("photoshoot_bronze_22open.in","r",stdin);
	freopen ("photoshoot_bronze_22open.out","w",stdout);
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int i=1;i<=n;i+=2){
	    if (s[i]=='G'&&s[i+1]=='G')continue;
	    if (s[i]=='G')a[++cnt]=i;
	    if (s[i+1]=='G')a[++cnt]=i+1;
    }
    int ans=0,lst=-1;
    for (int i=1;i<=cnt;i++){
        if (a[i]%2!=lst)ans++,lst=a[i]%2;
    }
    if (lst==0)ans--;
    printf("%d\n",ans);
    return 0;
}