F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Bumpy Objects

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 231    Accepted Submission(s): 13


Problem Description

Consider objects such as these. They are polygons, specified by the coordinates of a centre of mass and their vertices. In the figure, centres of mass are shown as black squares. The vertices will be numbered consecutively anti-clockwise as shown.

An object can be rotated to stand stably if two vertices can be found that can be joined by a straight line that does not intersect the object, and, when this line is horizontal, the centre of mass lies above the line and strictly between its endpoints. There are typically many stable positions and each is defined by one of these lines known as its base line. A base line, and its associated stable position, is identified by the highest numbered vertex touched by that line.

Write a program that will determine the stable position that has the lowest numbered base line. Thus for the above objects, the desired base lines would be 6 for object 1, 6 for object 2 and 2 for the square. You may assume that the objects are possible, that is they will be represented as non self-intersecting polygons, although they may well be concave.
 

Input
Successive lines of a data set will contain: a string of less than 20 characters identifying the object; the coordinates of the centre of mass; and the coordinates of successive points terminated by two zeroes (0 0), on one or more lines as necessary. There may be successive data sets (objects). The end of data will be defined by the string '#'.

Output will consist of the identification string followed by the number of the relevant base line.
 

Sample Input
Object2 4[bk]3 3[bk]2[bk][bk]5[bk]2[bk][bk]6[bk]1[bk][bk]7[bk]1[bk][bk]6[bk]3[bk][bk]4[bk]7[bk][bk]1[bk]1[bk][bk]2[bk]1[bk][bk]0[bk]0 Square[bk] 2[bk]2 1[bk]1[bk][bk]3[bk]1[bk][bk]3[bk]3[bk][bk]1[bk]3[bk][bk]0[bk]0 #
 

Sample Output
Object2[bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk]6 Square[bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk]2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 11:38:15, Gzip enabled