日韩性视频-久久久蜜桃-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 (水题,模拟)的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 国产精品久久久久久久天堂 | 黄色特级网站 | 黑人一区 | 久久影院一区二区 | 欧洲日韩一区二区三区 | 狠狠躁夜夜躁人爽 | 成人必看www.| 国产精品-区区久久久狼 | 日日摸日日 | 中文字幕日韩精品亚洲一区小树林 | 一级片黄色 | 色男人天堂av | 国产乱码精品一区二区三区五月婷 | 爱爱亚洲 | 夜夜操操 | 农村妇女愉情三级 | www国产亚洲精品久久麻豆 | 亚洲综合av一区二区三区 | 最好看的2019中文大全在线观看 | 伊人成综合网 | 探花视频在线版播放免费观看 | 国产91精品一区二区麻豆亚洲 | 九九热精品视频在线播放 | 午夜影院在线观看免费 | 老司机精品视频网站 | 长篇h版少妇沉沦交换 | 国产一级二级av | 日韩欧美一卡 | www.在线观看av| 一区二区三区久久精品 | 日本免费网| 日本不卡三区 | 日本青青草视频 | 黄色小说在线视频 | 亚洲欧洲无码一区二区三区 | 国产寡妇色xxⅹ交肉视频 | 黑人欧美一区二区三区 | 人妻少妇被粗大爽9797pw | 韩国av电影在线观看 | 免费看的一级片 | 日本黄色免费看 | 成人wwxx免费观看 | 久久亚洲美女 | 成人区人妻精品一区 | 天堂av观看| 日本三区视频 | 奇米影视第四色7777 | 国产精品毛片久久久久久久av | 99久久人妻无码精品系列 | 成人福利免费视频 | 麻豆一区二区三区 | 国产一线二线三线女 | 中文av免费 | 久久久欧美精品sm网站 | 亚洲成人aa| 亚洲无码精品国产 | 天天影视综合 | 小h片在线观看 | 变态 另类 国产 亚洲 | 亚洲午夜精品视频 | 国产伦精品一区二区三区高清版禁 | 97在线精品 | 韩国伦理片在线观看 | 成人写真福利网 | 羞羞成人 | 日韩女优在线视频 | 欧美国产乱视频 | 亚洲自拍偷拍第一页 | 日韩欧美三级在线 | 欧美激情精品久久久久久免费 | 日韩黄色网 | 欧美啪啪一区二区 | 久久久社区 | 色网视频| 国产aa视频| 精品国产乱码久久久久久影片 | 日本黄色免费网址 | 亚洲视频在线观看免费视频 | 人人澡澡人人 | 国产精品99无码一区二区视频 | 丁香五色月 | 合欢视频在线观看 | 91热精品 | 打屁股黄文 | 精品一区二区三区在线视频 | 亚洲免费视 | 精品国产制服丝袜高跟 | 欧美精品毛片 | 欧美国产在线观看 | 日韩一区二区三区av | 无套日出白浆 | 久久久久91 | 红桃视频在线播放 | 伊人网影院 | 亚洲国产精品va在线看黑人 | 欧美婷婷 | 伊人天天| 亚洲精品18在线观看 | 成人影音在线 |