Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Hello codeforces. Can anyone tell why this approach 217040454 in not working for this problem 1203B - Одинаковые прямоугольники?

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

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

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

»
14 месяцев назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится
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