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

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
新河县| 天门市| 华亭县| 营口市| 峨边| 延吉市| 南京市| 三河市| 徐水县| 庆阳市| 安徽省| 紫云| 连江县| 女性| 南丹县| 临泉县| 离岛区| 石门县| 乡宁县| 沐川县| 杨浦区| 甘洛县| 鄂托克前旗| 威远县| 巴彦县| 得荣县| 江口县| 垣曲县| 衡山县| 鄯善县| 武冈市| 和田市| 措美县| 呼和浩特市| 都兰县| 盘锦市| 淮滨县| 泸州市| 定西市| 探索| 富锦市|