日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 735A 】Ostap and Grasshopper (水题,模拟)

發布時間:2023/12/10 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 735A 】Ostap and Grasshopper (水题,模拟) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題干:

On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length?n?such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to one of the empty cells and a small insect in another empty cell. The grasshopper wants to eat the insect.

Ostap knows that grasshopper is able to jump to any empty cell that is?exactly?kcells away from the current (to the left or to the right). Note that it doesn't matter whether intermediate cells are empty or not as the grasshopper makes a jump over them. For example, if?k?=?1?the grasshopper can jump to a neighboring cell only, and if?k?=?2?the grasshopper can jump over a single cell.

Your goal is to determine whether there is a sequence of jumps such that grasshopper will get from his initial position to the cell with an insect.

Input

The first line of the input contains two integers?n?and?k?(2?≤?n?≤?100,?1?≤?k?≤?n?-?1)?— the number of cells in the line and the length of one grasshopper's jump.

The second line contains a string of length?n?consisting of characters '.', '#', 'G' and 'T'. Character '.' means that the corresponding cell is empty, character '#' means that the corresponding cell contains an obstacle and grasshopper can't jump there. Character 'G' means that the grasshopper starts at this position and, finally, 'T' means that the target insect is located at this cell. It's guaranteed that characters 'G' and 'T' appear in this line?exactly once.

Output

If there exists a sequence of jumps (each jump of length?k), such that the grasshopper can get from his initial position to the cell with the insect, print "YES" (without quotes) in the only line of the input. Otherwise, print "NO" (without quotes).

Examples

Input

5 2 #G#T#

Output

YES

Input

6 1 T....G

Output

YES

Input

7 3 T..#..G

Output

NO

Input

6 2 ..GT..

Output

NO

Note

In the first sample, the grasshopper can make one jump to the right in order to get from cell?2?to cell?4.

In the second sample, the grasshopper is only able to jump to neighboring cells but the way to the insect is free?— he can get there by jumping left?5?times.

In the third sample, the grasshopper can't make a single jump.

In the fourth sample, the grasshopper can only jump to the cells with odd indices, thus he won't be able to reach the insect.

解題報告:

? 有點簡單,直接模擬、

AC代碼:

#include<bits/stdc++.h>using namespace std;int main() {int n,k,st,ed,flag = 0;;cin>>n>>k;char s[105];scanf("%s",s);for(int i = 0; i<n; i++) {if(s[i] == 'G') st = i,flag = 1;if(s[i] == 'T') ed = i,flag = 2;}if(abs(st-ed) % k != 0) {printf("NO\n");return 0 ;}if(st > ed) swap(st,ed);for(int i = st; i<=ed; i+=k) {if(s[i] == '#') {printf("NO\n");return 0 ;}}printf("YES\n");return 0 ; }

?

總結

以上是生活随笔為你收集整理的【CodeForces - 735A 】Ostap and Grasshopper (水题,模拟)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。