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'Alice and Bob always had hard time choosing restaurant for the dinner. Previously they performed Eenie Meenie Miney Mo game, but eventually as their restaurant list grew, they had to create a new game. This new game starts as they write restaurant names on N cards and align the cards in one line. Before the game begins, they both choose starting card and starting direction they are going to. They take turns in order one after another. After each turn, they move one card in their current direction. If they reach the end or beginning of the line of cards they change direction. Once they meet in a card, the card is marked for removal and is removed the first moment they both leave the card. They repeat this process until there is only one restaurant card left. Since there are a lot of restaurant cards, they are bored to simulate this process over and over and need your help to determine the last card that remains. Can you help them? The first line of the input is one integer T ( 1 <= q T <= q 10^{4} ) representing number of test cases. Each test case contains 3 lines: The first line contains an integer N representing initial number of cards. Next line contains two integer values A,B ( 0 <= q A, B < N , 2 <= q N <= q 10^{18} ) representing starting 0-based index of the card in the array. Last line contains two strings D_A, D_B in {"left", "right"} representing starting direction of their movement. The output contains T integer number xe2 x80 x93 the 0-based index of the last card that remains for every test case in order. Note that since Alice is starting at the beginning of the line even though her initial direction is left, on her next move she will go right. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
131309008 |
dongruixuan zxjk tsugu |
B |
Oct. 9, 2021, 10:03 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
3686400 |
|
|
131372433 |
Egor.Lifar |
B |
Oct. 10, 2021, 2:21 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
0 |
|
|
131322319 |
A-SOUL_Bella A-SOUL_Ava A-SOUL_Eileen |
B |
Oct. 9, 2021, 11:52 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
30 |
3686400 |
|
|
131328072 |
xay5421 LJC00118 |
B |
Oct. 9, 2021, 12:46 p.m. |
OK |
GNU C++17 |
TESTS |
6 |
46 |
3788800 |
|
|
131354125 |
wexouv |
B |
Oct. 9, 2021, 5:49 p.m. |
OK |
GNU C++17 |
TESTS |
6 |
61 |
3686400 |
|
|
131372502 |
cookiedoth |
B |
Oct. 10, 2021, 2:23 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
4300800 |
|
|
131369669 |
Ormlis |
B |
Oct. 9, 2021, 11:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
4300800 |
|
|
131322293 |
noimi pachico mtsd |
B |
Oct. 9, 2021, 11:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
31 |
4300800 |
|
|
131324766 |
wh2005 _Wallace_61430 STUPID_JUSTIN |
B |
Oct. 9, 2021, 12:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
61 |
4300800 |
|
|
131320931 |
uwi nuip maspy |
B |
Oct. 9, 2021, 11:41 a.m. |
OK |
Java 11 |
TESTS |
6 |
202 |
23859200 |
|
|
remove filters
Back to search problems