Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'There are n + 1 cities, numbered from 0 to n . n roads connect these cities, the i -th road connects cities i - 1 and i ( i in [1, n] ). Each road has a direction. The directions are given by a string of n characters such that each character is either L or R. If the i -th character is L, it means that the i -th road initially goes from the city i to the city i - 1 ; otherwise it goes from the city i - 1 to the city i . A traveler would like to visit as many cities of this country as possible. Initially, they will choose some city to start their journey from. Each day, the traveler must go from the city where they currently are to a neighboring city using one of the roads, and they can go along a road only if it is directed in the same direction they are going; i. xe2 x80 x89e., if a road is directed from city i to the city i + 1 , it is possible to travel from i to i + 1 , but not from i + 1 to i . After the traveler moves to a neighboring city, all roads change their directions to the opposite ones. If the traveler cannot go from their current city to a neighboring city, their journey ends; it is also possible to end the journey whenever the traveler wants to. The goal of the traveler is to visit as many different cities as possible (they can visit a city multiple times, but only the first visit is counted). For each city i , calculate the maximum number of different cities the traveler can visit during exactly one journey if they start in the city i . The first line contains one integer t ( 1 <= t <= 10^4 ) -- the number of test cases. Each test case consists of two lines. The first line contains one integer n ( 1 <= n <= 3 cdot 10^5 ). The second line contains the string s consisting of exactly n characters, each character is either L or R. It is guaranteed that the sum of n over all test cases'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
105943518 |
NewbieFly |
D |
Jan. 29, 2021, 5 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
61 |
2764800 |
|
|
105970079 |
comld |
D |
Jan. 30, 2021, 12:56 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
61 |
13004800 |
|
|
105942034 |
lszxj |
D |
Jan. 29, 2021, 4:51 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
62 |
1536000 |
|
|
105934785 |
wrxi |
D |
Jan. 29, 2021, 4:28 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
62 |
1536000 |
|
|
105974065 |
HHHEN |
D |
Jan. 30, 2021, 2:56 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
62 |
2662400 |
|
|
105959345 |
Yoitsu_Holo |
D |
Jan. 29, 2021, 7:48 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
62 |
2662400 |
|
|
105943716 |
NewbieFly |
D |
Jan. 29, 2021, 5:01 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
62 |
2662400 |
|
|
105971667 |
zhl |
D |
Jan. 30, 2021, 1:51 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
62 |
2764800 |
|
|
105943354 |
foreverxr |
D |
Jan. 29, 2021, 4:59 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
62 |
2764800 |
|
|
105973835 |
do_while_true |
D |
Jan. 30, 2021, 2:50 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
62 |
3584000 |
|
|
remove filters
Back to search problems