Codeforces Round #382 (Div. 2), problem: (A) Ostap and Grasshopper Solution in C/C++

By |2017-04-07T22:11:48+00:00December 17th, 2016|Categories: C/C++, Programming|Tags: , , , , , , |

  #include<stdio.h> int b[105],d[105]; int main(){ int i,s,n,k,t; scanf("%d%d",&n,&k); char x; for(i=1;i<=n;i++){ scanf(" %c",&x); if(x=='G')s=i; if(x=='T')t=i; if(x=='#')b[i]=1; } for(i=s;i<=n;i+=k){ if(b[i]) break; d[i]=1; } for(i=s;i>=1;i-=k){ if(b[i]) break; d[i]=1; } if(d[t]) printf("YES"); else printf("NO"); }