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'A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k -balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters ( frac{k}{2} of each). You are given an integer k and a string s which is composed only of characters 0, 1, and ?. You need to determine whether you can make a k -balanced bitstring by replacing every ? characters in s with either 0 or 1. A string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^4 ). Description of the test cases follows. The first line of each test case contains two integers n and k ( 2 <= k <= n <= 3 cdot 10^5 , k is even) -- the length of the string and the parameter for a balanced bitstring. The next line contains the string s ( |s| = n ). It is given that s consists of only 0, 1, and ?. It is guaranteed that the sum of n over all test cases does not exceed 3 cdot 10^5 . For each test case, print YES if we can replace every ? in s with 0 or 1 such that the resulting bitstring is k -balanced, or NO if it is not possible. For the first test case, the string is already a 4 -balanced bitstring. For the second test case, the string can be transformed into 101. For the fourth test case, the string can be transformed into 0110. For the fifth test case, the string can be transformed into 1100110. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
92032474 |
Gassa |
A |
Sept. 6, 2020, 2:46 p.m. |
OK |
D |
TESTS |
69 |
46 |
4198400 |
|
|
92040945 |
hos.lyric |
A |
Sept. 6, 2020, 2:59 p.m. |
OK |
D |
TESTS |
69 |
62 |
13721600 |
|
|
92030417 |
physics0523 |
A |
Sept. 6, 2020, 2:44 p.m. |
OK |
GNU C11 |
TESTS |
69 |
46 |
1024000 |
|
|
92055801 |
pengin_2000 |
A |
Sept. 6, 2020, 3:34 p.m. |
OK |
GNU C11 |
TESTS |
69 |
62 |
307200 |
|
|
92029546 |
frodakcin |
A |
Sept. 6, 2020, 2:43 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
102400 |
|
|
92027900 |
DarkoLoveRuby |
A |
Sept. 6, 2020, 2:41 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
102400 |
|
|
92025914 |
cjy2003 |
A |
Sept. 6, 2020, 2:39 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
102400 |
|
|
92030449 |
eudanip |
A |
Sept. 6, 2020, 2:44 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
102400 |
|
|
92031695 |
OMG_link |
A |
Sept. 6, 2020, 2:45 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
102400 |
|
|
92036776 |
azizkhan |
A |
Sept. 6, 2020, 2:52 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
307200 |
|
|
92036618 |
Wall_breaker |
A |
Sept. 6, 2020, 2:52 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
307200 |
|
|
92031433 |
142857 |
A |
Sept. 6, 2020, 2:45 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
307200 |
|
|
92042313 |
stevenzhang |
A |
Sept. 6, 2020, 3:02 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
307200 |
|
|
92039035 |
CaroLinda |
A |
Sept. 6, 2020, 2:56 p.m. |
OK |
GNU C++11 |
TESTS |
69 |
31 |
307200 |
|
|
92027251 |
1207koo |
A |
Sept. 6, 2020, 2:40 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
307200 |
|
|
92078080 |
qxforever |
A |
Sept. 6, 2020, 5:27 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
307200 |
|
|
92034727 |
qx4ever |
A |
Sept. 6, 2020, 2:49 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
307200 |
|
|
92040413 |
xpov1LL |
A |
Sept. 6, 2020, 2:58 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
1024000 |
|
|
92025526 |
lucaperju |
A |
Sept. 6, 2020, 2:39 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
1536000 |
|
|
92035057 |
DougZheng |
A |
Sept. 6, 2020, 2:49 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
1536000 |
|
|
92034724 |
Luzivanlt |
A |
Sept. 6, 2020, 2:49 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
5017600 |
|
|
92080464 |
xb0nS |
A |
Sept. 6, 2020, 5:49 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
5120000 |
|
|
92094513 |
lavenderwithbluish |
A |
Sept. 6, 2020, 11:49 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
31 |
9011200 |
|
|
92038597 |
fjdksla |
A |
Sept. 6, 2020, 2:55 p.m. |
OK |
GNU C++14 |
TESTS |
69 |
46 |
307200 |
|
|
92029720 |
knightL |
A |
Sept. 6, 2020, 2:43 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
307200 |
|
|
92038657 |
luisBah |
A |
Sept. 6, 2020, 2:55 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
409600 |
|
|
92028662 |
Hyperbolic |
A |
Sept. 6, 2020, 2:42 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
614400 |
|
|
92089621 |
Rabeeb |
A |
Sept. 6, 2020, 8:31 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
614400 |
|
|
92088365 |
_overrated_ |
A |
Sept. 6, 2020, 7:59 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
819200 |
|
|
92027638 |
tamionv |
A |
Sept. 6, 2020, 2:41 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
1024000 |
|
|
92103299 |
nantha_manish |
A |
Sept. 7, 2020, 4:25 a.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
1024000 |
|
|
92033325 |
_Time_Lord_ |
A |
Sept. 6, 2020, 2:47 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
1024000 |
|
|
92031921 |
ShJ |
A |
Sept. 6, 2020, 2:45 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
1024000 |
|
|
92027825 |
Everule |
A |
Sept. 6, 2020, 2:41 p.m. |
OK |
GNU C++17 |
TESTS |
69 |
31 |
1024000 |
|
|
92028221 |
Localization |
A |
Sept. 6, 2020, 2:41 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
307200 |
|
|
92032515 |
ransewhale |
A |
Sept. 6, 2020, 2:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
716800 |
|
|
92106054 |
toxic_hack |
A |
Sept. 7, 2020, 5:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
1024000 |
|
|
92107196 |
Wolf. |
A |
Sept. 7, 2020, 5:38 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
1024000 |
|
|
92103867 |
Parsa84 |
A |
Sept. 7, 2020, 4:38 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
1024000 |
|
|
92099412 |
DQ9911 |
A |
Sept. 7, 2020, 2:53 a.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
1024000 |
|
|
92081919 |
neal |
A |
Sept. 6, 2020, 6:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
1024000 |
|
|
92080634 |
eidan |
A |
Sept. 6, 2020, 5:51 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
1024000 |
|
|
92078152 |
Anila9007 |
A |
Sept. 6, 2020, 5:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
1024000 |
|
|
92078103 |
Valera_Grinenko |
A |
Sept. 6, 2020, 5:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
69 |
31 |
1024000 |
|
|
92099909 |
synapse |
A |
Sept. 7, 2020, 3:07 a.m. |
OK |
Go |
TESTS |
69 |
62 |
409600 |
|
|
92038525 |
ZeyadKhattab |
A |
Sept. 6, 2020, 2:55 p.m. |
OK |
Java 11 |
TESTS |
69 |
202 |
0 |
|
|
92065804 |
insert_cool_handle |
A |
Sept. 6, 2020, 4:07 p.m. |
OK |
Java 11 |
TESTS |
69 |
202 |
0 |
|
|
92038887 |
cirno3153 |
A |
Sept. 6, 2020, 2:55 p.m. |
OK |
Java 11 |
TESTS |
69 |
202 |
0 |
|
|
92030256 |
uwi |
A |
Sept. 6, 2020, 2:43 p.m. |
OK |
Java 11 |
TESTS |
69 |
202 |
0 |
|
|
92027716 |
mphillotry |
A |
Sept. 6, 2020, 2:41 p.m. |
OK |
Java 11 |
TESTS |
69 |
202 |
0 |
|
|
92025599 |
qwerty787788 |
A |
Sept. 6, 2020, 2:39 p.m. |
OK |
Java 11 |
TESTS |
69 |
202 |
0 |
|
|
92079183 |
skittles1412 |
A |
Sept. 6, 2020, 5:36 p.m. |
OK |
Java 11 |
TESTS |
69 |
217 |
102400 |
|
|
92056847 |
awesomelemonade |
A |
Sept. 6, 2020, 3:37 p.m. |
OK |
Java 11 |
TESTS |
69 |
218 |
0 |
|
|
92032888 |
tusharjape007 |
A |
Sept. 6, 2020, 2:46 p.m. |
OK |
Java 11 |
TESTS |
69 |
218 |
0 |
|
|
92030632 |
mikit |
A |
Sept. 6, 2020, 2:44 p.m. |
OK |
Java 11 |
TESTS |
69 |
218 |
0 |
|
|
92094107 |
TriumphantEggplant |
A |
Sept. 6, 2020, 11:26 p.m. |
OK |
Java 8 |
TESTS |
69 |
124 |
0 |
|
|
92082281 |
kumarpritam863 |
A |
Sept. 6, 2020, 6:13 p.m. |
OK |
Java 8 |
TESTS |
69 |
124 |
0 |
|
|
92038753 |
ijxjdjd |
A |
Sept. 6, 2020, 2:55 p.m. |
OK |
Java 8 |
TESTS |
69 |
124 |
0 |
|
|
92037991 |
MagentaCobra |
A |
Sept. 6, 2020, 2:54 p.m. |
OK |
Java 8 |
TESTS |
69 |
124 |
0 |
|
|
92034341 |
polyakoff |
A |
Sept. 6, 2020, 2:48 p.m. |
OK |
Java 8 |
TESTS |
69 |
124 |
0 |
|
|
92032200 |
Naman_123 |
A |
Sept. 6, 2020, 2:45 p.m. |
OK |
Java 8 |
TESTS |
69 |
124 |
0 |
|
|
92028648 |
AnandOza |
A |
Sept. 6, 2020, 2:42 p.m. |
OK |
Java 8 |
TESTS |
69 |
124 |
0 |
|
|
92027587 |
fetetriste |
A |
Sept. 6, 2020, 2:41 p.m. |
OK |
Java 8 |
TESTS |
69 |
124 |
0 |
|
|
92038021 |
golions |
A |
Sept. 6, 2020, 2:54 p.m. |
OK |
Java 8 |
TESTS |
69 |
139 |
0 |
|
|
92034407 |
TheSawan |
A |
Sept. 6, 2020, 2:48 p.m. |
OK |
Java 8 |
TESTS |
69 |
139 |
0 |
|
|
92031574 |
Hakiobo |
A |
Sept. 6, 2020, 2:45 p.m. |
OK |
Kotlin |
TESTS |
69 |
139 |
0 |
|
|
92097012 |
Spheniscine |
A |
Sept. 7, 2020, 1:42 a.m. |
OK |
Kotlin |
TESTS |
69 |
155 |
0 |
|
|
92032465 |
elizarov |
A |
Sept. 6, 2020, 2:46 p.m. |
OK |
Kotlin |
TESTS |
69 |
171 |
0 |
|
|
92032627 |
batkhuyag |
A |
Sept. 6, 2020, 2:46 p.m. |
OK |
Kotlin |
TESTS |
69 |
312 |
102400 |
|
|
92038113 |
terry_u16 |
A |
Sept. 6, 2020, 2:54 p.m. |
OK |
Mono C# |
TESTS |
69 |
93 |
3072000 |
|
|
92039938 |
mban259 |
A |
Sept. 6, 2020, 2:57 p.m. |
OK |
Mono C# |
TESTS |
69 |
93 |
6860800 |
|
|
92029841 |
azukun |
A |
Sept. 6, 2020, 2:43 p.m. |
OK |
Mono C# |
TESTS |
69 |
93 |
6860800 |
|
|
92030004 |
keymoon |
A |
Sept. 6, 2020, 2:43 p.m. |
OK |
Mono C# |
TESTS |
69 |
93 |
7987200 |
|
|
92040431 |
shirowa |
A |
Sept. 6, 2020, 2:58 p.m. |
OK |
MS C++ 2017 |
TESTS |
69 |
46 |
307200 |
|
|
92036581 |
vpike |
A |
Sept. 6, 2020, 2:51 p.m. |
OK |
MS C++ 2017 |
TESTS |
69 |
46 |
921600 |
|
|
92031305 |
Gravekper |
A |
Sept. 6, 2020, 2:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
69 |
78 |
921600 |
|
|
92037532 |
AnnSuperstar |
A |
Sept. 6, 2020, 2:53 p.m. |
OK |
MS C++ 2017 |
TESTS |
69 |
93 |
3686400 |
|
|
92079997 |
shehebe |
A |
Sept. 6, 2020, 5:44 p.m. |
OK |
PyPy 2 |
TESTS |
69 |
436 |
12185600 |
|
|
92031448 |
chudy_lukasz1337 |
A |
Sept. 6, 2020, 2:45 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
233 |
11673600 |
|
|
92028453 |
conqueror_of_tourist |
A |
Sept. 6, 2020, 2:41 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
248 |
7680000 |
|
|
92030365 |
qwertz73355a |
A |
Sept. 6, 2020, 2:43 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
249 |
7884800 |
|
|
92029869 |
titia |
A |
Sept. 6, 2020, 2:43 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
249 |
8192000 |
|
|
92030342 |
kclee2172 |
A |
Sept. 6, 2020, 2:43 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
249 |
9011200 |
|
|
92029241 |
pineriver |
A |
Sept. 6, 2020, 2:42 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
264 |
9318400 |
|
|
92035808 |
Kiri8128 |
A |
Sept. 6, 2020, 2:50 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
280 |
8704000 |
|
|
92034459 |
juppy |
A |
Sept. 6, 2020, 2:48 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
280 |
9011200 |
|
|
92094179 |
chance |
A |
Sept. 6, 2020, 11:30 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
280 |
11673600 |
|
|
92033314 |
SPD_9X2 |
A |
Sept. 6, 2020, 2:47 p.m. |
OK |
PyPy 3 |
TESTS |
69 |
311 |
12902400 |
|
|
92028018 |
nwi |
A |
Sept. 6, 2020, 2:41 p.m. |
OK |
Python 2 |
TESTS |
69 |
265 |
2150400 |
|
|
92034023 |
r57shell |
A |
Sept. 6, 2020, 2:48 p.m. |
OK |
Python 3 |
TESTS |
69 |
280 |
3072000 |
|
|
92042654 |
mkawa2 |
A |
Sept. 6, 2020, 3:02 p.m. |
OK |
Python 3 |
TESTS |
69 |
373 |
2560000 |
|
|
92100473 |
yswness |
A |
Sept. 7, 2020, 3:22 a.m. |
OK |
Python 3 |
TESTS |
69 |
389 |
1740800 |
|
|
92089766 |
sansen |
A |
Sept. 6, 2020, 8:36 p.m. |
OK |
Rust |
TESTS |
69 |
46 |
2969600 |
|
|
92094757 |
kobae964 |
A |
Sept. 7, 2020, 12:04 a.m. |
OK |
Rust |
TESTS |
69 |
46 |
3174400 |
|
|
92029242 |
ngtkana |
A |
Sept. 6, 2020, 2:42 p.m. |
OK |
Rust |
TESTS |
69 |
171 |
2560000 |
|
|
remove filters
Back to search problems