上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 35 下一页
摘要: 题目链接:https://www.acwing.com/problem/content/146/ 令 \(D[i]\) 表示 \(i\) 到根路径上的值的异或之和, 则根据异或的性质,\(u,v\) 间路径的异或和即为 \(D[u] ^ D[v]\) 所以问题就变成了在 \(D\) 中选出异或值最大 阅读全文
posted @ 2020-11-08 15:52 Tartarus_li 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/145/ 把每个整数看成长度为 $32$ 位的 $01$ 串,插入$trie$树, 根据异或运算的性质,要得到最大的异或值,那每次要尽量沿着与当前数字相反的方向走 #include<cstdio> #includ 阅读全文
posted @ 2020-11-08 15:34 Tartarus_li 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/144/ Trie板子题 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<cmath> #in 阅读全文
posted @ 2020-11-08 15:20 Tartarus_li 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/description/143/ 引理:\(S[1~i]\) 具有长度为 \(len < i\) 的循环元的充要条件是 \(len\) 能整除 \(i\), 并且 \(S[len+1~i] = S[1~i-len 阅读全文
posted @ 2020-11-07 23:38 Tartarus_li 阅读(111) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/141/ 哈希做法: 对于每个回文串,长度要么是奇数,要么是偶数 如果长度为奇数,那么枚举中间点,二分长度,用哈希判断左右字串是否相等 如果为偶数,则枚举中间空格 预处理出前缀和后缀字串的哈希值,则可以在$O(1)$时间内 阅读全文
posted @ 2020-11-07 11:45 Tartarus_li 阅读(102) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/138/ 找前驱和后继,set基本操作 加哨兵节点 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<cm 阅读全文
posted @ 2020-11-07 10:45 Tartarus_li 阅读(82) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/description/135/ 优先队列,每次将最长的蚯蚓取出来,切开后减去当前的偏移量,再放回队列 但 \(m\) 的范围是 $7e6$,显然需要线性做法 线性做法,那就需要考虑一下蚯蚓长度的单调性了, 可以证明,如果 阅读全文
posted @ 2020-11-06 20:56 Tartarus_li 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/133/ 维护一个栈,使得栈内矩形高度单调递增, 如果当前矩形比栈顶高度高,则之间入栈, 否则不断取出栈顶,直到栈为空或栈顶高度比当前矩形小 出栈过程中累计被弹出的矩形的宽度之和,没弹出一个矩形,就用其高度乘上累 阅读全文
posted @ 2020-11-06 15:34 Tartarus_li 阅读(78) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/125/ 可以发现,横纵坐标的移动是分开的, 所以先对 \(y\) 轴进行操作,就是普通的货仓选址问题 再考虑 \(x\) 轴,最终的排列,士兵的排列顺序一定是不变的, 假设第一个士兵移动到的位置是$a$ 那么答案就是$\ 阅读全文
posted @ 2020-11-06 12:42 Tartarus_li 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.acwing.com/problem/content/124/ 环形均分纸牌,求出前缀和后转化为货仓选址问题 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #inc 阅读全文
posted @ 2020-11-06 11:30 Tartarus_li 阅读(52) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 35 下一页