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

Автор Adityaxv, 2 месяца назад, По-английски

Problem: Link, Submission: 280673288

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

»
2 месяца назад, # |
  Проголосовать: нравится -10 Проголосовать: не нравится

I'm sorry but function definition is wrong: do try this:

public static void main(String args[])

»
2 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

just brute force bro. Link

»
2 месяца назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

You have to split your vector g into two separate vectors, one for horizontal, and one vertical. Given input:

Spoiler

your code would say that (0, 0) is a "supercentral point" because there exist smaller and bigger xs and ys than 0, but really there is no "right neighbour" of that point

»
2 месяца назад, # |
Rev. 10   Проголосовать: нравится 0 Проголосовать: не нравится

Your approach is not correct. You are just checking for left , right, up and down points. But the condition says that they have to be direct left, right, up and down points.

point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y

So, before checking x > x ' or x < x' you have to check y == y'.
Similarly you also need to check x == x' for y > y' and y < y' to be valid.

So, if you really want to use this approach, you can use two seperate g vectors gx and gy.
see my edited submission of your code here 280712862. (accepted)

just check all the points. 200 is not that much points. My submission 280695175.

  • »
    »
    2 месяца назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Yeah, my approach was wrong. Thanks for the correction and the new solution.