CF264A.Escape from Stones

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbered from 1 to n in order.

The stones always fall to the center of Liss's interval. When Liss occupies the interval [k - d, k + d] and a stone falls to k, she will escape to the left or to the right. If she escapes to the left, her new interval will be [k - d, k]. If she escapes to the right, her new interval will be [k, k + d].

You are given a string s of length n. If the i-th character of s is "l" or "r", when the i-th stone falls Liss will escape to the left or to the right, respectively. Find the sequence of stones' numbers from left to right after all the n stones falls.

松鼠莉丝原本平静地生活在森林中,但意外的麻烦发生了:石头从山上滚落。初始时,莉丝占据区间 [0, 1][0, 1]。接下来将有 nn 块石头依次落下,莉丝需躲避这些石头。石头按顺序编号为 11 到 nn。

石头总是落在莉丝当前区间的正中心。当莉丝当前占据区间 [k − d, k + d][k - d, k + d],且一块石头落在位置 kk 时,她将向左或向右躲避。若向左躲避,则她的新区间变为 [k − d, k][k - d, k];若向右躲避,则新区间变为 [k, k + d][k, k + d]。

给定一个长度为 nn 的字符串 ss。若 ss 的第 ii 个字符为 "l" 或 "r",则表示当第 ii 块石头落下时,莉丝分别向左或向右躲避。求所有 nn 块石头全部落下后,从左到右排列的石头编号序列。

输入格式

The input consists of only one line. The only line contains the string s (1 ≤ |s| ≤ 106). Each character in s will be either "l" or "r".

输入仅包含一行。该行包含字符串 ss(1 ≤ ∣s∣ ≤ 1061 \le |s| \le 10^6)。字符串 ss 中的每个字符均为 "l" 或 "r"。

输出格式

Output n lines — on the i-th line you should print the i-th stone's number from the left.

输出 n 行——在第 i 行上,应输出从左往右数第 i 块石头的编号。

输入输出样例

  • 输入#1

    llrlr

    输出#1

    3
    5
    4
    2
    1
  • 输入#2

    rrlll

    输出#2

    1
    2
    5
    4
    3
  • 输入#3

    lrlrr

    输出#3

    2
    4
    5
    3
    1

说明/提示

In the first example, the positions of stones 1, 2, 3, 4, 5 will be , respectively. So you should print the sequence: 3, 5, 4, 2, 1.

在第一个例子中,石头 1、2、3、4、5 的位置分别为 。因此,你应该输出序列:3, 5, 4, 2, 1。

输入解题思路,AI测评打分。不知道怎么写?

首页