Haidora or not Haidora?#12298

Haidora or not Haidora? (Beszélgetés)

  1. Bura_Artem2026. jan. 6. 16:08

    If we have multiple bits that we can include into the answer by flipping some numbers, we can include only one bit (or multiple if they share exact same numbers we must flip) and it should be the largest, or am i missing something?

  2. Pikori2025. dec. 15. 5:45

    The editorial is overcomplicated.There are no flexible bits. The case keep_ok = true and flip_ok = true does not exist for any x != 0. In short, without spoiling a solution, the elements we need to flip are (forced/) fixed as soon as we look at the right bit.

    1. skolodyazhnyy2025. dec. 15. 10:05

      Pikori could you make a suggestion to simplify it or add alternative explanation?

    2. zss2026. jan. 7. 12:18szerkesztve

      Pikori Якщо коротко, то ідея така:

      Для всіх чисел масиву потрібно порахувати кількість біт, що знаходяться на кожній позиції, їх будемо зберігати в масиві з 32 елементів.

      Знайдемо найбільшу позицію біта на якій клькість одиниць буде n-k. Всі числа, в яких на даній позиції 0 потрібно інвертувати.

      Коли будемо шукати and-суму S незабути спочатку присвоїти число, в якого на всіх позиціях стоять 1, тобто (1<<32)-1