511 - Do You Know the Way to San Jose

The Internet now offers a variety ofinteractive map facilities, so that users can see either an overview map of alarge geographic region or can ``zoom in'' to a specific street, sometimes evena specific building, on a much more detailed map. For instance, downtown SanJose might appear in a map of California, a map of Santa Clara county, and adetailed street map.


Suppose you have a large collection of rectangular maps and you wish to designa browsing facility that will process a sequence of map requests for locationsat various levels of map detail. Locations are expressed using locationnames. Each location name has a unique pair of real coordinates (x,y).Maps are unique, labeled with identifying map names, and defined by two pairsof real coordinates-- (x1 ,y1) (x2 ,y2 )--representingopposite corners of the map. All map edges are parallel to the standardCartesian x and y axes. A map and a locationcan have the same name. The aspect ratio of a map is the ratioof its height to its width (where width is measured in the x directionand height is measured in the y direction).


The level of detail of a map can be approximated by using the rectangular arearepresented by the map; i.e., assume that a map covering a smaller areacontains more detailed information. Maps can overlap one another. If a location(x,y) lies within two or more maps having equal areas, thepreferred map (at that level of detail) is the one in which the location isnearest the center of the map. If the location is equidistant from the centersof two overlapping maps of the same area, then the preferred map (at that levelof detail) is the one whose aspect ratio is nearest to the aspect ratio of thebrowser window, which is 0.75. If this still does not break the tie, then thepreferred map is the one in which the location is furthest from the lower rightcorner of the map (this heuristic is intended to minimize the need forscrolling in the user's browser window). Finally, if there is still a tie, thenthe preferred map is the one containing the smallest x-coordinate.


The maximum detail level available for a given location is themaximal number of maps of different areas that contain the location. Clearly,different locations can have different maximum detail levels. The map atdetail i for the location is the map with the ithlargest area among a maximal set of maps of the distinct area containing thelocation. Thus, the map at detail level 1 for the location will be the leastdetailed (largest area) map containing the location and the map at the maximumdetail level will be the most detailed (smallest area) map containing thelocation.

Input 

The input file consists of a set of maps,locations, and requests; it is organized as follows:

  • The word ``MAPS'', in all uppercase letters and on a line by itself, introduces a set of one or more maps. Following the set heading, each map is described by a single line consisting of a map name (an alphabetic string with no leading, trailing, or embedded blanks) and two real coordinate pairs-- --representing opposite corners of the map.
  • The word ``LOCATIONS'', in all uppercase letters and on a line by itself, introduces a set of one or more locations. Following this heading, each location is described by a line consisting of a location name (an alphabetic string with no leading, trailing, or embedded blanks) and a real coordinate pair-- --representing the center of the location.
  • The word ``REQUESTS'', in all uppercase letters and on a line by itself, introduces a set of zero or more requests. Following this heading, each request is described by a line consisting of a location name (an alphabetic string with no leading, trailing, or embedded blanks) followed by a positive integer representing the desired detail level for that location.
  • The word ``END'', in all uppercase and on a line by itself, terminates the file.

All map and location data preceding therequests are valid. There will be no duplicate maps. The result of processing avalid request is the name of the map containing the given location at the givendetail level (using the tie-breaking rules described above). Invalid requestscan result from requesting unknown location names, locations that do not appearin any map, or detail levels that exceed the number of maps of different areas containingthe location.


The following example should illustrate all these definitions:

Output 

Each request must be echoed to the output.If the request is valid, display the name of the map satisfying the request. Ifthe location is not on a map, display a message to that effect. If the locationis on the map but the detail level is too large, display the name of the map ofthe smallest available area (largest possible detail level).

SampleInput 

MAPS

BayArea -6.0 12.0 -11.0 5.0

SantaClara 4.0 9.0 -3.5 2.5

SanJoseRegion -3.0 10.0 11.0 3.0

CenterCoast -5.0 11.0 1.0 -8.0

SanMateo -5.5 4.0 -12.5 9.0

NCalif -13.0 -7.0 13.0 15.0

LOCATIONS

Monterey -4.0 2.0

SanJose -1.0 7.5

Fresno 7.0 0.1

SanFrancisco -10.0 8.6

SantaCruz -4.0 2.0

SanDiego 13.8 -19.3

REQUESTS

SanJose 3

SanFrancisco 2

Fresno 2

Stockton 1

SanDiego 2

SanJose 4

SantaCruz 3

END

SampleOutput 

SanJose at detail level 3 usingSanJoseRegion

SanFrancisco at detail level 2 usingBayArea

Fresno at detail level 2 no map at thatdetail level; using NCalif

Stockton at detail level 1 unknown location

SanDiego at detail level 2 no map containsthat location

SanJose at detail level 4 using SantaClara

SantaCruz at detail level 3 no map at thatdetail level; using CenterCoast

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值