A: Erasing Zeroes (00:02)
Pop all the zeroes in the front and the end of the string. Then count the number of s in the array.
B: National Project (00:10, +1)
Very annoying to read and understand question. The code is not very long.
The required time is where is the time to have high-quality pavement.
for , and for .
C: Perfect Keyboard (00:18)
Build an edge between two adjacent letters. If they form a chain, output the chain then the remaining characters. Otherwise, it is impossible.
D: Fill The Bag (00:43, +1)
I have a few guesses to this question. Some of them were correct and some of them weren't, which contributed to the 1 WA.
Guess 1 (Wrong): you should greedily consume the box from the largest to the smallest that can be used without breaking first.
Guess 2 (Correct): you should handle from the lowest bit of to the highest bit of .
So it is just greedily finding a box that is larger than the current bit, breaking it down until there is a box of the same size, then adding this cost to the total cost.
Drafting some cases on paper, by marking down and in binary forms, does help me think of the solution much more quickly.
E: Erase Subsequences (01:00, +1)
The problem can be transformed to the problem: is it possible to find two increasing, distinct sequences such that the characters they are referring to are exactly ?
Tips (not actually tips): read the constraints carefully.
I missed the last line of the constraints: the total length of strings doesn't exceed 400. So I tried to guess that the sequence in step 1 must be maximum, but that was not the case (WA on test 4).
F: Number of Components
Did not attempt. Noted the unusual limit of .
G: Sum of Prefix Sums
Thought that this is probably centroid decomposition, tried coding after finishing A to E. After coding most of the helper functions, suddenly realized that I have no idea how to maximize the required function.