编程介的小学生 2019-05-19 09:42 采纳率: 20.5%
浏览 200

字符串echo方式的一个算法,怎么才能采用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
2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误