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);
}

(Visited 15 times, 1 visits today)

About the Author:

Leave A Comment