Snow Footprints CodeForces - 298A

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 }
时间: 2024-10-01 04:27:19

Snow Footprints CodeForces - 298A的相关文章

codeforces 的20道C题

A - Warrior and Archer CodeForces - 595C n  偶数  然后n个数字 A B 轮流取一个 A让差变小B让差变大 直到最后2 个   求的是最小剩下的差 最后剩下的 L R  相距 n/2    求一下最小的就行 #include <iostream> #include <cstdio> #include <cmath> #include <map> #include <algorithm> #include

Mutual Training for Wannafly Union #2

codeforces 298A. Snow Footprints 分类讨论三种情况: ①..RRRRRR-  ②..LLLLLLL- ③..RRRLLLL.. //AC by lwq: #include<stdio.h> #include<algorithm> #include<string> #include<string.h> using namespace std; int main() { int n; scanf("%d",&a

Codeforces Round #339 Div.2 C - Peter and Snow Blower

Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to so

[CodeForces - 614C] C - Peter and Snow Blower

C - Peter and Snow Blower Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work

Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)C. Producing Snow+差分标记

题目链接:C. Producing Snow 题意:给两个数组v[N],T[N],v[i]表示第i天造的雪,T[i],表示第i天的温度,一堆雪如果<=T[i],当天就会融完,否则融化T[i],要求输出每天的融雪总量. 题解:我对T数组求个前缀和,就可以二分找到每堆雪在那一天(pos)融化,余下的要加进答案中ans[i],然后用一个an数组在a[i]+1,a[pos]-1,最后求再求一次前缀和. ans[i]再加上an[i]*t[i].每次操作二分logn,N次操作.复杂度O(nlogn) #in

【基数排序】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) C. Jon Snow and his Favourite Number

发现值域很小,而且怎么异或都不会超过1023--然后可以使用类似基数排序的思想,每次扫一遍就行了. 复杂度O(k*1024). #include<cstdio> #include<cstring> using namespace std; int n,k,x,cnts[1110],tmpcnts[1110]; int main() { // freopen("c.in","r",stdin); int X; scanf("%d%d%

CodeForces - 948C Producing Snow(优先队列)

题意: n天. 每天你会堆一堆雪,体积为 v[i].每天都有一个温度 t[i] 所有之前堆过的雪在第 i 天体积都会减少 t[i] . 输出每天融化了的雪的体积. 这个题的正解我怎么想都很难理解,但是慢慢理解了. 计算一个 t[i] 的前缀和 sum. 那么到第 j 天时,设第 i 堆雪融化的体积是 V,则 V = min (sum [ j ] - sum[ i-1], v[ i ] ) 所以把 v[ i ] + sum[ i -1] 加入优先队列里,就可以只处理所有当天能化完的雪了. 若 su

Codeforces Round #399 B 思维 C 模拟 D 概率dp E SG博弈

Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined)B. Code For 1 题意:数n,不断拆分为 n/2, n&1, n/2,直到都为0或1.求区间[l, r]有多少个1. tags:画一画很容易看出来,类似dfs中序遍历. //#399 B #include<bits/stdc++.h> using namespace std; #pragma comment(linker, &quo

Codeforces 839D Winter is here - 暴力 - 容斥原理

Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers. He has created a m