From d92a049cea91d69aa326a9f5ec9790f65f751f0b Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Mon, 21 Sep 2020 19:49:44 +0800 Subject: [PATCH] =?UTF-8?q?P3741=20honoka=E7=9A=84=E9=94=AE=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R38667882 --- problem/P3741/P3741.cpp | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 problem/P3741/P3741.cpp diff --git a/problem/P3741/P3741.cpp b/problem/P3741/P3741.cpp new file mode 100644 index 00000000..f1af911d --- /dev/null +++ b/problem/P3741/P3741.cpp @@ -0,0 +1,47 @@ +// R38667882 + +#include + +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; +}