最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 1791B - Following Directions

2023-07-03 08:39 作者:您是打尖兒還是住店呢  | 我要投稿

Alperen is standing at the point (0,0). He is given a string s of length n and performs n moves.

?The i-th move is as follows:

if si=L, then move one unit left;

if si=R, then move one unit right;

if si=U, then move one unit up;

if si=D, then move one unit down.

There is a candy at?(1,1)(1,1)?(that is, one unit above and one unit to the right of Alperen's starting point). You need to determine if Alperen ever passes the candy.




Input

The first line of the input contains an integer t (1≤t≤1000) — the number of testcases.


The first line of each test case contains an integer n (1≤n≤50) — the length of the string.


The second line of each test case contains a string s of length n consisting of characters L, R, D, and U, denoting the moves Alperen makes.


Output

For each test case, output "YES" (without quotes) if Alperen passes the candy, and "NO" (without quotes) otherwise.


You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

easy 題目 模擬,向右則x++,向上則y++,每次判斷x,y是否都等于1即可。

等于了,就輸出yes,不等于就輸出no。

下面是代碼:


CF 1791B - Following Directions的評論 (共 條)

分享到微博請遵守國家法律
平安县| 尼勒克县| 宁阳县| 中江县| 门头沟区| 宁强县| 卓资县| 海南省| 巴楚县| 临漳县| 怀化市| 龙游县| 嘉义市| 新竹市| 常宁市| 临沭县| 安图县| 福泉市| 桐柏县| 高陵县| 阳曲县| 宜宾市| 法库县| 兴和县| 万盛区| 高邑县| 马山县| 灵丘县| 岚皋县| 浏阳市| 小金县| 江华| 大洼县| 广水市| 屯昌县| 灌阳县| 巍山| 曲靖市| 且末县| 常州市| 贵定县|