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 binary string is a string where every character is texttt{0} or texttt{1} . Call a binary string decent if it has an equal number of texttt{0} s and texttt{1} s. Initially, you have an infinite binary string t whose characters are all texttt{0} s. You are given a sequence a of n updates, where a_i indicates that the character at index a_i will be flipped ( texttt{0} <= ftrightarrow texttt{1} ). You need to keep and modify after each update a set S of disjoint ranges such that: You only need to output the ranges that are added to or removed from S after each update. You can only add or remove ranges from S at most mathbf{10^6} times. More formally, let S_i be the set of ranges after the i -th update, where S_0 = varnothing (the empty set). Define X_i to be the set of ranges removed after update i , and Y_i to be the set of ranges added after update i . Then for 1 <= q i <= q n , S_i = (S_{i - 1} setminus X_i) cup Y_i . The following should hold for all 1 <= q i <= q n : The first line contains a single integer n ( 1 <= q n <= q 2 cdot 10^5 ) -- the number of updates. The next n lines each contain a single integer a_i ( 1 <= q a_i <= q 2 cdot 10^5 ) -- the index of the i -th update to the string. After the i -th update, first output a single integer x_i -- the number of ranges to be removed from S after update i . In the following x_i lines, output two integers l and r ( 1 <= q l < r <= q 10^6 ), which denotes that the range [l,r] should be removed from S . Each of these ranges should be distinct and be part of S . In the next line, output a single integer y_i -- the number of ranges to be added to S after update i . In the following y_i lines, output two integers l and r ( '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
182578236 |
mguliyev12360 |
F |
Nov. 26, 2022, 12:28 a.m. |
OK |
GNU C11 |
TESTS |
27 |
4102 |
13619200 |
|
|
182539699 |
liympanda |
F |
Nov. 25, 2022, 5:30 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
342 |
6963200 |
|
|
182544837 |
D_lover |
F |
Nov. 25, 2022, 6:04 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
1949 |
174489600 |
|
|
182597985 |
Aging1986 |
F |
Nov. 26, 2022, 5:53 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
452 |
13516800 |
|
|
182553771 |
dmenezes |
F |
Nov. 25, 2022, 6:48 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
467 |
13619200 |
|
|
182538900 |
Roundgod |
F |
Nov. 25, 2022, 5:29 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
467 |
43212800 |
|
|
182571148 |
aa2985759 |
F |
Nov. 25, 2022, 9:34 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
482 |
10854400 |
|
|
182541114 |
Um_nik |
F |
Nov. 25, 2022, 5:33 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
717 |
20172800 |
|
|
182550752 |
fishy15 |
F |
Nov. 25, 2022, 6:31 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
795 |
14643200 |
|
|
182553430 |
HoshimiOWO |
F |
Nov. 25, 2022, 6:46 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
810 |
10649600 |
|
|
182573940 |
dmenezes |
F |
Nov. 25, 2022, 10:32 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
810 |
14643200 |
|
|
182540191 |
March_7th |
F |
Nov. 25, 2022, 5:31 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
1419 |
128614400 |
|
|
182547953 |
Omar-Hk |
F |
Nov. 25, 2022, 6:17 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
1996 |
174489600 |
|
|
182555404 |
hitonanode |
F |
Nov. 25, 2022, 6:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
343 |
14643200 |
|
|
182564879 |
Sana |
F |
Nov. 25, 2022, 8:15 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
374 |
46899200 |
|
|
182533016 |
kotatsugame |
F |
Nov. 25, 2022, 5:14 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
420 |
15769600 |
|
|
182575087 |
neal |
F |
Nov. 25, 2022, 11:01 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
436 |
11776000 |
|
|
182575049 |
neal |
F |
Nov. 25, 2022, 11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
452 |
20582400 |
|
|
182575067 |
neal |
F |
Nov. 25, 2022, 11:01 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
467 |
11776000 |
|
|
182587403 |
xcyle |
F |
Nov. 26, 2022, 3:50 a.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
514 |
15667200 |
|
|
182588025 |
xcyle |
F |
Nov. 26, 2022, 4:01 a.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
514 |
15667200 |
|
|
182544873 |
syl123456 |
F |
Nov. 25, 2022, 6:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
545 |
43724800 |
|
|
182556020 |
peng01 |
F |
Nov. 25, 2022, 7:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
623 |
22630400 |
|
|
182568321 |
puffins |
F |
Nov. 25, 2022, 8:53 p.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
327 |
18124800 |
|
|
182545968 |
maspy |
F |
Nov. 25, 2022, 6:08 p.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
452 |
28160000 |
|
|
182595283 |
Kodaman |
F |
Nov. 26, 2022, 5:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
545 |
26316800 |
|
|
182573218 |
Farhod_Farmon |
F |
Nov. 25, 2022, 10:15 p.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
795 |
18227200 |
|
|
182563165 |
fallleaves01 |
F |
Nov. 25, 2022, 7:58 p.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
795 |
30105600 |
|
|
182573240 |
Farhod_Farmon |
F |
Nov. 25, 2022, 10:15 p.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
857 |
18329600 |
|
|
182544936 |
Kapt |
F |
Nov. 25, 2022, 6:04 p.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
1263 |
21504000 |
|
|
182570330 |
Igorjan94 |
F |
Nov. 25, 2022, 9:21 p.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
1403 |
15769600 |
|
|
182583942 |
kmjp |
F |
Nov. 26, 2022, 2:48 a.m. |
OK |
GNU C++20 (64) |
TESTS |
27 |
2994 |
39731200 |
|
|
182550559 |
manish.17 |
F |
Nov. 25, 2022, 6:30 p.m. |
OK |
PyPy 3 |
TESTS |
27 |
3884 |
37376000 |
|
|
remove filters
Back to search problems