A. Snow footprintstime limit per test
1 second
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
There is a straight snowy Road, dividedNBlocks. The blocks are numbered from 1NFrom left to right. If one moves fromI-Th block to (I+ 1)-TH Block, he will leave a right footprint onI-TH Block. Similarly, if one moves fromI-Th block to (I-1)-TH Block, he will leave a left footprint onI-TH Block. If there already is a footprint onI-TH Block, the new footprint will cover the old one.
At the beginning, there were no footprints. Then polar bear Alice starts fromS-TH Block, makes a sequence of moves and ends inT-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 valuesS,TBy looking at the footprints.
Input
The first line of the input contains integerN(3 ≤N≤ 1000 ).
The second line contains the description of the road-the string that consistsNCharacters. 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 ". ". also, the first and the last character will always be ". ". it's guaranteed that a solution exists.
Output
Print two space-separated integers-the valuesSAndT. If there are several possible solutions you can print any of them.
Sample test (s) Input
9..RRLL...
Output
3 4
Input
11.RRRLLLLL..
Output
7 5
Note
The first test sample is the one in the picture.
# Include <stdlib. h>
# Include <string. h>
# Include <stdio. h>
Char input [1010];
Int R1 = 0, R2 = 0, L1 = 0, L2 = 0;
Void getr ()
{
Int I;
For (I = 0; I <strlen (input); I ++)
{
If (input [I] = 'R ')
{
R1 = I;
Break;
}
}
If (I = strlen (input ))
{
R1 =-1;
R2 =-1;
Return;
}
Else
{
For (I = strlen (input)-1; I> = 0; I --)
{
If (input [I] = 'R ')
{
R2 = I;
Break;
}
}
}
}
Void getl ()
{
Int I;
For (I = strlen (input)-1; I> = 0; I --)
{
If (input [I] = 'l ')
{
L2 = I;
Break;
}
}
If (I <0)
{
L1 =-1;
L2 =-1;
Return;
}
Else
{
For (I = 0; I <strlen (input); I ++)
{
If (input [I] = 'l ')
{
L1 = I;
Break;
}
}
}
}
Void solve ()
{
If (r1 =-1)
{
Printf ("% d \ n", l2 + 1, L1 );
}
Else if (L2 =-1)
{
Printf ("% d \ n", R1 + 1, r2 + 2 );
}
Else
{
Printf ("% d \ n", R1 + 1, r2 + 1 );
}
}
Int main (INT argc, char * argv [])
{
// Freopen ("data. In", "r", stdin );
Int Len;
While (scanf ("% d", & Len )! = EOF)
{
Scanf ("% s", input );
Getr ();
Getl ();
Solve ();
}
Return 0;
}