Skip to content

Commit

Permalink
Update en.md for ioi-2022-prison
Browse files Browse the repository at this point in the history
  • Loading branch information
jan876 authored Jul 26, 2023
1 parent cbd9de0 commit 02bcb01
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ioi-2022-prison/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In this subtask, we can get some partial scores depending on how small the chose
We can simulate how to compare two binary numbers. By noting that it requires up to 13 bits to represent a number up to 5000, the value on the whiteboard represents the current state, i.e.

* If the value is $3 \times d$, then we need to check the $(12 − d)$-th bit of $A$, and then overwrite it with $3 × d + 1$ or $3 × d + 2$ depending on the bit value.
* If the value $is 3 × d + 1$ or $3 × d + 2$, then we know the $(12 − d)$-th bit of $A$ is either 0 or 1 from the previous prisoner. Then, the current prisoner has to check the $(12 − d)$-th of $B$ and compare the current bit value between $A$ and $B$. If the values are still the same, the prisoner can overwrite it with $3 \times (d + 1)$ to continue to the next bit. Otherwise, the prisoner can answers which bag has fewer coins.
* If the value is $3 × d + 1$ or $3 × d + 2$, then we know the $(12 − d)$-th bit of $A$ is either 0 or 1 from the previous prisoner. Then, the current prisoner has to check the $(12 − d)$-th of $B$ and compare the current bit value between $A$ and $B$. If the values are still the same, the prisoner can overwrite it with $3 \times (d + 1)$ to continue to the next bit. Otherwise, the prisoner can answers which bag has fewer coins.

Therefore, this solution needs $x = 3 \times {\lceil {\log_2{N}} \rceil} − 1$ or $x = 38$ for $N = 5000$.

Expand Down

0 comments on commit 02bcb01

Please sign in to comment.