07 2024 档案

摘要:树的重心 原题 B站董晓讲解 任取一点u,若以u为重心,则分为两类:一类是u的子树,一类是u上面的部分 需要算出u的最大子树的节点树和u上面的部分的节点数,然后取两者的最大值。 add函数:a所对应的单链表中插入b a作为根 我的代码 #include<iostream> using namespa 阅读全文
posted @ 2024-07-31 20:02 某朝 阅读(16) 评论(0) 推荐(0) 编辑
摘要:树和图的框架 #include<iostream> #include<algorithm> using namespace std; const int N = 10010; int h[N], e[N], ne[N], idx; //a所对应的单链表中插入b a作为根 void add(int a 阅读全文
posted @ 2024-07-29 14:27 某朝 阅读(16) 评论(0) 推荐(0) 编辑
摘要:董晓的宽搜模板 #include <iostream> #include <cstring> #include <algorithm> #include <queue> using namespace std; const int N = 100010; int n, m, a, b; vector 阅读全文
posted @ 2024-07-29 11:21 某朝 阅读(20) 评论(0) 推荐(0) 编辑
摘要:大佬的解析DFS #include<iostream> using namespace std; const int N = 10; int n; int path[N]; bool st[N]; void dfs(int u) { if (u == n) { for (int i = 0; i < 阅读全文
posted @ 2024-07-28 21:06 某朝 阅读(22) 评论(0) 推荐(0) 编辑
摘要:简单用法 阅读全文
posted @ 2024-07-28 15:28 某朝 阅读(8) 评论(0) 推荐(0) 编辑
摘要:拉链法 哈希函数:f(x) = ( x % N + N ) % N k就是下标, h[k]=x 哈希表的头节点(head指针)是idx,就是第几个插入的序号 idx没什么用,用头插法插入元素,插入和寻找都是h[k]在起作用 idx会变,当插入第二个下标为k的元素时,idx就会变成新的。 #inclu 阅读全文
posted @ 2024-07-27 21:36 某朝 阅读(13) 评论(0) 推荐(0) 编辑
摘要:插入一个数 heap[++size]=x; up(size); 求集合当中的最下值 heap[1]; 删除最小值 heap[1]=heap[size]; size--; down(1); 删除任意一个元素 heap[k]=heap[size]; size--; up(k); down(k); 修改任 阅读全文
posted @ 2024-07-27 17:46 某朝 阅读(6) 评论(0) 推荐(0) 编辑
摘要:// 关闭输入输出缓存,使效率提升 ios::sync_with_stdio(false); // 解除cin和cout的默认绑定,来降低IO的负担使效率提升 cin.tie(NULL); cout.tie(NULL); 阅读全文
posted @ 2024-07-27 16:21 某朝 阅读(15) 评论(0) 推荐(0) 编辑
摘要:一共两个操作:合并和查询。 开始是没有并集的,得先合并再查询。 #include<iostream> using namespace std; const int N = 100010; int p[N]; int n, m; //p[x]=find(p[x]),直到找到它的祖宗节点,之后返回祖宗节 阅读全文
posted @ 2024-07-27 16:06 某朝 阅读(10) 评论(0) 推荐(0) 编辑
摘要:Trie树 阅读全文
posted @ 2024-07-27 11:41 某朝 阅读(6) 评论(0) 推荐(0) 编辑
摘要:董晓 阅读全文
posted @ 2024-07-26 15:04 某朝 阅读(9) 评论(0) 推荐(0) 编辑
摘要:单调栈 视频连接 #include<iostream> using namespace std; const int N = 100010; int stk[N], tt; int main() { int n; cin >> n; while (n--) { int x; scanf("%d", 阅读全文
posted @ 2024-07-25 19:21 某朝 阅读(8) 评论(0) 推荐(0) 编辑
摘要:题目大意 实现一个单链表,链表初始为空,支持三种操作: (1) 向链表头插入一个数; (2) 删除第k个插入的数后面的数; (3) 在第k个插入的数后插入一个数 现在要对该链表进行M次操作,进行完所有操作后,从头到尾输出整个链表。 注意 : 题目中第k个插入的数并不是指当前链表的第k个数。例如操作过 阅读全文
posted @ 2024-07-25 16:36 某朝 阅读(16) 评论(0) 推荐(0) 编辑
摘要:acwing803 我的代码 #include <iostream> #include <vector> #include <algorithm> using namespace std; typedef pair<int, int> PII; void merge(vector<PII>& seg 阅读全文
posted @ 2024-07-25 12:31 某朝 阅读(8) 评论(0) 推荐(0) 编辑
摘要:acwing802区间和 注意:find只是在alls里查找 //x->kx //l->kl //r->kr //一个数离散化对应坐标 //求l~r之间的区间和,就是求a[kl~kr] //add: 保存真实的下标和相应的值 //alls : 用来保存真实的下标和想象的下标的映射关系 //query 阅读全文
posted @ 2024-07-23 11:53 某朝 阅读(12) 评论(0) 推荐(0) 编辑
摘要://洛谷p2367语文成绩 一维差分 #include<iostream> using namespace std; const int N = 10000010; int a[N], b[N]; int n; int p; void insert(int l, int r, int c) { b[ 阅读全文
posted @ 2024-07-22 13:25 某朝 阅读(8) 评论(0) 推荐(0) 编辑
摘要://洛谷p8218求区间和 #include<iostream> using namespace std; const int N = 100010; int n; int m; int a[N], s[N]; int main() { cin >> n; for (int i = 1; i <= 阅读全文
posted @ 2024-07-22 13:21 某朝 阅读(6) 评论(0) 推荐(0) 编辑
摘要:加法 #include<iostream> using namespace std; string s1, s2; int a[101], b[101],c[101]; void strtoint(string str,int des[]) { for (int i = 0; i < str.siz 阅读全文
posted @ 2024-07-20 21:35 某朝 阅读(13) 评论(0) 推荐(0) 编辑
摘要:void mySort::printArr(vector<int>& vec) { for (const auto& i : vec) { cout << i<<" "; } } 冒泡排序 把最大的数放到最后面 void mySort::BubbleSort(vector<int> &vec) { 阅读全文
posted @ 2024-07-20 21:31 某朝 阅读(28) 评论(0) 推荐(0) 编辑
摘要:循环 int search1(int a[], int len,int key) { int l = 0, r = len - 1; while (l <= r) { int mid = l + (r - l) / 2; if (a[mid] == key)return mid; else if(a 阅读全文
posted @ 2024-07-20 14:37 某朝 阅读(9) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示