QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: Lavria

Posted at: 2026-04-22 20:18:57

Last updated: 2026-04-22 20:23:24

Back to Problem

True Official Editorial

定向策略:将 $s-1$ 的二进制表示对应至节点 $2\sim n$,每个节点上标记对应位的状态($0,1$),并假设节点 $1$ 上标记 $0$,对于一条无向边 $(a_i,b_i)$,假定 $a_i < b_i$,若节点 $a_i,b_i$ 上标记的数字不同,则定向 $b_i\rightarrow a_i$,否则定向 $a_i\rightarrow b_i$。

解密策略:跑一遍 DFS 求出每个节点的状态即可。

Comments

No comments yet.