AC日记——Vicious Keyboard codeforces 801a
思路:
水题;
来,上代码:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int len,ans; char s[205]; int check() { int res=0; for(int i=1;i<len;i++) { if(s[i]=='V'&&s[i+1]=='K') res++; } return res; } int main() { cin>>s+1; len=strlen(s+1); ans=check(); for(int i=1;i<=len;i++) { if(s[i]=='V') { s[i]='K'; ans=max(ans,check()); s[i]='V'; } else { s[i]='V'; ans=max(ans,check()); s[i]='K'; } } cout<<ans; return 0; }