求助!!卡在88pts上不去了……悬关
查看原帖
求助!!卡在88pts上不去了……悬关
1559473
JmBecca楼主2025/1/1 22:09

知道是要判断VVK和KKV的情况,但是不知道怎么写,一个else肯定有问题,但是后面写不下去了,有没有哪位大佬救救蒟蒻……

#include<bits/stdc++.h>
using namespace std;
int n,a1=0,a2=0,a3=0,cnt=0;
string s;
int main(){
    cin>>n>>s;
    while(s.find("VK",a1)!=string::npos){
        a1=s.find("VK",a1)+1;
        cnt++;
    }
    if(int(s.find("VV"))==-1 and int(s.find("KK"))==-1)cout<<cnt;
    else cout<<cnt+1;
}
2025/1/1 22:09
加载中...