Computational Ry-hdoj-1147-Pick-up sticks

Source: Internet
Author: User
Pick-up sticks
Problem descriptionstan has n sticks of various length. he throws them one at a time on the floor in a random way. after finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. stan has noticed that the last thrown stick is always on top but he wants to know all the sticks that are on top. stan sticks are very, very thin such that their thickness can be neglected.
 
Inputinput consists of a number of instances. the data for each case start with 1 ≤ n ≤ 100000, the number of sticks for this case. the following n lines contain four numbers each, these numbers are the planar coordinates of the endpoints of one stick. the sticks are listed in the order in which Stan has thrown them. you may assume that there are no more than 1000 top sticks. the input is ended by the case with n = 0. this case shoshould not be processed. outputfor each input case, print one line of output listing the top sticks in the format given in the sample. the top sticks shocould be listed in order in which they were thrown.
The picture to the right below lower strates the first case from input. sample input
51 1 4 22 3 3 11 -2.0 8 41 4 8 23 3 6 -2.030 0 1 11 0 2 12 0 3 10

Sample output

Top sticks: 2, 4, 5.
Top sticks: 1, 2, 3.

Throwing a wooden stick to the ground in order gives the coordinates of the two endpoints of each wooden stick. Ask which sticks are not overwhelmed by other sticks. Output is required in order.

Analysis: two for loops are used to determine whether the current wooden stick is pressed by the backend. It is equivalent to the intersection of two line segments. Line Segment endpoint intersection is not considered.





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.