【CodeForces - 264A】Escape from Stones (模拟,卡精度的处理)

题干:

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, nstones 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.

Input

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".

Output

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

Examples

Input

llrlr

Output

3
5
4
2
1

Input

rrlll

Output

1
2
5
4
3

Input

lrlrr

Output

2
4
5
3
1

Note

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.

题目大意:

  有一只松鼠,他在【0,1】这个区间,然后有一堆石头从天而降,每次都是砸在他所在区间的中间,他会选择向左或者向右跳,问从左到右输出石头的编号。

解题报告:

  直接开long double 也会炸精度,,,这题其实同时放大几倍 就好了啊,因为一共有n个操作,所以就用n这么大的数组,然后模拟就行了。

 

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 1e6 + 6;
char s[MAX];
int a[MAX];
int main() 
{cin>>(s+1);int len = strlen(s+1);int l = 1,r = len;for(int i = 1; i<=len; i++) {if(s[i] == 'l') a[l++]=i;else a[r--]=i;  } for(int i = len; i>=1; i--) printf("%d\n",a[i]);return 0;
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/441182.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【CodeForces - 270A】Fancy Fence (几何,思维,水题)

题干&#xff1a; Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot. He wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fenc…

判断集合相等_数学启蒙的每个关键阶段之集合分类

本文我们将分享数学启蒙学什么&#xff1f;用几个字简单的归纳为集合、数、量、形、时间、空间。我们接下来会讲感知集合和分类&#xff0c;数概念&#xff0c;量的概念&#xff0c;形状包含平面图形和立体图形&#xff0c;空间方位和时间的初步概念。 家长们可以发现幼儿数学启…

【CodeForces - 270C】Magical Boxes (思维,进制,有坑)

题干&#xff1a; Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes. From the top view each magical box looks like a square with side leng…

虚拟机安装黑群晖_【群晖系统】HEI群辉DSM 6.2.1 系统安装图文教程 (19年2月)

黑群晖系统其实是指在普通电脑运行Synology DSM系统, 事实上在普通PC电脑上安装黑群晖(Synology DSM)也非常方便, 现在把教程简单写一下。引导系统装哪里&#xff1f;非常关键的问题&#xff0c;DSM采用系统和数据相分离的结构&#xff0c;也就是说引导系统需要独立安装在一个设…

mysql 主从 keepalived_MySQL之双向主从加keepalived高可用

最近在做MySQL数据库的双向主从&#xff0c;了解到keepalived能够自动判断并切换到可用数据库&#xff0c;自己试了一下&#xff0c;整理出文档来。先声明一下环境iptables开启3306端口或者关掉&#xff0c;关闭selinuxMySQL-01&#xff1a;192.168.204.138MySQL-02&#xff1a…

docker启动mysql容器_Docker容器开机自启动

查看所有容器[vagrantlocalhost ~]$ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3f142f72d7e8 redis "docker-entr…

【CodeForces - 527C】Glass Carving(线段树或者SBT或者set)

题干&#xff1a; Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm    h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understand…

mysql常驻内存_MySQL的内存和相关问题排查

我们都知道数据库是IO密集型一类应用&#xff0c;为了提高其性能大量使用内存代替文件(交换分区)的IO操作是保证数据库稳定、高效的基本原则。那么数据库是如何使用内存的&#xff0c;我们如何查看数据库内存的占用&#xff0c;如何通过通过数据库内存配置设置提高其性能&#…

java短除法获取二进制_Java十四天零基础入门-Java的数据类型介绍

不闲聊&#xff01;&#xff01;&#xff01;不扯淡&#xff01;&#xff01;&#xff01;小UP只分享Java相关的资源干货本章节目标&#xff1a;理解数据类型的作用。Java中包括哪些数据类型&#xff1f;常见的八种基本数据类型都有哪些&#xff1f;会用八种基本数据类型声明变…

vs怎么把textbox输入的实数放置变量里_方程的计算机处理96(3)_C++vs

计算机语言运用--数值计算9-方程的计算机处理96(3)_Cvs计算机&#xff1a;电子线路组成的计算机器。人与计算机则是通过计算机语言-符号系统说给计算机听而交流。计算机语言有低级语言-机器语言、汇编、高级语言-C/C/C#/VB/PASCAL/LISP/JAVA/PYTHON/……成百上千种之多。作为一…

2008r装mysql_mysql5.7.17在win2008R2的64位系统安装与配置实例

安装MySql操作系统&#xff1a;Windows Server 2008 R2 StandardMySql版本&#xff1a;mysql-5.7.17-winx64第一步&#xff1a;解压mysql-5.7.17-winx64.zip到指定位置第二步&#xff1a;安装文件根目录下添加data文件夹&#xff0c;将my-default.ini重命名为my.ini第三步&…

【HDU - 5187】zhx's contest (快速幂+ 快速乘,模板)

题干&#xff1a; 2018百度之星复赛晋级名单出炉&#xff08;增加20%晋级名额&#xff09;~ zhxs contest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3779 Accepted Submission(s): 1226 Problem Desc…

【牛客 - 283E】贪心只能过样例(模拟)

题干&#xff1a; 小西是单身狗&#xff0c;所以她不喜欢看到有CP在秀恩爱&#xff01; 有一天&#xff0c;小西出来闲逛&#xff0c;发现街上的行人都排成了一排&#xff0c;并且可以用这种形式表示&#xff1a; MMFMMFFFMMM 其中M表示男孩子&#xff0c;F表示女装的男孩…

apmserver导入MySQL_mysql数据库导入导出

window下1.导出整个数据库mysqldump -u 用户名 -p 数据库名 > 导出的文件名mysqldump -u dbuser -p dbname > dbname.sql2.导出一个表mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名mysqldump -u dbuser -p dbname users> dbname_users.sql3.导出一个数据库结…

【牛客 - 283C】模拟只会猜题意(简单模拟)

题干&#xff1a; 小西突然觉得回文串是一种非常优雅的东西&#xff0c;她突然想要把身边所有的字符串都变成回文&#xff01; 所谓回文串就是一个倒置后仍与自身相等的字符串&#xff0c;如“gxuacmmcauxg”和“gxuacmcauxg”。 小西不喜欢单身狗&#xff0c;所以小西只会…

sql开启mysql远程连接_SQLServer2008设置开启远程连接

SQLServer2008设置开启INTERNET远程连接 SQL Server 2008默认是不允许远程连接的&#xff0c;sa帐户默认禁用的&#xff0c;如果想要在本地用SSMS连接远程服务器上的SQL Server 2008&#xff0c;需要做两个部分的配置&#xff1a; 使用sa账户登录SQL Server Management Studio(…

【牛客 - 283H】图论一顿套模板(思维转化,Dijkstra)

题干&#xff1a; 由于临近广西大学建校90周年校庆&#xff0c;西大开始了喜闻乐见的校园修缮工程&#xff01; 然后问题出现了&#xff0c;西大内部有许许多多的道路&#xff0c;据统计有N栋楼和M条道路&#xff08;单向&#xff09;&#xff0c;每条路都有“不整洁度”W&…

spss相关性分析看结果_spss相关性分析

当我们想要了解变量的相关程度时,就需要用到相关分析,而相关分析也是回归之前很重要的一步,通常用到的方法是pearson方法。 首先解释一下相关系数,相关系数反应的是两个变量之间变化趋势的方向以及程度,其值范围为-1到+1,正值表示正相关,负值表示负相关,绝对值越大表示…

【牛客 - 283F】出装方案(最小费用最大流)

题干&#xff1a; 众所周知&#xff0c;在各种对抗类游戏里装备都是很重要的一环&#xff0c;不同的出装方案会给玩家带来不同的强度。 dalao手里有N件装备&#xff0c;现在dalao要把装备分给N个队友&#xff0c;每个队友只能分一件装备&#xff0c;而每个队友穿上不同的装…

【CodeForces - 289D】Polo the Penguin and Houses (带标号的无根树,Cayley定理,Prufer编码)

题干&#xff1a; Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n). Little penguin Po…