JianfengZhu's blog

By JianfengZhu, history, 18 months ago, In English

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)$$$.

  • Vote: I like it
  • +58
  • Vote: I do not like it

»
18 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by JianfengZhu (previous revision, new revision, compare).

»
18 months ago, # |
  Vote: I like it +39 Vote: I do not like it

https://codeforces.net/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.

»
18 months ago, # |
  Vote: I like it -96 Vote: I do not like it

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

  • »
    »
    18 months ago, # ^ |
      Vote: I like it +46 Vote: I do not like it

    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.