随笔分类 -  新函数

零碎知识点
摘要:原理: 都是基于二分查找。 升序数组中: lower_bound( begin,end,num):返回(begin和end之间)第一个大于或等于num的数字的地址。 下标=返回地址-begin; upper_bound(begin,end,num) : (同上) 唯一不同——返回第一个大于num的数 阅读全文
posted @ 2022-05-09 17:55 xxj112 阅读(53) 评论(0) 推荐(0)
摘要:fill 在头文件<algorithm>里。 按照数组的始末位置以一个数组元素为单位赋值,将区间内的每一个元素都赋值为val。 代码:fill(vector.begin(), vector.end(), val); fill_n() 在头文件<algorithm>里。 从当前起始点开始,将之后的cn 阅读全文
posted @ 2022-05-09 17:40 xxj112 阅读(105) 评论(0) 推荐(0)
摘要:#include<iostream> #include<queue> #include<vector> using namespace std; typedef pair<int,int> pll; int main() { priority_queue<pll,vector<pll>,less<p 阅读全文
posted @ 2022-05-09 17:22 xxj112 阅读(35) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<string.h> //int gcd(int a,int b) //较快 //{ // return b>0?gcd(b,a%b):a; //} int gcd(int a,int b) //超快 { // if(b) // while((a% 阅读全文
posted @ 2022-05-05 15:22 xxj112 阅读(70) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> #include<vector> using namespace std; vector<int> G[666]; int e[630]; int main() { int n,m,a,b; while(~scanf("%d %d",&n,&m)) { 阅读全文
posted @ 2022-05-03 21:43 xxj112 阅读(23) 评论(0) 推荐(0)
摘要:KMP算法分两步 一:求子字符串(p)的next数组 void getnext(int nextt[],string p) { nextt[0]=-1; for (int i=1;i<p.size();i++) { int j=nextt[i-1]; while ((p[j+1]!=p[i])&&( 阅读全文
posted @ 2022-04-28 08:53 xxj112 阅读(42) 评论(0) 推荐(0)
摘要:#include<iostream> #include<map> #include<queue> using namespace std; typedef long long ll; const int N=10000; int e[N]; int tmp[N]; ll merge_sort(int 阅读全文
posted @ 2022-04-21 23:30 xxj112 阅读(40) 评论(0) 推荐(0)
摘要:map大数据时会超时 map有自动排序(降序:按first)和查重功能。 #include<iostream> #include<map> using namespace std; map<int, int> mp; void sss() { for(auto it=mp.begin();it!=m 阅读全文
posted @ 2022-04-21 22:49 xxj112 阅读(51) 评论(0) 推荐(0)