这题的官方题解中提到的 lemma 是错
误的(2 : The circuit contains at least one of the first four gate kinds, and having at least one such gate is sufficient for the circuit to meet the condition from the problem. )
原因是第二每个门 在取反电路中 输出 0 的条件并不能同时成立。
一个 hack,在 cf 上的大部分代码输出 −1,但只有小部分代码输出正确的答案 0。
3 6 3
nand xx. or xx. nand x.x or x.x nand .xx or .xx
nor xx.... nor ..xx.. nor ....xx
官方题解的错误在 cf comment 里也被提到,可是过了这么多年也没有修正题解。
现在唯一靠谱的做法可能是 um_nik 说的爆搜然后 2sat,但这样复杂度不太靠谱(虽然能过)。这题要解决的问题似乎是“在一个 3sat 问题中最少删去多少个条件使得有解”,我怀疑没有多项式复杂度做法。