合集-数据结构与算法

摘要:循环 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 某朝 阅读(15) 评论(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 某朝 阅读(35) 评论(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 某朝 阅读(17) 评论(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 某朝 阅读(31) 评论(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 某朝 阅读(23) 评论(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 某朝 阅读(20) 评论(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 某朝 阅读(11) 评论(0) 推荐(0)
摘要:题目大意 实现一个单链表,链表初始为空,支持三种操作: (1) 向链表头插入一个数; (2) 删除第k个插入的数后面的数; (3) 在第k个插入的数后插入一个数 现在要对该链表进行M次操作,进行完所有操作后,从头到尾输出整个链表。 注意 : 题目中第k个插入的数并不是指当前链表的第k个数。例如操作过 阅读全文
posted @ 2024-07-25 16:36 某朝 阅读(28) 评论(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 某朝 阅读(19) 评论(0) 推荐(0)
摘要:董晓 阅读全文
posted @ 2024-07-26 15:04 某朝 阅读(20) 评论(0) 推荐(0)
摘要:Trie树 阅读全文
posted @ 2024-07-27 11:41 某朝 阅读(11) 评论(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 某朝 阅读(15) 评论(0) 推荐(0)
摘要:// 关闭输入输出缓存,使效率提升 ios::sync_with_stdio(false); // 解除cin和cout的默认绑定,来降低IO的负担使效率提升 cin.tie(NULL); cout.tie(NULL); 阅读全文
posted @ 2024-07-27 16:21 某朝 阅读(35) 评论(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 某朝 阅读(9) 评论(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 某朝 阅读(20) 评论(0) 推荐(0)
摘要:简单用法 阅读全文
posted @ 2024-07-28 15:28 某朝 阅读(9) 评论(0) 推荐(0)
摘要:#include <iostream> #include <iomanip> #include <unordered_map> #include <string> using namespace std; const int N = 100010; unordered_map<string, str 阅读全文
posted @ 2024-09-17 11:34 某朝 阅读(64) 评论(0) 推荐(0)
摘要:汉诺塔 逆序输出(栈先进后出) #include<iostream> #include<stack> #include<tuple> using namespace std; int n; const int N = 10010; stack <tuple<int, char, char, char 阅读全文
posted @ 2024-09-21 16:22 某朝 阅读(15) 评论(0) 推荐(0)
摘要:ds题目 #include<iostream> using namespace std; typedef struct Node { int index; int data; }node; const int N = 10010; node a[N]; int output[N]; int hh = 阅读全文
posted @ 2024-09-23 14:20 某朝 阅读(20) 评论(0) 推荐(0)
摘要:查找不存在的元素 左边比它小,右边比它大 阅读全文
posted @ 2024-10-18 22:44 某朝 阅读(9) 评论(0) 推荐(0)
摘要:题目 #include<iostream> #include<string> #include<map> #include<algorithm> using namespace std; struct stu { string id; int place; int score; int rank; 阅读全文
posted @ 2024-10-21 17:00 某朝 阅读(10) 评论(0) 推荐(0)
摘要:字符串关键词的散列函数构造 平方探测法 阅读全文
posted @ 2024-10-30 21:01 某朝 阅读(13) 评论(0) 推荐(0)
摘要:Description 索隆是有名的路痴,为了不让索隆走丢,娜美给了索隆一本地图。该地图有N个城市,编号从1到N。每个城 市有个代号,索隆每到一个城市只能知道该城市的代号而不知道该城市的编号,现有一份编号与代号对应的 清单,你能帮索隆尽快地找到所在城市的编号吗? Input 输入第一行为两个正整数N 阅读全文
posted @ 2024-11-06 11:34 某朝 阅读(32) 评论(0) 推荐(0)
摘要:【递归树求时间复杂度-哔哩哔哩】 https://b23.tv/smeBKsf 阅读全文
posted @ 2024-12-06 21:04 某朝 阅读(7) 评论(0) 推荐(0)