mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P3741 honoka的键盘
R38667882
This commit is contained in:
parent
f0c2c7434a
commit
d92a049cea
47
problem/P3741/P3741.cpp
Normal file
47
problem/P3741/P3741.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
// R38667882
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int count(string str) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < str.size() - 1; i++)
|
||||
if (str[i] == 'V' && str[i + 1] == 'K')
|
||||
sum++;
|
||||
return sum;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n, max;
|
||||
string str;
|
||||
|
||||
cin >> n >> str;
|
||||
|
||||
max = count(str);
|
||||
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
if (str[i] == 'V') {
|
||||
str[i] = 'K';
|
||||
}
|
||||
else {
|
||||
str[i] = 'V';
|
||||
}
|
||||
|
||||
int s = count(str);
|
||||
|
||||
if (s > max) {
|
||||
max = s;
|
||||
}
|
||||
if (str[i] == 'V') {
|
||||
str[i] = 'K';
|
||||
}
|
||||
else {
|
||||
str[i] = 'V';
|
||||
}
|
||||
}
|
||||
|
||||
cout << max << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user