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"You are given a board of size 2 x n ( 2 rows, n columns). Some cells of the board contain chips. The chip is represented as '*', and an empty space is represented as '.'. It is guaranteed that there is at least one chip on the board. In one move, you can choose any chip and move it to any adjacent (by side) cell of the board (if this cell is inside the board). It means that if the chip is in the first row, you can move it left, right or down (but it shouldn't leave the board). Same, if the chip is in the second row, you can move it left, right or up. If the chip moves to the cell with another chip, the chip in the destination cell disappears (i. xe2 x80 x89e. our chip captures it). Your task is to calculate the minimum number of moves required to leave exactly one chip on the board. You have to answer t independent test cases. The first line of the input contains one integer t ( 1 <= t <= 2 cdot 10^4 ) -- the number of test cases. Then t test cases follow. The first line of the test case contains one integer n ( 1 <= n <= 2 cdot 10^5 ) -- the length of the board. The second line of the test case contains the string s_1 consisting of n characters '*' (chip) and/or '.' (empty cell). The third line of the test case contains the string s_2 consisting of n characters '*' (chip) and/or '.' (empty cell). Additional constraints on the input: For each test case, print one integer -- the minimum number of moves required to leave exactly one chip on the board. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
157076273 |
kakel_san |
E |
May 13, 2022, 4:47 p.m. |
OK |
C# 8 |
TESTS |
42 |
951 |
31436800 |
|
|
157071967 |
Gassa |
E |
May 13, 2022, 4:29 p.m. |
OK |
D |
TESTS |
42 |
62 |
13516800 |
|
|
157112270 |
lzy2021 |
E |
May 14, 2022, 4:30 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
409600 |
|
|
157065893 |
Linx. |
E |
May 13, 2022, 4:11 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
409600 |
|
|
157099345 |
liympanda |
E |
May 13, 2022, 10:31 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
1843200 |
|
|
157072272 |
PIGGOD |
E |
May 13, 2022, 4:30 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
1945600 |
|
|
157117400 |
XIXI1257660 |
E |
May 14, 2022, 5:56 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
2048000 |
|
|
157117117 |
XIXI1257660 |
E |
May 14, 2022, 5:52 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
2048000 |
|
|
157104141 |
_jsgnt |
E |
May 14, 2022, 1:35 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
2048000 |
|
|
157101395 |
L7-56 |
E |
May 13, 2022, 11:55 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
3584000 |
|
|
157078901 |
wuhudsm |
E |
May 13, 2022, 5:10 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
14028800 |
|
|
157069988 |
Gamble_King |
E |
May 13, 2022, 4:24 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
409600 |
|
|
remove filters
Back to search problems