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

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

CF 1779A - Hall of Fame

2023-07-18 14:54 作者:您是打尖兒還是住店呢  | 我要投稿

Thalia is a Legendary Grandmaster in chess. She has n trophies in a line numbered from 1 to n (from left to right) and a lamp standing next to each of them (the lamps are numbered as the trophies).

A lamp can be directed either to the left or to the right, and it illuminates all trophies in that direction (but not the one it is next to). More formally, Thalia has a string s consisting only of characters 'L' and 'R' which represents the lamps' current directions. The lamp i illuminates:

trophies 1,2,…,i?1 if si is 'L';trophies i+1,i+2,…,n if si is 'R'.

She can perform the following operation at most once:


Choose an index i (1≤i<n);Swap the lamps i and i+1 (without changing their directions). That is, swap si with si+1.

Thalia asked you to illuminate all her trophies (make each trophy illuminated by at least one lamp), or to tell her that it is impossible to do so. If it is possible, you can choose to perform an operation or to do nothing. Notice that lamps cannot change direction, it is only allowed to swap adjacent ones.

----------------------------------------------------------

塔利亞是一位傳奇的國際象棋大師。 她有 n 個獎杯,排成一排,編號從 1 到 n(從左到右),每個獎杯旁邊都立著一盞燈(燈被編號為獎杯)。

一盞燈可以指向左側(cè)或右側(cè),它會照亮該方向上的所有獎杯(但不會照亮旁邊的獎杯)。 更正式地說,Thalia 有一個僅由字符“L”和“R”組成的字符串 s,表示燈的當(dāng)前方向。 燈 i 亮起:

如果 si 為“L”,則獎杯 1,2,…,i?1;如果 si 為“R”,則獎杯 i+1,i+2,…,n。

她最多可以執(zhí)行一次以下操作:


選擇一個索引i(1≤i<n);交換燈i和i+1(不改變它們的方向)。 即,將si 與si+1 交換。

塔莉亞要求你照亮她所有的獎杯(讓每個獎杯至少被一盞燈照亮),或者告訴她這是不可能的。 如果可能,您可以選擇執(zhí)行操作或不執(zhí)行任何操作。 請注意,燈不能改變方向,只能交換相鄰的燈。

-------------------------------------------

substring卡了下,啊,我的腦仁啊。。。


CF 1779A - Hall of Fame的評論 (共 條)

分享到微博請遵守國家法律
安福县| 迭部县| 平陆县| 卢氏县| 樟树市| 商丘市| 佛教| 驻马店市| 平陆县| 教育| 吉林省| 蒲江县| 桂东县| 历史| 康保县| 游戏| 侯马市| 连城县| 桃源县| 天水市| 河东区| 沙雅县| 巍山| 五家渠市| 张掖市| 九台市| 汕头市| 武城县| 安义县| 和田县| 沙坪坝区| 徐闻县| 荆门市| 崇明县| 大同市| 沁阳市| 阿巴嘎旗| 花莲市| 弥勒县| 漳浦县| 思茅市|