摘要:
1 #include<iostream> 2 using namespace std; 3 const int N=1e5+10; 4 int m,idx; 5 int stk[N]; 6 int main (void){ 7 cin>>m; 8 for(int i=0;i<m;i++){ 9 st
阅读全文
posted @ 2020-11-08 09:37
greenofyu
阅读(101)
推荐(0)
摘要:
1 // (1) 在最左侧插入一个数; 2 3 // (2) 在最右侧插入一个数; 4 5 // (3) 将第k个插入的数删除; 6 7 // (4) 在第k个插入的数左侧插入一个数; 8 9 // (5) 在第k个插入的数右侧插入一个数 10 #include<iostream> 11 #incl
阅读全文
posted @ 2020-11-08 09:35
greenofyu
阅读(87)
推荐(0)
摘要:
1 // (1) 向链表头插入一个数; 2 3 // (2) 删除第k个插入的数后面的数; 4 5 // (3) 在第k个插入的数后插入一个数 6 #include<iostream> 7 #include<algorithm> 8 using namespace std; 9 const int
阅读全文
posted @ 2020-11-08 09:34
greenofyu
阅读(100)
推荐(0)
摘要:
面对需要两重循环的问题,如果可以发现其中的某些单调性,使得一个指针移动的过程中,另一个指针只能单调的朝某个方向移动,这就可以称作双指针算法 1 //最长不连续子序列问题 2 #include<iostream> 3 using namespace std; 4 const int N=100010;
阅读全文
posted @ 2020-10-12 14:24
greenofyu
阅读(114)
推荐(0)
摘要:
差分面向的问题是对于一段数组同时加上某个值的问题 差分是前缀和的逆操作 差分没有必要关注差分的构造,因为你写好了插入函数的话,对[i,i]区间插入a[i]就好了 1 #include<iostream> 2 using namespace std; 3 int n,m; 4 const int N=
阅读全文
posted @ 2020-10-12 14:21
greenofyu
阅读(265)
推荐(0)
摘要:
一定从1开始 1 #include<iostream> 2 using namespace std; 3 int n,m; 4 const int N=1e5+10; 5 int a[N],s[N]; 6 int main(void){ 7 cin>>n>>m; 8 for(int i=1;i<=n
阅读全文
posted @ 2020-10-12 14:16
greenofyu
阅读(163)
推荐(0)
摘要:
AcWing模板题:https://www.acwing.com/problem/content/804/ 1 #include<iostream> 2 #include<vector> 3 #include<algorithm> 4 using namespace std; 5 int n,m;
阅读全文
posted @ 2020-10-12 14:14
greenofyu
阅读(125)
推荐(0)
摘要:
1 #include<iostream> 2 using namespace std; 3 const int N=1e5+10; 4 int q[N],tt; 5 int main(void){ 6 int m; 7 cin>>m; 8 for(int i=0;i<m;i++){ 9 int x;
阅读全文
posted @ 2020-10-12 14:12
greenofyu
阅读(118)
推荐(0)
摘要:
1 #include<iostream> 2 using namespace std; 3 int n,m; 4 const int N=1e5+10; 5 const int M=1e6+10; 6 char p[N],s[M];//p是模板串,s是源串 7 int ne[N];//ne表示前缀和
阅读全文
posted @ 2020-10-12 14:07
greenofyu
阅读(102)
推荐(0)
摘要:
来自AcWing->活动->算法基础课 二分模板1 1 int binary_search1(int l,int r){ 2 while(l<r){ 3 int mid=l+r+1>>1; 4 if(check(mid)){ 5 l=mid; 6 }else{ 7 r=mid-1; 8 } 9 }
阅读全文
posted @ 2020-10-02 22:56
greenofyu
阅读(123)
推荐(0)