大模拟,复杂度 O(n2) , WA了, 86pts
#include<bits/stdc++.h>
using namespace std;
int n,ma=-1;
string s,d;
int count(){
int cnt=0,p=d.find("VK");
while(p!=-1){
cnt++;
p=d.find("VK",p+1);
}
return cnt;
}
int main() {
cin>>n>>s;
ma=count();
for(int i=1;i<=n;i++){
d=s;
if(d[i]=='V') d[i]='K';
else d[i]='V';
ma=max(count(),ma);
}
cout<<ma;
return 0;
}
之前做过这题对了直接贴过来居然错了