当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3830:Ancient vending machine

题目描述
Though the story of Shaolong Xiang, the great time-traveler, is not recorded in the history, some recent discoveries show the possibility that the ancient mystery visitor might really exist. Several months ago, a strange machine was found together with some newly unearthed terra-cotta warriors. That machine looks like a modern machine and even has some electronic parts - that's why people take Mr. Xiang into consideration when guessing the origin of the strange machine.

After careful examinations, scientists finally figured out what the machine is - it actually is a vending machine in Qin dynasty! There is a hole on a panel of the machine, and scientists are pretty sure that Qin people put their coins into the machine through that hole to buy things. As you know, there were too many different types of coins before Qin dynasty and Emperor Qin Shihuang didn't like that. But scientists found an announcement made by Qin Shihuang carved on the machine, saying that any coins which can go through the hole is still legal to use. Now your task is to determine whether a certain type of coin can be put into the hole-from these results we might find some clues about the mystery time-traveler.

The hole on the panel is a polygon and all coins also have a shape of polygon. THEY ALL MAYBE CONCAVE. Scientist found out that ancient people use the vending machine this way: The panel with the hole was positioned horizontally, and the customer chose a best position above the hole to hold a coin. Then the customer dropped the coin. During the process of felling down, the coin WOULD NOT ROTATE in any direction. If the coin could go through the hole, the coin is considered "legal". Otherwise, the coin is judged "illegal". If the coin just merely touched the edges of the hole but was not blocked, it was considered as legal. For example, as shown in the sample input, a square coin with side length 5 can go through a triangle hole with sides of length 3, 4 and 5, so it's legal.



Please note that coins and the panel are all considered as no thickness.
输入解释
The first line contains an integer T representing the number of test cases (0 < T <= 20). For each test case, the first line contains an integer N (3 <= N <= 20), representing the number of vertexes of the hole-polygon.

Next N lines describe the shape of the hole-polygon by listing positions of all vertexes in counterclockwise order. Each line contains two real numbers r1 and r2 (-100 <= r1, r2 <= 100), describing the position of a vertex.

The next line contains an integer M (3 <= M <= 20), representing the number of vertexes of the coin-polygon.

Next M lines describe the shape of the coin-polygon by listing positions of all vertexes in counterclockwise order. Each line contains two real numbers r1 and r2 (-100 <= r1, r2 <= 100), describing the position of a vertex.

The positions mentioned above are relative coordinates but not absolute values.
输出解释
For each test case, output one line containing either the word 'legal' or the word 'illegal', which represents that the coin can or can't go through the hole.
输入样例
2
4
0 0
4 0
4 1
0 1
3
0 4
1 4
1 0
3
0 0
4 0
0 3
4
0 0
5 0
5 5
0 5
输出样例
legal
legal

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Ningbo 2009

源链接: POJ-3830

最后修改于 2020-10-29T07:13:13+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536