92分求助
查看原帖
92分求助
324277
qywk99楼主2020/7/8 10:17
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	//freopen("in.txt","r",stdin);
	int n;
	cin>>n;
	string str;
	cin>>str;
	int cnt=0;
	for(int i=1;i<n;i++){
		if(str[i]=='K'&&str[i-1]=='V'){
			cnt++;
			str[i]=str[i-1]==' ';
		}
	}
	for(int i=1;i<n;i++){
		if((str[i]=='V' && str[i-1]=='V')||(str[i]=='K'&& str[i-1]=='K')){
			cnt++;
			break;
		}
	}
	cout<<cnt;
	return 0;
}


2020/7/8 10:17
加载中...