Range selection + range coverage, range selection coverage

Source: Internet
Author: User
Tags for in range

Range selection + range coverage, range selection coverage

Interval selection + interval coverage

Interval point selection problem (select the least point so that each interval has at least k points)

Sort these intervals [l, r] in ascending order of r and then in descending order of l. Select a point close to the right border as much as possible. Then, we traverse the sorted intervals and use a variable to store the right boundary of the upper interval in the traversal process. When we encounter a new interval, we need to discuss it in two cases: 1. If this interval has an intersection with the previous interval, You need to determine the number of points selected last time in this interval. Do these points meet the requirements? If this parameter is not met, You need to select vertex 2 in this interval. If this interval does not have an intersection with the previous one, you need to select a vertex in this interval.

The preceding policy ensures that the right boundary is the same. Select the shorter boundary. Because the vertex in the short interval is selected, a larger interval with the same right boundary must include all the vertices selected in this smaller interval, in this way, the range of this big point is more likely to be satisfied. In addition, the method for selecting a vertex here is to take the vertex as close as possible to the right border, so that the number of satisfied intervals is the largest.

Pseudocode
Interval [maxn] [2]; sort (interval, interval + maxn, cmp ); // cmp arranges pre = interval [1] [0]-1 according to the r small l high priority; // creates an exclusive right boundary for in range (1, maxn): if interval [I] [0]> pre: // not intersecting // near the right boundary else: // first, find the selected number of points in this interval, then select pre = interval [1] [1] according to whether the requirements are met; // update the right boundary else :;

Question: uva10148Advertisement (interval selection)

Range coverage (select the least range to overwrite [m, n])

Assume that the covered range is [m, n]. First, the range of [m, n] and [m, n] are pre-processed. Place the interval with a small starting point in front. If the starting point is the same, place the long interval in front. Make two special judgments to determine whether the first range of the start point covers m and whether the last coverage covers n. The next step is the intermediate judgment. The intermediate judgment depends on the code.

Pseudocode
Interval [maxn] [2]; vis [maxn]; // records the range of edges selected/deleted and [m, n] not touched, function Cover_Interval: if interval [0] [0] <m // whether to cover m return false; pre = m; // The right boundary of the previous selection interval, which is also the valid starting boundary t =-1 for the next selection interval; // record the subscript of the previous range, probably this interval is not the best interval cover = m-1; // the position already overwritten for in range (1, maxn ): if interval [I] [0] <= pre: // satisfies the condition that at least the upper boundary pre is overwritten, so that the entire covered range will not be disconnected if interval [I] [1]> cover: // select the longest range that meets the preceding requirements vis [I] = 1; cover = interva L [I] [1]; // update the overwrite location if t! =-1: // The last selected cancelling vis [t] = 0; else: // If the else does not meet the requirements, you need to select the next interval and Update pre = cover; if interval [I] [0]> pre: // if the left boundary of the current range is greater than the overwrite position, return false is not covered in the middle; t =-1; // The new interval clears the previously selected I --; if cover> = n: break; else:; if cover <n return false; // output the selected range according to vis [maxn] return true; function end;

Question: uva10020-Minimal coverage (range coverage) uva10382-Watering Grass (range coverage deformation)


Which of the following is the golden splitting principle for narrowing down the interval?

What is the election principle when the golden splitting method reduces the interval? Why is this option selected?
The point selection principle is that the inserted points should be separated by 0.618 intervals.
In this way, the selected point can maintain the same proportional distribution of the two iteration intervals, with the same shortening rate.

Which of the following is the golden splitting principle for narrowing down the interval?

According to the formula a1 = B-λ (B-a); a2 = a + λ (B-)
λ = 0.618; a, B is the first given search area [a, B].

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.