Comments

I found the problem, I forgot to add "return" in this place during dfs

if (check(x, y) == 0)
        "return" dfs2(u + 1, cnt);

This can lead to otherwise legal points that I still go to enumerate to modify its diagonal, resulting in a large answer. And the more cases of dfs, the more likely it is to lead to a large answer, which is what led to my question above.

For F,my submission 247420824, why i add the dfs branch (the //add part),the result become worse. For example,

1
BBBWBBB
BBBBBBB
BBBBBBB
BBBBBBB
BBBBBBB
BWBWBBB
BBWBBWB

If I remove the comment symbols in the code and dfs by five cases, I get a result of 7.While following the code inside my link to dfs with three cases gives a result of 6.

Besides , What is the problem with the code inside my link and why can't AC.

Sorry for my poor English, can anyone help me ?

I'm sorry that I can't understand why in D, we need to sum up dp[] and that is the ans."as we can select such a set of vertices exactly from one subtree from the dynamic programming states" is hard for me to understand, can anyone tell me why?

I also think the author made a mistake in writing.Largest and smallest are written backwords.