Magic Trick

시간 제한2초메모리 제한2048 MB

문제

Alicia and Beatriz are preparing a magic trick for the IOI Talent Show. The trick works as follows:

  • A volunteer selects a permutation $P$ of length $N$ and places $N$ cards on the table. The cards are numbered from $0$ to $N − 1$, with card $i$ displaying the value $P[i]$.
  • Alicia enters the room, observes the cards, and selects $K$ of them to flip face down, hiding their values.
  • Beatriz then enters the room, sees the current arrangement of the cards (including which ones are face down), and magically determines the values of all $K$ hidden cards!

Your task is to devise and implement a strategy for Alicia and Beatriz. The more impressive the trick, the better your score: the objective is to maximize $K$, the number of hidden cards Beatriz can correctly reveal.

제한

  • $N = 256$
  • $1 ≤ P[i] ≤ N$ for each $i$ such that $0 ≤ i < N$.
  • All values in $P$ are distinct.