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

建议使用的浏览器:

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

3490:Manhattan Distance

题目描述
The kingdom of Henryy is the most civilized country in the world. Meanwhile, the capital city H is as well the most beautiful city on the earth. Currently, the city is to build up database to maintain the statistics of the buildings in the city.
You are a little P in the company that takes this project. Your task is to calculate the maximum distance between two buildings in the city.
The Manhattan Distance is defined as: for two points P1(x1, y1) and P2(x2, y2) on a two dimension Cartesian plane, the Manhattan Distance D(P1, P2) = |x1-x2|+|y1-y2|.
Your database should support this query: after updating a data that a building has built or demolished, it should return the maximum distance between existed buildings:



N is the current number of buildings, and Pi is the coordinates of the ith building.
输入解释
The first line contains an integer T (T<=10), indicating the number of the test cases.
For each test case, the first line contains an integer M (M<=100000), the number of records of the changes of buildings.
Then M lines followed, each line starting with a positive integer: 1 for building that has built, and 2 for demolished. A string with less than 9 characters follows, indicating the name of the building. If this building is just built, two integers of the coordinates of this building are given afterwards.
Notice that no two buildings share the same name, even when one of these buildings has been demolished, but might share the same coordinates. It is also guaranteed that the building exists when a demolishing record is given.
A blank line is followed after each test case.
输出解释
For each record, output an integer in a single line, indicating the maximum Manhattan Distance among existing buildings.
Print a blank line after each test case.
输入样例
1
8
1 mgj -2 1
2 mgj
1 kmoaktmr 4 -4
1 mauxizu 3 -2
2 kmoaktmr
1 md -1 4
2 md
1 umos -5 0
输出样例
0
-1
0
3
0
10
0
10
来自杭电HDUOJ的附加信息
Recommend zhouzeyong

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3490

最后修改于 2020-10-25T23:04:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
9000/3000MS(Java/Others) 65535/65535K(Java/Others)