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

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

Автор Noob5644, история, 3 года назад, По-английски

https://codeforces.net/contest/1581/problem/A

what is the logic ?? i just know the ans is (2*n)!/2 ,but how ?

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

»
3 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

Assume there is a unsatisfied permutation $$$P$$$ and $$$x$$$ is the number of $$$i$$$ that satisfy $$$p_i < p_{i + 1}$$$ and $$$x < n$$$. So just reverse $$$P$$$, the number of $$$i$$$ satisfy $$$p_i < p_{i + 1}$$$ in our new permutation is $$$2 * n - 1 - x > 2 * n - n - 1 = n - 1$$$. It's easy to see that the answer is $$$\frac{(2*n)!}{2}$$$

»
3 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

if any permutation doesn't satisfied that condition then it reverse will do and if that permutation does then its reverse doesn't.

so half will satisfy and other half( reverse one) will not.