Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2), problem: (A) Vicious Keyboard Solution In C/C++

#include <stdio.h>
int ans,l,i;
int main()
{
char ch[110];
scanf(“%s”,ch);
for( ; ch[i+1]; i++)
{
l++;
if(ch[i]==’V’ && ch[i+1]==’K’)
ans++,ch[i]=’#’,ch[i+1]=’#’,i++;
}
l++;
for(i=0; ch[i+1]; i++)
{
if((ch[i]==’V’ && ch[i+1]==’V’) || (ch[i]==’K’&&ch[i+1]==’K’))
{
ans++;
break;
}
}

printf(“%d”,ans);
}

Leave a Reply

Your email address will not be published. Required fields are marked *