![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
模板题
2Ululu
这个作者很懒,什么都没留下…
展开
-
LeetCode1649. 通过指令创建有序数组 C++ 树状数组和线段树
树状数组template <class T> class FenwickTree { int limit; vector<T> arr; //树状数组是从1开始储存的,而不是0 inline int lowbit(int x) { return x & (-x); }public: FenwickTree(int limit=1) { this->limit = limit; arr =原创 2022-04-08 10:22:51 · 423 阅读 · 0 评论 -
Leetcode 2213 由单个字符重复的最长子字符串(线段树)
根据题目要求设计线段树节点内的信息只需要pushup,不需要pushdown所以不需要使用懒标记,其中qurry函数也是多余的,但是此份代码主要是为了记录一个线段树的模板class Solution { static const int N = 1e5 ; string s; struct TreeNode { int l, r, size; char lc, rc; int lmax, rmax, dmax; } t原创 2022-03-24 23:03:35 · 478 阅读 · 0 评论 -
树状数组模板
leetcode5999力扣template <class T> class FenwickTree { int limit; vector<T> arr; //树状数组是从1开始储存的,而不是0 int lowbit(int x) { return x & (-x); }public: FenwickTree(int limit) { this->limit = limit; arr = vector<T>.原创 2022-02-20 09:54:07 · 215 阅读 · 0 评论 -
字符串编码Rabin-Karp算法Leetcode 1044. 最长重复子串
最长重复子串注意的点:字符串是全部小写字母,所以其实就是26进制,这里去比26大的最小质数 C++中unsigned long long会自动处理上溢(相乘、相加超出了它能表示的最大范围2^64-1)和下溢(因为减法使得小于0) 求多少次方的时候,可以使用快速幂class Solution {public: int n; unsigned long long a=29; unsigned long long my_power(int m){ u.原创 2021-12-23 22:49:09 · 120 阅读 · 0 评论 -
CCF最优灌溉(模板题)
第一种是prim算法但是有点坑#include<iostream>using namespace std;typedef long long ll;ll arc[1010][1010];const ll inf=0x3f3f3f3f;int n,e;ll prim(){ ll dist[1010]; ll curent; ll sum=0...原创 2018-08-15 16:31:49 · 957 阅读 · 0 评论