上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页
摘要: 简单的一道深搜: 思路:让每个有奶牛的农场沿着道路跑下去,跑到的农场加上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)
摘要: 链接:https://www.luogu.com.cn/problem/P1352 树形dp板子,感觉很巧妙,利用01表示是否取 代码: #include<iostream> #include<vector> #include<algorithm> #include<math.h> #include 阅读全文
posted @ 2024-05-10 17:10 WHUStar 阅读(9) 评论(0) 推荐(0)
摘要: 链接:https://codeforces.com/problemset/problem/1833/D 题面: 细节:分类讨论 约定记号:a,b[c,d],e,f:选定cd为反向序列。 ①当最大值出现在最后一个元素 可以确定:必然的形式是[a,...,p],maxn,右括号位置一定不变,那么就移动左 阅读全文
posted @ 2024-05-10 15:51 WHUStar 阅读(22) 评论(0) 推荐(0)
摘要: 链接:https://codeforces.com/problemset/problem/1773/E 思路 首先先得出最终序列,因为它具有唯一性,然后再根据其中的前后关系来判断原来的数列需要切几刀。然后再根据切几刀形成的最终数列判断需要合并几次。 例如: 目标数列是ABCDEF,而给出的某两段序列 阅读全文
posted @ 2024-05-10 13:55 WHUStar 阅读(19) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P2341 题目: 思路: tarjan缩点:把所有强连通分量缩成一个点,然后统计出度为0的缩点,如果只有一个,那么能成为明星的数量就是该缩点扩充后的个数;如果不止一个,那就是0. 代码: 额,就是不知道为什么debug了两节课 阅读全文
posted @ 2024-05-09 11:46 WHUStar 阅读(17) 评论(0) 推荐(0)
摘要: Tarjan模板 #include<iostream> #include<vector> #include<algorithm> #include<math.h> #include<sstream> #include<string> #include<string.h> #include<ioman 阅读全文
posted @ 2024-05-09 09:57 WHUStar 阅读(40) 评论(0) 推荐(0)
摘要: https://www.luogu.com.cn/problem/P3388 求割点模板 #include<iostream> #include<vector> #include<algorithm> #include<math.h> #include<sstream> #include<strin 阅读全文
posted @ 2024-05-09 09:28 WHUStar 阅读(49) 评论(0) 推荐(0)
摘要: 题面: 链接:https://www.luogu.com.cn/problem/P3916 思路:反向遍历图 啊卡了好久,如果正序来的话还得考虑环和先后次序的问题 代码: #include<iostream> #include<vector> #include<algorithm> #include 阅读全文
posted @ 2024-05-08 17:24 WHUStar 阅读(17) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页