CF2124F2 Some notes on the overcounting

Revision en1, by Sanae, 2025-07-07 13:46:05

Case 1

$$$[1,2,3,\dots ,x][x+1,x+2,\dots ,y,1,2,3,\dots,x-1]$$$

$$$[1,2,3,\dots ,x,x+1,x+2,\dots ,y][1,2,3,\dots,x-1]$$$

take either

take the example in the officail tutorial:

$$$[1,2,3,1,2,1]$$$

$$$[1,2,3]+[1,2]+[1]$$$

$$$[1,2]+[3,1,2]+[1]$$$

It inspire me to ban the $$$[1,2,\dots x][x+1\dots]$$$ situation.

Case 2

$$$[k,k+1,\dots,x,1,2,3,\dots,k-1][k,k+1,\dots]$$$

There should be no misunderstanding.

Solution

The $$$O(n^4)$$$ brute force.

I didn't come up with it during the contest,though.

https://mirror.codeforces.com/contest/2124/submission/327909733

I wrote another $$$O(n^3)$$$ dp.

https://mirror.codeforces.com/contest/2124/submission/327819126

But I can't optimize it.

So what is tutorial say is right.

https://mirror.codeforces.com/contest/2124/submission/327928111

https://mirror.codeforces.com/contest/2124/submission/327928858

Tags note

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Sanae 2025-07-07 13:46:05 902 Initial revision (published)