POJ 2932 scanning line idea

Source: Internet
Author: User

This question is amazing.

N non-intersecting circles are given. One circle may completely contain the other. Here, a circle is contained in another circle.

Calculate the sequence numbers of the excluded circles.

The data volume is 4 W.

So N2 certainly won't work.

Meditation, cannot solve

 


After reading this, I couldn't help calling the data structure.

The general idea is similar to the scanning line we often use, but here it is a circle.

Each circle has the leftmost vertex and rightmost vertex. We just scanned the points from left to right in order.

In the process of scanning, if the left endpoint of a circle is scanned, it depends on whether the circle is included. If it is not included, it is added to the data structure we designed. So how can we determine whether it is included? The bare idea is to check whether it is included in a circle in the previous data structure. In fact, we only need to determine the upper and lower circles that are close to the center of our own center in the data structure, because at this time, the data structure we designed must be some circles that do not contain each other, if the new circle is included, the circle containing it must be in its adjacent place.

If a circle is scanned to the right endpoint, the circle will be deleted, because the circle in the future will not be related to it.

Based on this insertion, deletion, and adjacent conditions, we can find that it is better to use set to implement it.

 


 

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.