-->
当前位置:首页 > 题库

PROGRAMMING:Honest man and liar

Luz5年前 (2021-05-10)题库391
There are two kinds of people on an island: honest people and liars. Honest people always tell the truth, while liars always tell lies. It is known that there are n people on the island. Suppose you are a logician, you can ask everyone on the island the same question:
How many honest people are there on the island?
The i-th person on the island replied:
The number of honest people is between AI and Bi.
Please judge whether everyone on the island is an honest person or a liar.
###Input format:
The input includes multiple sets of test data. The first row of each group of test data contains the total number of people on the island n (0 < = n < = 100), followed by N rows. Each row includes the lower bound AI (0 < = AI < = n) of honest people and the upper bound Bi (0 < = Bi < = n) of honest people. N = 0 indicates the end of input.
###Output format:
For each group of test data, the output contains an n-bit binary integer. If the i-th bit of the binary integer is 1, it means that the i-th person is an honest person, and if it is 0, it means that the i-th person is a liar. If the solution of a set of test data is not unique, the binary integer output should be the smallest of all possible solutions. If a set of test data has no solution, output – 1.
###Input example:
```in
one
0 1
four
1 4
2 4
3 4
4 4
three
1 2
0 0
1 3
one
0 0
0
```
###Output example:
```out
one
0000
one hundred and one
–1
```






answer:If there is no answer, please comment