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

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

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

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

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

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

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +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.