acwing算法
czyhbo
这个作者很懒,什么都没留下…
展开
-
算法——归并排序
#include<bits/stdc++.h> using namespace std; const int N=1e5+100; int a[N],n,tmp[N]; void merge_sort(int a[],int l,int r) { if(l>=r) return ; int mid=l+r>>1; //1.找临界点 merge_sort(a,l,mid),原创 2021-06-14 20:26:07 · 78 阅读 · 0 评论 -
逆序对——归并排序
归并排序实际上也是把序列进行了分块,二分分块。 树状数组也是分块。 先分再合。 分到底的序列就是原序列 #include<bits/stdc++.h> #define ll long long using namespace std; const int N=1e5+100; int a[N],n,tmp[N]; ll sum=0; void merge_sort(int a[],int l,int r) { if(l>=r) return ; int mid=原创 2021-06-14 20:24:51 · 164 阅读 · 0 评论 -
算法——快速排序
#include<bits/stdc++.h> using namespace std; const int N=1e5+100; int n,p[N]; void quick_sort(int q[],int l,int r) { if(l>=r) return ; int i=l-1,j=r+1,x=q[l+r>>1]; while(i<j) { do i++;while(q[i]<x); .原创 2021-06-14 12:29:08 · 66 阅读 · 0 评论