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

建议使用的浏览器:

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

3288:Mall Mania

题目描述

Waterloo has two giant shopping malls, each enclosing several city blocks. Kim and Pat like to shop and to walk within the malls but they don't like walking between the malls because such walking does not contribute directly to the task at hand: shopping. They would therefore like to know the minimum crossing distance between the malls.

Each city block is a unit square delimited by streets and avenues. Streets run east-west and avenues run north-south. Both are identified by consecutive integers between 0 and 2000. (Lower numbered avenues are west of higher numbered avenues and lower numbered streets are south of higher numbered streets.) Streets and avenues are narrow so their thickness may be assumed to be 0.

Each mall is a contiguous set of complete city blocks. By contiguous we mean that any two blocks are connected by some sequence of blocks such that consecutive pairs of blocks in the sequence share a side. The malls do not intersect and do not surround any empty blocks; that is, the blocks not in any mall are themselves contiguous.

输入解释

Standard input contains several test cases. Each test case contains the description of the two malls. Each mall's description consists of an integer p ≥ 4, the perimeter of the mall, followed by one or more lines containing p pairs (a,s) giving the coordinates of the avenue-street intersections contained in the perimeter, in clockwise order. A line containing 0 follows the last test case.

输出解释

For each case, output a single integer d -- the minimum walking distance between the malls, assuming that Kim and Pat always walk along streets and avenues.

输入样例
4
0 0 0 1 1 1 1 0
6
4 3 4 2 3 2
2 2 2 3
3 3
0
输出样例
2

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

源链接: POJ-3288

最后修改于 2020-10-29T06:57:48+00:00 由爬虫自动更新

共提交 0

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