There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint on the i-th block. If there already is a footprint on the i-th block, the new footprint will cover the old one.

At the beginning, there were no footprints. Then polar bear Alice starts from the s-th block, makes a sequence of moves and ends in the t-th block. It is known that Alice never moves outside of the road.

You are given the description of Alice’s footprints. Your task is to find a pair of possible values of s, t by looking at the footprints.

Input
The first line of the input contains integer n (3 ≤ n ≤ 1000).

The second line contains the description of the road — the string that consists of n characters. Each character will be either “.” (a block without footprint), or “L” (a block with a left footprint), “R” (a block with a right footprint).

It’s guaranteed that the given string contains at least one character not equal to “.”. Also, the first and the last character will always be “.”. It’s guaranteed that a solution exists.

Output
Print two space-separated integers — the values of s and t. If there are several possible solutions you can print any of them.

Example
Input
9
..RRLL…
Output
3 4
Input
11
.RRRLLLLL..
Output
7 5
Note
The first test sample is the one in the picture.

#include<cstdio>
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<string>
using namespace std;
int main()
{int num;cin>>num;string str;cin>>str;int start,end,diff;for(int i=0;i<str.size();i++)if(str[i]!='.'){start=i;break;}for(int i=start;i<str.size();i++)if(str[i]==str[start])diff=i; for(int i=str.size()-1;i>=0;i--)if(str[i]!='.'){end=i;break;}if(str[start]=='R'){if(str[diff+1]=='.')cout<<start+1<<" "<<diff+2; else if(str[diff+1]=='L')cout<<start+1<<" "<<diff+1;}else{cout<<end+1<<" "<<start;}return 0;
}

Snow Footprints相关推荐

  1. Codeforces Round #180 (Div. 2) A. Snow Footprints 贪心

    A. Snow Footprints 题目连接: http://www.codeforces.com/contest/298/problem/A Description There is a stra ...

  2. CodeForces 298A Snow Footprints

    1.http://codeforces.com/problemset/problem/298/A 2.题目大意:给定一个小球,可以往左往右移动,如果小球从第i个位置移到第i+1个位置,那么第i个位置将 ...

  3. 文章标题 CoderForces 298A: Snow Footprints(水)

    Snow Footprints Description There is a straight snowy road, divided into n blocks. The blocks are nu ...

  4. Snow Footprints CodeForces - 298A

    There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left ...

  5. 298A Snow Footprints

    http://codeforces.com/problemset/problem/298/A 归纳题,若是存在R或者L,则必定左边为R,右边卫L,开始地点随意定在存在L或者R的位置,结束地点定在L和R ...

  6. Codeforces 298A Snow Footprints 题解

    题意 雪地里有一条路,可以向左走.向右走,每走一步会在这一步的起点留下一个朝向走的方向的脚印,新脚印会覆盖旧脚印,现给出脚印的情况,判断起点和终点 思路 如果只有一个方向的脚印,那就是从脚印的一头走到 ...

  7. 【Codeforces】A2组刷题记录(50 / 50)完结

    目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...

  8. 在虚拟机中如何安装Mac OS X Snow Leopard 10.6

    前一段时间由于心血来潮,也由于在twitter上经常看到tinyfoo等大虾说苹果的优势.自己就先装个Mac OS系统学习一下,本人是狂热的小黑迷,原来在bestbuy和老婆在看Macbook Pro ...

  9. AWS — AWS Snow 系列

    目录 文章目录 目录 AWS Snow 系列 AWS Snowcone AWS Snowball AWS Snowmobile AWS Snow 系列 AWS Snow 系列可为需要在严峻的非数据中心 ...

最新文章

  1. Fragment 复习一
  2. 有道精品课python-网易词典在线翻译
  3. 在eclipse导入SSH项目
  4. linux宝塔类似工具,有没有比宝塔面板更好的linux运维工具?
  5. ubuntu16.04安装gradle
  6. 关于未能启用约束。一行或多行中包含违反非空、唯一或外键约束的值的解决方法...
  7. 用keil怎么擦除_环氧树脂结构胶怎么清洗 结构胶弄到衣服上怎么洗掉
  8. poj 1125 Floyd简单
  9. java 加锁_Java中的重重“锁”事
  10. 计算机图形学 dda,计算机图形学直线DDA算法和Bresenham算法精选.doc
  11. Ubuntu录制gif图
  12. 黑马程序员-黑马,人生的一个重要转折
  13. js身份证号计算性别
  14. ubuntu系统安装到移动硬盘
  15. 与卡耐基梅隆大学博士交流笔记
  16. 手机怎么识别图片上的文字
  17. 拆弹实验-phase_1
  18. 精彩回顾 | 苏州农商银行新一代云原生信息科技架构体系实践
  19. 递归算法之蜜蜂路线问题
  20. 侯捷 C++内存管理

热门文章

  1. 卖家云 oracle集成,卖家云—专业级SAAS化ERP店铺管理
  2. python 2到100的素数_po视频app下载安装|西瓜视频app下载安装_电脑知识学习网
  3. 以彼之道,还施彼身:Android 模拟定位
  4. SitePoint播客#144:免费增补Schmeemium
  5. win10繁体字 与 简体字 切换 快捷键 繁体字改简体字
  6. 常用版本名称含义:SNAPSHOT-alpha-beta-release-GA等
  7. Python3爬取OpenStreetMap平台的城市道路交通网数据
  8. 分数化成有限小数的方法_分数化成小数最简单的方法就是直接用分子除以分母...
  9. Acunetix 简介 为什么需要保护您的 Web 应用程序
  10. Service基础(实现IBinder)(二)