Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

Aries512's blog

By Aries512, 5 years ago, In English,

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.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Aries512, 8 years ago, In English,

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.

Read more »

 
 
 
 
  • Vote: I like it
  • +14
  • Vote: I do not like it