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

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

Imagine we have a n x m rectangular grid of some reasonable size (say, only 1000x1000), and for some of the positions on grid we have elements, each with an associated range a..b.

The query is: for the position x,y on the grid with the value z, find the closest neighbour on the grid such that a<=z<=b.

Without the range constraint, the task is fairly easy with the use of kd-trees or other structures. How can we efficiently solve the problem with the additional range constraint? I'm interested in approximation or probabilistic algorithms too if there are any.

Полный текст и комментарии »

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

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

Sometimes it is useful to terminate program immidiately, and the easiest way to do so in Java is via System.exit(0). However, it is rather poor programming practice and on Java courses I took, we were heavily discouraged to use it, as it terminates the whole currently running JVM and this can cause trouble.

So I want to ask, if it is ok on Codeforces. I already tried in one of my submission and it worked (720582), but I want to make sure it is ok in every situation, nobody likes to lose points during contest because of some unexpected error.

Полный текст и комментарии »

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