You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
int maxN;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取字符串中有多少个VK
|
|
|
|
|
*/
|
|
|
|
|
int getVkCount(string s) {
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
for (int i = 0; i < s.size() - 1; i++) //注意这里的-1
|
|
|
|
|
if (s[i] == 'V' && s[i + 1] == 'K') cnt++;
|
|
|
|
|
return cnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
int n;
|
|
|
|
|
string s;
|
|
|
|
|
cin >> n >> s;
|
|
|
|
|
//计算一下原始的VK个数
|
|
|
|
|
maxN = getVkCount(s);
|
|
|
|
|
//变换
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
string s1 = s;
|
|
|
|
|
s1[i] = s1[i] == 'K' ? 'V' : 'K';//该个变换一下,这个三元表达式用的很舒服~
|
|
|
|
|
//重新计算最大个数值
|
|
|
|
|
maxN = max(maxN, getVkCount(s1));
|
|
|
|
|
}
|
|
|
|
|
printf("%d", maxN);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|