编程介的小学生 2019-09-01 21:59 采纳率: 20.5%
浏览 153

God and Devil C语言

Problem Description
There are many gods and devils living on HDU Island, and echo is one of them. Gods always tell the truth whereas devils sometimes tell the truth but sometimes not. What's more, every god and devil knows all the others are a god or a devil.
One day, an accident unfortunately happened which made echo lose her memory. She was so despairing and determined to turn to others for help. She asked all the residents a question, but all of the answers were merely "Be careful! X is a devil!". As a result she failed to arouse her memory. However, she has to find out a method to calculate the minimum number of devils on the island. Could you help echo to manage it well?

Input
There are multi-cases (The total number of cases won't exceed 20). First line is an integer N(1<=N<=15000), the total number of gods and devils. Then N lines follow, each line includes a name, and the length of each name won't exceed 30. The first name is "echo". The next N-1 lines will be as the formation "A says: Be careful! B is a devil!"(A is different from B), and you can assume that at least one of them will consider echo is a devil and says "Be careful! echo is a devil!".

Output
Output the minimum number of devils in the island.

Sample Input
3
echo
bigdog
smalldog
smalldog says: Be careful! bigdog is a devil!
bigdog says: Be careful! echo is a devil!
4
echo
Lethe
bigdog
smalldog
Lethe says: Be careful! bigdog is a devil!
smalldog says: Be careful! echo is a devil!
bigdog says: Be careful! smalldog is a devil!

Sample Output
1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题