Problem B. Binary Code
Input file: binary.in
Output file: binary.out
Ben has recently learned about binary prefix codes. A binary code is a set of n distinct nonempty code
words si
, each consisting of 0s and 1s. A code is called a prefix code if for every i 6= j neither si
is a prefix
of sj nor sj is a prefix of si
. A word x is called a prefix of a word w if there exists a possibly empty word
y, such that xy = w. For example, x = 11 is a prefix of w = 110 and x = 0100 is a prefix of w = 0100.
Ben found a paper with n lines of binary code in it. However, this paper is pretty old and there are some
unreadable characters. Fortunately, each word contains at most one unreadable character.
Ben wants to know whether these n lines could represent a binary prefix code. In other words, can he
replace every unreadable character with 0 or 1, so that the code becomes a prefix code
Binary_Code 2-SAT神题
最新推荐文章于 2019-09-26 13:25:04 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)