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

Fireworks

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 459    Accepted Submission(s): 86


Problem Description
2008 witnessed the magnificent opening ceremony of the 29th Beijing Olympic Games. The gorgeous fireworks shows during the ceremony have left deep impressions on millions of people all over the world.

Fireworks are always used to accompany many festivities. Today, in important events and festivities, fireworks are still guaranteed sights.

Recently, a new advanced device for generating fireworks is put into use. This device can precisely control the shapes and the positions and the colors of fireworks easily and arbitrarily. To use this device, we just need to set up its range of targets, as well as the appearances of fireworks. However, this kind of devices have a fatal flaw - if two or more devices have common part(s) in their ranges of targets, even just a point, it may cause some unpredictable errors, and finally result in unexpected appearances.

Now here comes your task: given the target ranges of two devices, please determine whether they have common part(s).

Note that the target range of a device will always be a none hole and none self-intersecting polygon on a plane, and the edges are considered as a part of the range. To simplify the problem, it¡¯s guaranteed that interior angles of polygon will never be straight angles.
 

Input
The input contains multiple test cases, and the number of test cases is less than 50.
Each test case begins with two integers, m and n (3 <= m, n <= 500), indicating the numbers of the vertices of the ranges of two devices. Then m + n lines follow. Each line contains three float numbers (no more than 1000 in absolute value) indicating the coordinates of a point in 3D space. The first m points are the vertices of the range of the first device, and the other n points are the vertices of the range of the second device. The vertices of both polygonal ranges are given in clockwise order.

Two consecutive cases are separated by a blank line.

The input ends with m = 0 and n = 0
 

Output
For each test case, there should be a single line containing only one word "YES" or "NO" as the answer to the question: Are the ranges of two devices have common part(s)?
 

Sample Input
4 3 3 3 0 7 8 0 8 7 0 10 0 0 5 3 -1 3 2 9 1 8 7 4 3 3 3 0 7 8 0 8 7 0 10 0 0 5 5 1 3 2 9 1 8 7 0 0
 

Sample Output
YES NO
 

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-23 00:01:34, Gzip enabled