The serial number for this question is 2808.
I got a question before I got off work last night and drew a picture on the paper with a pen.
The same method in Q2 is used to store input data, but the array format is int;
As long as you know the start and end locations of the subway station, the cut-down tree is end-begin + 1;
The remaining tree is the total number of trees (L + 1)-cut tree
The difficulty lies in how to calculate the overlapping area of the subway. When I think of the method used in Q2 to list all the situations, I will be stranded until this morning.
This morning, I drew a lot of images on paper, and formed an animation in my head. I moved the starting and ending positions of the New Earth iron to summarize the situation. I tried it twice and made another interval, die.
Considering range union, there is no upper limit on storage, and it is attempted
If there is a way, I read the text in the book, maybe it is too tangled, just read a word to instantly epiphany:
Array ElementThe value in represents each tree.MarkIt is false (0), and is still marked as true (1). It is true (1) at first );
At last, you only need to count the number of all element values in the array as 1, that is, the remaining tree.
How can I be so smart ~, Bunker,
I gave up my previous idea of seeking for a range and adopted this processing method. Soon I finished writing and submitted it successfully.
In addition, the previous improvement is that the first step is to consider how to handle user input errors (for example, the input range exceeds the start l ).
The question preparation time is also shortened.
Comrade P continues his efforts and strives to become a master of the mind as soon as possible if he encounters problems without looking at the explanation or Google.
1 accepted