Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.
#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");
}
📦 Looking for Codeforces Round 382 Div Problem Ostap? Check the best deals on Amazon.
🛒 Shop Codeforces Round 382 Div Problem Ostap on Amazon
As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.
Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.
#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");
}
📦 Looking for Codeforces Round 382 Div Problem Ostap? Check the best deals on Amazon.
🛒 Shop Codeforces Round 382 Div Problem Ostap on Amazon
As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.