problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
luogu::P3741类 参考

洛谷 P3741 honoka的键盘 更多...

#include <luogu.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

洛谷 P3741 honoka的键盘

在文件 luogu.h549 行定义.

成员函数说明

◆ main()

int luogu::P3741::main ( istream &  cin,
ostream &  cout 
)
static

在文件 luogu.cpp2024 行定义.

2024 {
2025 int n;
2026 bool flag = false;
2027 int ans = 0;
2028 cin >> n;
2029 string str;
2030 cin >> str;
2031 for(int i = 0; i < n - 1; i++) {
2032 if(str[i] == 'V') {
2033 if(str[i + 1] == 'K') {
2034 ans++;
2035 } else if(i + 2 == n || i + 2 < n && str[i + 2] != 'K') {
2036 flag = true;
2037 }
2038 } else if(str[i + 1] == 'K' && (i - 1 >= 0 && str[i - 1] != 'V' || i == 0)) {
2039 flag = true;
2040 }
2041 }
2042 if(flag) {
2043 ans++;
2044 }
2045 cout << ans;
2046 return 0;
2047 }

被这些函数引用 luogu::TEST().


该类的文档由以下文件生成: