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

By |2017-07-24T01:19:26+00:00July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , , |

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