上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 21 下一页
摘要: SPFA #include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <queue> using namespace std; #define ll long long #define p 阅读全文
posted @ 2020-05-21 19:23 SummerMingQAQ 阅读(98) 评论(0) 推荐(0) 编辑
摘要: Bellman-ford #include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std; #define ll long long #define pb push_ba 阅读全文
posted @ 2020-05-21 17:31 SummerMingQAQ 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Ponk Warshall 思路:容易想到如果存在 "AG" "GA"这种,那一定是先交换这些,可以一次交换解决两个位置,如果不存在前面的情况,我们需要找到类似"AG","GT"这种斜对角能抵消的,得到"AT"然后我们需要马上去找有无"AT","TA"这种情况的。 我们知道"ATCG"只会出现16种 阅读全文
posted @ 2020-05-18 19:32 SummerMingQAQ 阅读(391) 评论(0) 推荐(0) 编辑
摘要: G. Pot!! 思路:区间维护线段树即可,由题意可知我们只需要区间维护cnt[2, 3, 5, 7]个数的最大值即可。 1 #include <cstdio> 2 #include <iostream> 3 #include <cstdio> 4 #include <algorithm> 5 #i 阅读全文
posted @ 2020-05-11 11:04 SummerMingQAQ 阅读(318) 评论(0) 推荐(0) 编辑
摘要: Garland 1 #include <cstdio> 2 #include <iostream> 3 #include <cstdio> 4 #include <algorithm> 5 #include <functional> 6 #include <set> 7 #include <vect 阅读全文
posted @ 2020-05-09 17:41 SummerMingQAQ 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Just Eat It! 思路:最大连续子段和:判断前缀和是否大于0,如果大于0对后面有贡献,否则置0. #include <cstdio> #include <iostream> #include <cstdio> #include <algorithm> #include <functional 阅读全文
posted @ 2020-05-07 16:35 SummerMingQAQ 阅读(287) 评论(0) 推荐(0) 编辑
摘要: Dr. Evil Underscores 思路:对每位二进制进行判断,如果当前位的二进制都为0或者1,则这个位对答案贡献为0,如果当前为有0有1则这个位对答案贡献(1 << bit),然后对当前位为0和为1的分成两个集合进行分治,所有答案取min。 1 #include <cstdio> 2 #in 阅读全文
posted @ 2020-05-06 15:21 SummerMingQAQ 阅读(259) 评论(0) 推荐(0) 编辑
摘要: Minimax Problem 思路:我们通过二分去试探答案,假设答案是x,则我们把数组中大于等于key的标记为1,反之标为0。我们知道m = 8,则01串的情况只有2^8-1种,那么我们可以把n行的情况压缩在vis[2^8-1]长度的数组中,vis记录符合的下标,如果(!vis[x] && !vi 阅读全文
posted @ 2020-05-05 12:22 SummerMingQAQ 阅读(223) 评论(0) 推荐(0) 编辑
摘要: Nastya and Scoreboard 思路:先确定每个位置上变成0~9需要额外点亮多少灯,因为需要用完k个灯,可以有前导零,我们从最后一位开始点亮灯,往前递推可行的方案。dp[当前位置][用了j个灯] = (可行,不可行)。 然后就判断能不能用完k个灯,可以得话从前往后以9~0顺序寻找最大数字 阅读全文
posted @ 2020-05-05 12:16 SummerMingQAQ 阅读(268) 评论(0) 推荐(0) 编辑
摘要: Cow and Message 思路:我们可以发现,超过两位的字符一定先包含两位相同的字符,所以我们只需统计长度为1和长度为2的字符。我们只需枚举所有两位字符的情况就可,用前缀和可以快速算出哪些位置有几个该字符,当然,统计每个字符下标,然后二分也可以。 1 #include <iostream> 2 阅读全文
posted @ 2020-04-29 10:42 SummerMingQAQ 阅读(204) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 21 下一页