![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
模板
循环是人递归是神
北京邮电大学
展开
-
二分模板
//lower_bound,即>=target实现。跳出循环时,l==rint l = 0, r = nums.size();while (l < r) { int m = (l + r) >> 1; if (nums[m] < target) l = m + 1; else r = m;} //upper_bound,即> target实现。取边界ll = 0, r = nums.size() - 1;while (l <= r) {.原创 2020-07-05 23:56:05 · 125 阅读 · 0 评论 -
线段树模板
配合https://www.bilibili.com/video/av47331849食用#include<bits/stdc++.h> using namespace std;#define maxn 100000void build_tree(int arr[], int tree[], int node, int start, int end) { if (start == end) { tree[node] = arr[start]; return; }.原创 2020-06-30 21:59:23 · 169 阅读 · 0 评论 -
链式前向星
模板是这样的????const int maxn = 100000;int head[maxn], Next[maxn], to[maxn], edge[maxn],cnt;void add(int u, int v, int w){ Next[++cnt] = head[u]; to[cnt] = v; head[u] = cnt; edge[cnt] = w;}int main(){ int m,n,w; scanf("%d%d", &m, &n); for (原创 2020-06-20 20:25:54 · 134 阅读 · 0 评论