You are given a permutation of $$$n$$$. Build an undirected graph of $$$n$$$ nodes. There is an edge $$$(i,j)$$$ if and only if $$$i<j$$$ and $$$p_i < p_j$$$. Please find the maximum matching of the graph.
I don't know how to do it in $$$O(n \log n)$$$.
Auto comment: topic has been updated by JianfengZhu (previous revision, new revision, compare).
https://codeforces.me/gym/103627/problem/D is basically that. I only have polylog solutions, but I cited some sources that claim O(n log log n) solutions.
Thanks very much!
I gave ChatGPT this. then it gives me this. Code with a bit of explanation Um have no idea whether it is correct or not xd
Not only is it too slow, but it's also wrong and I think it's due to its sqrt ""optimisation"". I instantly hacked it with the permutation
1 5 3 8 4 2 9 7 6 10
.Don't rely on ML tools for code. They're mistake generators.