I tried Solving ICPC India Online prelims Question D but I am not to find the correct logic
https://www.codechef.com/ICPCOL2025/problems/ICPC25P4TMP
I Would like to hear what was the logic from the people who solved this
I tried Solving ICPC India Online prelims Question D but I am not to find the correct logic
https://www.codechef.com/ICPCOL2025/problems/ICPC25P4TMP
I Would like to hear what was the logic from the people who solved this
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3857 |
| 2 | jiangly | 3810 |
| 3 | maroonrk | 3534 |
| 4 | tourist | 3528 |
| 5 | Kevin114514 | 3510 |
| 6 | turmax | 3411 |
| 7 | Um_nik | 3387 |
| 8 | Radewoosh | 3367 |
| 9 | heuristica | 3322 |
| 10 | strapple | 3317 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | maspy | 150 |
| 3 | Um_nik | 146 |
| 4 | Errichto | 139 |
| 5 | adamant | 136 |
| 6 | maroonrk | 134 |
| 7 | DNR | 133 |
| 8 | Dominater069 | 131 |
| 9 | Proof_by_QED | 130 |
| 9 | AmShZ | 130 |
| Название |
|---|



Auto comment: topic has been updated by Erikasa (previous revision, new revision, compare).
Auto comment: topic has been updated by Erikasa (previous revision, new revision, compare).
Auto comment: topic has been updated by Erikasa (previous revision, new revision, compare).
cry burger
ok! Next order?
Hint: try to solve it in exactly 2 operations.
Lets call $$$k$$$ the number of indices $$$i$$$ that satisfy $$$i \leq \frac{n}{2}$$$ and $$$p[i] \leq \frac{n}{2}$$$. Then the number of indices $$$i\leq \frac{n}{2}, p[i] \gt \frac{n}{2}$$$ is $$$\frac{n}{2}-k$$$, the number of indices $$$i \gt \frac{n}{2}, p[i] \leq \frac{n}{2}$$$ is $$$\frac{n}{2}-k$$$, and the number of indices $$$i \gt \frac{n}{2}, p[i] \gt \frac{n}{2}$$$ is $$$k$$$. This gives us a way to do it in exactly 2 operations.
Since we want the minimum number of operations, we only need to figure out if it is possible in 1 operation. Hopefully you are able to solve this case :)
Think about it as a 2d plot, where you draw a cross in the middle of the plot. Then you choose (left top + right bottom) and (left bottom + right top)
Thanks i think i got how to do it
ans <= 2 is always possible