比赛 |
EYOI与SBOI开学欢乐赛9th |
评测结果 |
AWWAAAAAAA |
题目名称 |
Photoshoot |
最终得分 |
80 |
用户昵称 |
HeSn |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-09-30 20:50:49 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 100010;
int n;
string s;
signed main() {
freopen("photoshoot_bronze_22open.in", "r", stdin);
freopen("photoshoot_bronze_22open.out", "w", stdout);
cin >> n >> s;
int ans = 0, cnt = 0, k = 0;
for(int i = 1; i <= n; i += 2) {
int a = i - 1, b = i;
if(s[a] == 'G' && s[b] == 'G') {
continue;
}
if(s[a] == 'G') {
k = 1;
}
if(s[b] == 'G') {
if(k == 1) {
k = 0;
cnt ++;
ans ++;
if(cnt != 1) {
ans ++;
}
}
}
}
if(k == 1 && cnt == 0) {
ans ++;
}
if(k == 1 && cnt != 0) {
ans += 2;
}
cout << ans;
return 0;
}