“Mangers and Engineers”

来源:互联网 发布:mac在哪里下游戏 编辑:程序博客网 时间:2024/06/16 00:41
Q:The FBI has surrounded the headquarters of the Norne corporation. There are n people in the building. Each person is either an engineer or a manager. All computer files have been deleted, and all documents have been shredded by the managers. The problem confronting the FBI interrogation team is to separate the people into these two classes, so that all the managers can be locked up and all the engineers can be freed. Each of then people knows the status of all the others. The interrogation consists entirely of asking personi if personj is an engineer or a manager. The engineers always tell the truth. What makes it hard is that the managers may not tell the truth. In fact, the managers are evil geniuses who are conspiring to confuse the interrogators.
  1. Under the assumption that more than half of the people are engineers, can you find a strategy for the FBI to find one engineer with at mostn-1 questions?
  2. Is this possible in any number of questions if half the people are managers?
  3. Once an engineer is found, he/she can classify everybody else. Is there a way to classify everybody in fewer questions?





A:

1.如果manager人数少于engineer人数:

    initialize:将所有人放进UNSEEN集合中,从UNSEEN集合中随机选一人,放在STACK堆栈的top;

    step1:从UNSEEN集合中随机选一个人x,向当前STACK堆栈的top元素y询问x的身份。如果y说x是manager,同时丢掉x和y,如果是engineer,将x放到STACK的top;

    step2:repeat  step1,直到UNSEEN集合为空,此时STACK的top元素的身份必然为engineer;

    step3:向该engineer询问所有人的身份(因为他不撒谎),Ends。

    n-1步就可以完成(特定情况下可以优化成n-2,n-3,不详述,参照Ref.)

    but,如何proof???

2.如果manager人数多于或等于engineer人数,问题无解。

3. don't konw.


(Ref:The Puzzle Toad - 1)

原创粉丝点击