Adityaxv's blog

By Adityaxv, 2 months ago, In English

Problem: Link, Submission: 280673288

Code
  • Vote: I like it
  • -1
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it -10 Vote: I do not like it

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

public static void main(String args[])

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

just brute force bro. Link

»
2 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thank you for providing the testcase, now I understood my error.

»
2 months ago, # |
Rev. 10   Vote: I like it 0 Vote: I do not like it

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 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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