How to code 2D segment tree?

守給你的承諾、 提交于 2019-12-12 00:40:03

问题


I was solving the problem http://www.spoj.com/problems/LIS2/ on spoj. I tried for days but could not come up with a solution that could pass(time wise). Then I googled and found people talking about 2D segment tree.I searched a lot but could not find a descent explanation.Is there any other solution to this problem ??
Also on topcoder i found people say this problem is similar to www.spoj.com/problems/NICEDAY.I had solved this problem way long back and that time I even did not know 1D segment tree.
So can anyone suggest some solution to LIS2 preferably with 2D segment tree.

PS: I am not looking for codes please don't post codes a broad explanation of implementation and space/time complexity of data structure will suffice.


回答1:


Refer to this link : http://e-maxx.ru/algo/segment_tree

Although the page is in Russian, but Google Translate would be good enough. This page explains the 1-D segment tree first. On the bottom, there is a section titled 'The two-dimensional tree segments in its simplest form' which would give you the required explanation.



来源:https://stackoverflow.com/questions/17225753/how-to-code-2d-segment-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!