__fn__'s blog

By __fn__, history, 17 months ago, In English

Hello codeforces. Can anyone tell why this approach 217040454 in not working for this problem 1203B - Equal Rectangles?

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

»
17 months ago, # |
  Vote: I like it -8 Vote: I do not like it

The problem is in the map ,
Don't use map. It has happened with me too , see here : 212775377

»
17 months ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it
if (x != y) {
    if (h[x] != h[y]) {
        b = false;
        break;
    }
}

in this part of the code when h[y] does not exist, it inserts {y, 0} into the map. this previous y is later iterated as an x which does not exist in our original array but one which in there in our map. this can be avoided with a continue statement when cnt = 0. the time complexity can also be further improved as max(sides) * min(sides) is the only area for which we can get an YES value.

ac submission using this logic: 217060530

  • »
    »
    17 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeah you are right, thanks you ! I didn't think about that. Now my submission get accepted 217078965