Блог пользователя nownikhil

Автор nownikhil, 13 лет назад, По-английски

Hi all,

I was trying to solve this problem on spoj. http://www.spoj.com/problems/WILD/

If we treat each evil candidate as a point and consider the cube (0,0,0) — (x,y,z). The problem is reduced to finding the volume of union of cubes. The answer in this case will be m^3 — volume.

The complexity is turning out to be n*n*log(n). Can anyone suggest a better algorithm?

Thanks

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

You can do it in O(n * log2(n)) in the same way you find the area of the union of rectangles in O(n * log(n)), by using segment trees, and in each leaf, another segment tree...