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