当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
This is a story from Death Note.
L has determined to find Killa out. Because Killa is a dangerous and cruel guy, L has to make a perfect plan. He has founded a team consisting of n detectives (include himself) to investigate Killa. These guys are extremely trusty, intelligent and cagey. So they won't be easily killed by Killa.
Moreover, m assistants are assigned to help L. Each of them is responsible to transporting information from one detective to another and only in this direction. These guys are also trusty and cagey, but not intelligent enough, so they may be easily killed and the information may be stolen by Killa. So L has a better plan.
Every time L has an instruction which he wants to inform all the detectives. He encodes the instruction and assigns some assistants to deliver the encoded instruction to the detectives they are responsible to contact. Then the detectives who receive the encoded instruction will deliver the instruction to other detectives in the same way. As we want to reduced the possibility of assistants’ being killed, we will always try to use least assistants to make all the detective receive the encoded instruction.
At the same time L will inform the way to decode the instruction to all the detectives in the same way. Of course L doesn’t want Killa to know their plan, so no assistants will be assigned to deliver the encoded instruction and the way to decode it at same time.
L believes that Killa can track and kill no more than one person at one time, so he believes that this plan is perfect. And L can directly get information from his detectives via some magical measure and you needn't worry about the feedback of the instruction.
The task for you is to select the assistants to deliver the encoded instruction and the way to decode it, or tell L that no valid schemes exist.
4 6 2 2 3 3 3 4 4 1 2 0 0 0
YES 1 3 4 2 5 6
时间上限 | 内存上限 |
3000 | 65536 |