Блог пользователя ivplay

Автор ivplay, история, 10 лет назад, По-английски

I failed to manage any good resource on 2-SAT that illustrates printing solution for the value of each variable.Basically, I am stuck with this problem: lighoj — 1251 — Forming the Council http://www.lightoj.com/volume_showproblem.php?problem=1251

  • What I did: for each (a v b) I connected -a ->b and -b ->a. Then I run SCC and check if a and -a exist in same component.

But how can I decide value of each variable?

Thanks in advance ...

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

So you have made 2sat on the graph. That means that for all vertexes V: V is not in the same SCC az !V. Also if V and U are in the same component then their values are the sam (they are either 0 or 1). Then you chose a random SCC and set all of its values to 1 or 0 (you can chose one of them). You start DFS from any point in that SCC. Let's call that point U. Then all vertexes in the SCC of U are the same as it (0/1). And also for any vertex in the SCC of U (let's call it V) if value of V's SCC is 1 then the value of !V (or -V as you call it) is 0. The same goes if V's SCC value is 0, then the value of !V will be 1. You do DFS while there are vertexes with no set value.

After all vertexes have their value, you will have one possible solution.