无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

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

分享到微博請遵守國家法律
旬阳县| 丽水市| 伊宁市| 洛扎县| 合作市| 石狮市| 江城| 沭阳县| 海盐县| 黑龙江省| 苍南县| 桂阳县| 句容市| 烟台市| 凤城市| 泉州市| 长宁县| 南阳市| 通榆县| 永寿县| 高尔夫| 朝阳市| 平遥县| 正安县| 太和县| 洛南县| 页游| 莱西市| 阿克陶县| 防城港市| 大安市| 赫章县| 彭山县| 常宁市| 贡山| 乌拉特后旗| 钦州市| 湖口县| 眉山市| 盐亭县| 布尔津县|