摘要: 简单的一道深搜: 思路:让每个有奶牛的农场沿着道路跑下去,跑到的农场加上root地方的奶牛数量,最后统计能有k头奶牛的农场数量就是答案 代码: #include<iostream> #include<vector> #include<algorithm> #include<math.h> #incl 阅读全文
posted @ 2024-05-11 21:43 WHUStar 阅读(26) 评论(0) 推荐(0)
摘要: 拓扑排序,有向图 记录每个点的入度,进行拓扑排序 然后怎么计算ans? 通过每个点的入度传递到子节点,在食物链的末尾加上即可,注意求余。 原理: 代码: #include<iostream> #include<vector> #include<algorithm> #include<math.h> 阅读全文
posted @ 2024-05-11 17:07 WHUStar 阅读(28) 评论(0) 推荐(0)
摘要: 简记: 1.参考学习: https://blog.csdn.net/qaqwqaqwq/article/details/126124806 https://www.cnblogs.com/cjjsb/p/9771868.html 2.代码: #include<iostream> #include<v 阅读全文
posted @ 2024-05-11 14:49 WHUStar 阅读(15) 评论(0) 推荐(0)