LOJ through an example explanations

Park synchronization blog

Here it is the LOJ a comprehensive solution to a problem on the brush through the subject, is not updated regularly. Specific update policy poke here .

If the subject is relatively simple, the it will be briefly explained roadmap , and according to specific needs, pseudo-code is given, the whole paste link code or not to code. Little or no comment.

If there is a more difficult subject of thinking, then we will explain in detail the problem solving process , and then give pseudo-code or post links to the full code. Fewer notes.

If the subject are more code amount, then it will roughly explain the policy, but focuses on explaining implementation , given post direct links to the full code or paste the full code. More comments.

If the subject of both the difficulty of thinking, but also the amount of code, then I will explain in detail the problem-solving process, and explain the implementation , given paste the full link code or directly paste the full code. More comments.

Above, it is noted. But always clarify the meaning of the questions brief, time complexity analysis and so on. And if the content is really too much, branch problem solution will be considered.

If it can solve level data to strengthen the case, and will make every effort to strengthen the data speak. Strengthen data indicate a greater level of my program can be achieved.

LOJ # 10000. "1.1 cases through a 1" activity schedule

Briefly meaning of the questions: Given a number of left and right opening and closing section [ s i , f i ) [s_i , f_i ) , Seeking the largest number of intervals so that they twenty-two no intersection.

Obviously, with pair \text{pair} array will sort these intervals, then last \texttt{last} section taken at the end of the recording time (initially 0 0 ).

From small to large to take, if we can take, then a n s a n s + 1 years \ gets + 1 years , and updates last \texttt{last} .

time complexity: THE ( n log n ) O(n \log n) . Data strengthening: n 1 0 6 n \ leq 10 ^ 6 . Actual score: 100 p t s 100pts .

Link Code

LOJ # 10001. "1.1 cases through a 2" trees

Briefly meaning of the questions: there h h requirement, i.e. each request [ l , r ] [l,r] interval planted e e tree. Seeking to meet the minimum number of trees of all kinds of conditions.

Obviously, the structure ordered in the end storage requirements. Then, as many trees at the end of the interval , as this may lead to a greater contribution to the back of the range.

time complexity: THE ( n × h ) O(n \times h) . Actual score: 100 p t s 100pts .

Link Code

Strengthen data: n , h 1 0 6 n,h \leq 10^6 , the maintenance process by planting tree line, there are many details.

LOJ # 10002. Sprinklers "1.1 cases through a 3"

Briefly meaning of the questions:

Given a l × w l \times w lawns and n n printheads, each nozzle in the center line, from left L L m, watering range W W m. It requires at least the entire nozzle Watering lawns.

Still, with pair<double,double> \text{pair<double,double>} storage, to calculate the current Watering nozzleleftmost position and the rightmost position.

Then, according to LOJ # 10000. "1.1 cases through a 1" campaign scheduled ideas to solve.

Note judgment 1 -1 case.

time complexity: O ( T × n log n ) O(T \times n \log n) . Actual Score: 100 p t s 100pts .

Link Code

LOJ # 10003. "4 1.1 cases through a" process of production scheduling

Briefly meaning of the questions:

n n products are in A A B B two processing workshop, and must be in A A plant to be processed after B B processing workshop. Seeking the order of processing such that the minimum time.

Obviously for two items x , y x, y , min ( A x , B y ) < min ( A y , B x ) \min(A_x , B_y) < \min(A_y , B_x) Then x x before processing, otherwise y Y first processing.

This sort, then you can count it again.

time complexity: O ( n log n ) O(n \log n) . Actual Score: 100 p t s 100pts .

Link Code

Strengthen data: n 1 0 6 n \ leq 10 ^ 6 1 A i , B i 1 0 12 1 \leq A_i , B_i \leq 10^{12} .

Published 55 original articles · won praise 76 · views 7143

Guess you like

Origin blog.csdn.net/bifanwen/article/details/105345603