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.

 1 #include<cstdio>
 2 #include<string>
 3 #include<cstring>
 4 #include<iostream>
 5 #include<algorithm>
 6 using namespace std;
 7 typedef long long ll;
 8
 9 const int INF=100000;
10
11 int main()
12 {   int n;
13     cin>>n;
14     char a[1005];
15     scanf("%s",a);
16     int len=strlen(a),rp=INF,rq=-1,lp=INF,lq=-1;
17     for(int i=0;i<len;i++){
18         if(a[i]=='R') { rp=min(rp,i); rq=max(rq,i); }
19         if(a[i]=='L') { lp=min(lp,i); lq=max(lq,i); }
20     }
21     bool rf=false,lf=false;
22     if(rp==INF&&rq==-1) rf=true;
23     if(lp==INF&&lq==-1) lf=true;
24     if(rf) cout<<lq+1<<" "<<lp<<endl;
25     if(lf) cout<<rp+1<<" "<<rq+2<<endl;
26     if(!rf&&!lf) cout<<rp+1<<" "<<lp<<endl;
27 }

转载于:https://www.cnblogs.com/zgglj-com/p/7257982.html

Snow Footprints CodeForces - 298A相关推荐

  1. CodeForces 298A Snow Footprints

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

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

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

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

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

  4. Codeforces 298A Snow Footprints 题解

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

  5. 298A Snow Footprints

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

  6. Snow Footprints

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

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

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

  8. 【二分】Producing Snow @Codeforces Round #470 Div.2 C

    time limit per test: 1 second memory limit per test: 256 megabytes Alice likes snow a lot! Unfortuna ...

  9. Codeforces Round #470 (rated, Div. 2 C. Producing Snow(思维)

    C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input standard in ...

最新文章

  1. Word中新建样式/修改样式对话框中的各个选项意义
  2. WIN8、WIN7访问Windows Server 2003服务器的数据库速度很慢、远程速度很慢的解决方法...
  3. vsim生成VCD波形文件(verilog)
  4. PyQt:成功解决PyQt4升级到PyQt5改变的函数或方法
  5. MySQL中的索引(主键索引)
  6. JAVA字符串的替换replace、replaceAll、replaceFirst的区别解析。
  7. android vue.js点击反应慢,解决vue 界面在苹果手机上滑动点击事件等卡顿问题
  8. asp.net web api集成微信服务(使用Senparc微信SDK)
  9. 使用BIND安装智能DNS服务器(一)---基本的主从DNS服务器搭建
  10. Java TCP/UDP编程
  11. 购物车demo(内含bug)
  12. MockServer的测试思想与实现
  13. pytorch nn.CrossEntropyLoss()中的label不需要是one_hot
  14. 史上最完整的MySQL注入
  15. HTML转义字符表的使用
  16. lenovo微型计算机如何拆t410,联想thinkpad T410S全面拆解
  17. Spark versus Flink: Understanding Performance in Big Data Analytics Frameworks论文总结
  18. FANUC机器人:奇异点回避功能介绍与使用方法
  19. FreeMarker标签使用以及精度数字的处理
  20. php音视频边下边播,视频个别片段加旁白,就是我边播放视频边录制旁白或声音...

热门文章

  1. Android如何测试wifi时延,如何检测WIFI连接何时已经在Android中建立?
  2. 如何在mysql中录入数据库_如何向MySQL数据库的表中录入数据
  3. excel超链接应用:快速生成目录的几个方法-上
  4. 分子量 (Molar Mass, ACM/ICPC Seoul 2007, UVa1586)
  5. 动量风险因子 matlab,期货市场存在较强的时间序列动量效应
  6. 使用Java对返回的结果,封装成指定JSON格式的数据类型
  7. LinearLayout下如何实现两端对齐
  8. 信息安全复习三:古典密码之设计好的密码算法
  9. 死磕Ubuntu18(完)
  10. 利用bastille配置安全的linux系统