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'Bertown is a city with n buildings in a straight line. The city 's security service discovered that some buildings were mined. A map was compiled, which is a string of length n , where the i -th character is "1" if there is a mine under the building number i and "0" otherwise. Bertown 's best sapper knows how to activate mines so that the buildings above them are not damaged. When a mine under the building numbered x is activated, it explodes and activates two adjacent mines under the buildings numbered x-1 and x+1 (if there were no mines under the building, then nothing happens). Thus, it is enough to activate any one mine on a continuous segment of mines to activate all the mines of this segment. For manual activation of one mine, the sapper takes a coins. He can repeat this operation as many times as you want. Also, a sapper can place a mine under a building if it wasn 't there. For such an operation, he takes b coins. He can also repeat this operation as many times as you want. The sapper can carry out operations in any order. You want to blow up all the mines in the city to make it safe. Find the minimum number of coins that the sapper will have to pay so that after his actions there are no mines left in the city. The first line contains one positive integer t ( 1 <= t <= 10^5 ) -- the number of test cases. Then t test cases follow. Each test case begins with a line containing two integers a and b ( 1 <= a, b <= 1000 ) -- the cost of activating and placing one mine, respectively. The next line contains a map of mines in the city -- a string consisting of zeros and ones. The sum of the string lengths for all test cases does not exceed 10^5 . For each test case, output one integer -- the minimum number of coins that the sapper will have to pay. In the second test case, if we place a mine under the fourth building and then activate it, then all mines on the '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
97516350 |
yumtam |
B |
Nov. 3, 2020, 12:43 a.m. |
OK |
GNU C11 |
TESTS |
8 |
46 |
102400 |
|
|
97480248 |
babaiserror |
B |
Nov. 2, 2020, 4:07 p.m. |
OK |
GNU C11 |
TESTS |
8 |
46 |
307200 |
|
|
97481206 |
avi_p |
B |
Nov. 2, 2020, 4:09 p.m. |
OK |
GNU C11 |
TESTS |
8 |
46 |
1024000 |
|
|
97526211 |
_spryzon_ |
B |
Nov. 3, 2020, 5:02 a.m. |
OK |
GNU C11 |
TESTS |
8 |
61 |
102400 |
|
|
97487576 |
prince17 |
B |
Nov. 2, 2020, 4:25 p.m. |
OK |
GNU C11 |
TESTS |
8 |
62 |
102400 |
|
|
97505923 |
flayer_hunter |
B |
Nov. 2, 2020, 7:23 p.m. |
OK |
GNU C11 |
TESTS |
8 |
62 |
409600 |
|
|
97529675 |
loenvom |
B |
Nov. 3, 2020, 6:02 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
15 |
0 |
|
|
97525588 |
luogu_bot2 |
B |
Nov. 3, 2020, 4:49 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
15 |
614400 |
|
|
97515916 |
xwn |
B |
Nov. 3, 2020, 12:24 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
30 |
102400 |
|
|
97527418 |
Hitmman_002 |
B |
Nov. 3, 2020, 5:25 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
30 |
307200 |
|
|
97520659 |
adi_tya |
B |
Nov. 3, 2020, 2:56 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
30 |
307200 |
|
|
97519191 |
MengWH |
B |
Nov. 3, 2020, 2:21 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
30 |
409600 |
|
|
97506979 |
victoragc |
B |
Nov. 2, 2020, 7:39 p.m. |
OK |
GNU C++11 |
TESTS |
8 |
30 |
614400 |
|
|
97523203 |
HHHHHRL |
B |
Nov. 3, 2020, 3:53 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
30 |
921600 |
|
|
97523129 |
Lqingyi |
B |
Nov. 3, 2020, 3:51 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
30 |
921600 |
|
|
97526921 |
onesunny |
B |
Nov. 3, 2020, 5:15 a.m. |
OK |
GNU C++11 |
TESTS |
8 |
30 |
1126400 |
|
|
97496906 |
kitae0629 |
B |
Nov. 2, 2020, 5:31 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
15 |
307200 |
|
|
97520312 |
sravangorati2001 |
B |
Nov. 3, 2020, 2:49 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
15 |
307200 |
|
|
97521877 |
qccccc |
B |
Nov. 3, 2020, 3:21 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
30 |
204800 |
|
|
97510465 |
Mr.vajpayee |
B |
Nov. 2, 2020, 8:52 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
30 |
307200 |
|
|
97513728 |
Khadija_Assem |
B |
Nov. 2, 2020, 10:41 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
30 |
307200 |
|
|
97523967 |
present_sir |
B |
Nov. 3, 2020, 4:12 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
30 |
307200 |
|
|
97524406 |
MehrajShakil |
B |
Nov. 3, 2020, 4:22 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
30 |
307200 |
|
|
97527331 |
AKJ0811 |
B |
Nov. 3, 2020, 5:23 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
30 |
307200 |
|
|
97513703 |
Khadija_Assem |
B |
Nov. 2, 2020, 10:39 p.m. |
OK |
GNU C++14 |
TESTS |
8 |
30 |
307200 |
|
|
97522698 |
zzugzx |
B |
Nov. 3, 2020, 3:40 a.m. |
OK |
GNU C++14 |
TESTS |
8 |
30 |
307200 |
|
|
97508937 |
iamvinayvk |
B |
Nov. 2, 2020, 8:17 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
307200 |
|
|
97500101 |
Parihar |
B |
Nov. 2, 2020, 6:02 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
307200 |
|
|
97492208 |
marmik.p |
B |
Nov. 2, 2020, 4:34 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
307200 |
|
|
97509869 |
nahi_aati_coding |
B |
Nov. 2, 2020, 8:38 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
307200 |
|
|
97480108 |
coder-X |
B |
Nov. 2, 2020, 4:06 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
409600 |
|
|
97524839 |
villazer |
B |
Nov. 3, 2020, 4:31 a.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
409600 |
|
|
97506638 |
anish_sofat |
B |
Nov. 2, 2020, 7:34 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
716800 |
|
|
97489186 |
amurto |
B |
Nov. 2, 2020, 4:28 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
716800 |
|
|
97488681 |
AlexRoss |
B |
Nov. 2, 2020, 4:27 p.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
1024000 |
|
|
97526600 |
vik_nash |
B |
Nov. 3, 2020, 5:09 a.m. |
OK |
GNU C++17 |
TESTS |
8 |
15 |
1228800 |
|
|
97494783 |
coderfool |
B |
Nov. 2, 2020, 5:15 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
307200 |
|
|
97519898 |
dejavu11zzz |
B |
Nov. 3, 2020, 2:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
307200 |
|
|
97525272 |
Hetarth |
B |
Nov. 3, 2020, 4:41 a.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
307200 |
|
|
97499675 |
june_waves |
B |
Nov. 2, 2020, 5:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
716800 |
|
|
97500739 |
Arceus03 |
B |
Nov. 2, 2020, 6:10 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
1228800 |
|
|
97495753 |
kaizen_ |
B |
Nov. 2, 2020, 5:22 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
1228800 |
|
|
97480202 |
jack07 |
B |
Nov. 2, 2020, 4:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
1331200 |
|
|
97522758 |
alif_cse_ju |
B |
Nov. 3, 2020, 3:41 a.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
2252800 |
|
|
97498684 |
squishy1337 |
B |
Nov. 2, 2020, 5:48 p.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
15 |
2355200 |
|
|
97522462 |
301_anky |
B |
Nov. 3, 2020, 3:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
8 |
30 |
307200 |
|
|
97484575 |
chiendo97 |
B |
Nov. 2, 2020, 4:17 p.m. |
OK |
Go |
TESTS |
8 |
935 |
204800 |
|
|
97503796 |
codelegend |
B |
Nov. 2, 2020, 6:50 p.m. |
OK |
Haskell |
TESTS |
8 |
46 |
1126400 |
|
|
97489061 |
gsahil216 |
B |
Nov. 2, 2020, 4:28 p.m. |
OK |
Java 11 |
TESTS |
8 |
186 |
0 |
|
|
97499408 |
Agnimandur |
B |
Nov. 2, 2020, 5:55 p.m. |
OK |
Java 11 |
TESTS |
8 |
186 |
0 |
|
|
97513342 |
mphillotry |
B |
Nov. 2, 2020, 10:25 p.m. |
OK |
Java 11 |
TESTS |
8 |
187 |
0 |
|
|
97528268 |
brijeshujcbm |
B |
Nov. 3, 2020, 5:39 a.m. |
OK |
Java 11 |
TESTS |
8 |
187 |
0 |
|
|
97513835 |
abdelrahman-yousf |
B |
Nov. 2, 2020, 10:46 p.m. |
OK |
Java 11 |
TESTS |
8 |
187 |
0 |
|
|
97498664 |
sanju2504 |
B |
Nov. 2, 2020, 5:48 p.m. |
OK |
Java 11 |
TESTS |
8 |
187 |
0 |
|
|
97481968 |
LightYagami674 |
B |
Nov. 2, 2020, 4:11 p.m. |
OK |
Java 11 |
TESTS |
8 |
187 |
0 |
|
|
97524096 |
adityachandla |
B |
Nov. 3, 2020, 4:15 a.m. |
OK |
Java 11 |
TESTS |
8 |
202 |
0 |
|
|
97499737 |
singhdhanwant |
B |
Nov. 2, 2020, 5:59 p.m. |
OK |
Java 11 |
TESTS |
8 |
202 |
0 |
|
|
97485738 |
Yash-Saxena |
B |
Nov. 2, 2020, 4:20 p.m. |
OK |
Java 11 |
TESTS |
8 |
202 |
0 |
|
|
97511981 |
kareem3id |
B |
Nov. 2, 2020, 9:35 p.m. |
OK |
Java 8 |
TESTS |
8 |
93 |
0 |
|
|
97523106 |
Sjoa |
B |
Nov. 3, 2020, 3:51 a.m. |
OK |
Java 8 |
TESTS |
8 |
109 |
0 |
|
|
97514869 |
procrastinate7 |
B |
Nov. 2, 2020, 11:33 p.m. |
OK |
Java 8 |
TESTS |
8 |
109 |
0 |
|
|
97513586 |
rachitpts.2454 |
B |
Nov. 2, 2020, 10:34 p.m. |
OK |
Java 8 |
TESTS |
8 |
109 |
0 |
|
|
97512103 |
csn3rd |
B |
Nov. 2, 2020, 9:38 p.m. |
OK |
Java 8 |
TESTS |
8 |
109 |
0 |
|
|
97510019 |
iamavalon |
B |
Nov. 2, 2020, 8:41 p.m. |
OK |
Java 8 |
TESTS |
8 |
109 |
0 |
|
|
97487007 |
Bodz204 |
B |
Nov. 2, 2020, 4:23 p.m. |
OK |
Java 8 |
TESTS |
8 |
109 |
0 |
|
|
97483323 |
ay_08 |
B |
Nov. 2, 2020, 4:14 p.m. |
OK |
Java 8 |
TESTS |
8 |
109 |
0 |
|
|
97481578 |
kocko |
B |
Nov. 2, 2020, 4:10 p.m. |
OK |
Java 8 |
TESTS |
8 |
109 |
0 |
|
|
97527536 |
gagan_6730 |
B |
Nov. 3, 2020, 5:27 a.m. |
OK |
Java 8 |
TESTS |
8 |
124 |
0 |
|
|
97517431 |
Spheniscine |
B |
Nov. 3, 2020, 1:22 a.m. |
OK |
Kotlin |
TESTS |
8 |
109 |
0 |
|
|
97491729 |
rupesh.thakur |
B |
Nov. 2, 2020, 4:33 p.m. |
OK |
Kotlin |
TESTS |
8 |
140 |
0 |
|
|
97482940 |
ShvarcstNeger |
B |
Nov. 2, 2020, 4:13 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
31 |
1024000 |
|
|
97527983 |
xsc |
B |
Nov. 3, 2020, 5:34 a.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
31 |
1228800 |
|
|
97524060 |
Trantor |
B |
Nov. 3, 2020, 4:14 a.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
61 |
204800 |
|
|
97492145 |
BrantWang |
B |
Nov. 2, 2020, 4:34 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
61 |
204800 |
|
|
97491434 |
kayahidden |
B |
Nov. 2, 2020, 4:33 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
61 |
204800 |
|
|
97490458 |
Nitika30 |
B |
Nov. 2, 2020, 4:31 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
61 |
204800 |
|
|
97487017 |
Yanming |
B |
Nov. 2, 2020, 4:23 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
61 |
204800 |
|
|
97490031 |
mckm2000 |
B |
Nov. 2, 2020, 4:30 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
61 |
307200 |
|
|
97510733 |
dominotim |
B |
Nov. 2, 2020, 9 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
61 |
1433600 |
|
|
97489200 |
Torehalt |
B |
Nov. 2, 2020, 4:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
8 |
62 |
1638400 |
|
|
97480129 |
guptakhushi345 |
B |
Nov. 2, 2020, 4:06 p.m. |
OK |
PyPy 2 |
TESTS |
8 |
436 |
5529600 |
|
|
97496177 |
hxu10 |
B |
Nov. 2, 2020, 5:25 p.m. |
OK |
PyPy 2 |
TESTS |
8 |
545 |
8192000 |
|
|
97505017 |
vvedant99 |
B |
Nov. 2, 2020, 7:09 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
171 |
4300800 |
|
|
97489419 |
srkvrm |
B |
Nov. 2, 2020, 4:29 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
186 |
3993600 |
|
|
97504987 |
vvedant99 |
B |
Nov. 2, 2020, 7:08 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
186 |
4300800 |
|
|
97526621 |
Anuranjan_Pandey |
B |
Nov. 3, 2020, 5:10 a.m. |
OK |
PyPy 3 |
TESTS |
8 |
187 |
3481600 |
|
|
97502451 |
AggarwalRaghav |
B |
Nov. 2, 2020, 6:31 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
187 |
4300800 |
|
|
97526197 |
DebRC |
B |
Nov. 3, 2020, 5:02 a.m. |
OK |
PyPy 3 |
TESTS |
8 |
202 |
3481600 |
|
|
97496379 |
kaleabasfaw2010 |
B |
Nov. 2, 2020, 5:26 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
202 |
4710400 |
|
|
97495170 |
gintoki_s |
B |
Nov. 2, 2020, 5:18 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
202 |
13209600 |
|
|
97485655 |
Akhil_Rautela |
B |
Nov. 2, 2020, 4:20 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
217 |
13516800 |
|
|
97496248 |
reddevil100 |
B |
Nov. 2, 2020, 5:25 p.m. |
OK |
PyPy 3 |
TESTS |
8 |
218 |
5222400 |
|
|
97480581 |
agw02010 |
B |
Nov. 2, 2020, 4:07 p.m. |
OK |
Python 3 |
TESTS |
8 |
139 |
1126400 |
|
|
97497146 |
Lord_vaibhav |
B |
Nov. 2, 2020, 5:33 p.m. |
OK |
Python 3 |
TESTS |
8 |
171 |
614400 |
|
|
97509494 |
jramaswami |
B |
Nov. 2, 2020, 8:29 p.m. |
OK |
Python 3 |
TESTS |
8 |
171 |
1433600 |
|
|
97518258 |
happa |
B |
Nov. 3, 2020, 1:50 a.m. |
OK |
Python 3 |
TESTS |
8 |
187 |
1433600 |
|
|
97484164 |
juvelop17 |
B |
Nov. 2, 2020, 4:16 p.m. |
OK |
Python 3 |
TESTS |
8 |
202 |
716800 |
|
|
97516052 |
eugalt |
B |
Nov. 3, 2020, 12:30 a.m. |
OK |
Python 3 |
TESTS |
8 |
218 |
1331200 |
|
|
97487004 |
msp1451 |
B |
Nov. 2, 2020, 4:23 p.m. |
OK |
Python 3 |
TESTS |
8 |
218 |
1433600 |
|
|
97522282 |
KanhuKeNanu |
B |
Nov. 3, 2020, 3:30 a.m. |
OK |
Python 3 |
TESTS |
8 |
233 |
409600 |
|
|
97502580 |
ruslanraupoff |
B |
Nov. 2, 2020, 6:32 p.m. |
OK |
Python 3 |
TESTS |
8 |
233 |
409600 |
|
|
97501294 |
bug_eater |
B |
Nov. 2, 2020, 6:17 p.m. |
OK |
Python 3 |
TESTS |
8 |
233 |
409600 |
|
|
97519586 |
bqn |
B |
Nov. 3, 2020, 2:32 a.m. |
OK |
Rust |
TESTS |
8 |
140 |
2355200 |
|
|
97518092 |
bqn |
B |
Nov. 3, 2020, 1:45 a.m. |
OK |
Rust |
TESTS |
8 |
155 |
1331200 |
|
|
remove filters
Back to search problems