Codeforces 491B. New York Hotel 最远曼哈顿距离
最遠曼哈頓距離有兩個性質:
1: 對每一個點(x,y) ?分別計算 ?+x+y , -x+y , x-y , -x-y 然后統計每種組合的最大值就能夠了, 不會對結果產生影響
2: 去掉絕對值 , 設正號為0負號為1 則 兩個點的符號是能夠通過異或的得到的.?
如兩個點 P(x,y) 和 Q(a,b) 若去掉絕對值符號后P的兩個坐標為 -x +y 既相應數字 10 ?那么Q相應的數字則為 01 既 +a -b 兩個點的曼哈頓距離為 -x +y +a -b
B. New York Hotel time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputThink of New York as a rectangular grid consisting of?N?vertical avenues numerated from?1?to?N?and?M?horizontal streets numerated?1?toM.?C?friends are staying at?C?hotels located at some street-avenue crossings. They are going to celebrate birthday of one of them in the one of?H?restaurants also located at some street-avenue crossings. They also want that the maximum distance covered by one of them while traveling to the restaurant to be minimum possible. Help friends choose optimal restaurant for a celebration.
Suppose that the distance between neighboring crossings are all the same equal to one kilometer.
InputThe first line contains two integers?N?и?M?— size of the city (1?≤?N,?M?≤?109). In the next line there is a single integer?C?(1?≤?C?≤?105)?— the number of hotels friends stayed at. Following?C?lines contain descriptions of hotels, each consisting of two coordinates?x?and?y?(1?≤?x?≤?N,?1?≤?y?≤?M). The next line contains an integer?H?— the number of restaurants (1?≤?H?≤?105). Following?H?lines contain descriptions of restaurants in the same format.
Several restaurants and hotels may be located near the same crossing.
OutputIn the first line output the optimal distance. In the next line output index of a restaurant that produces this optimal distance. If there are several possibilities, you are allowed to output any of them.
Sample test(s) input 10 10 2 1 1 3 3 2 1 10 4 4 output 6 2總結
以上是生活随笔為你收集整理的Codeforces 491B. New York Hotel 最远曼哈顿距离的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 研发手Q推广遇到的一系列问题
- 下一篇: 原创:战国时期,魏惠王一心想要有所作为,