九度OJ 题目1448:Legal or Not (拓扑排序)

ACM-DIY是一个和谐的QQ群,成员间通过交流和帮助形成了一张复杂的‘师傅-徒弟’关系网。题目要求判断这个关系网中是否存在非法的循环关系,即某人既是某人的师傅又是其徒弟。拓扑排序可以用于解决这个问题,合法关系应满足师傅可以有多名徒弟,徒弟也可有多个师傅,但不允许存在A既是B的师傅也是B的徒弟的情况。请根据输入数据,利用拓扑排序算法判断关系是否合法。
摘要由CSDN通过智能技术生成
题目描述:

ACM-DIY is a large QQ group where many excellent acmers get together. It is so harmonious that just like a big family. Every day,many "holy cows" like HH, hh, AC, ZT, lcc, BF, Qinz and so on chat on-line to exchange their ideas. When someone has questions, many warm-hearted cows like Lost will come to help. Then the one being helped will call Lost "master", and Lost will have a nice "prentice". By and by, there are many pairs of "master and prentice". But then problem occurs: there are too many masters and too many prentices, how can we know whether it is legal or not?We all know a master can have many prentices

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值