就想问一下这是神马排序

Kinghero King of the summit 2023-08-15 0:09:00 2023-08-15 13:57:49 0
昨天(8月14日)洛谷csp-j模拟赛复制的【狗头】
#include<iostream>
using namespace std;
int a[100005], b[100005], n, m;
void very_quick_sort(int l, int r, int p, int q) {
	if (l >= r || p > q) {
		return;
	}
	int mid = (l + r) / 2;
	int p0 = p - 1;
	int q0 = q + 1;
	for (int i = p; i <= q; i ++) {
		if (a[i] > mid) b[++ p0] = a[i];
		else b[-- q0] = a[i];
	}
	for (int i = p; i <= q; i ++)
		a[i] = b[i];
	very_quick_sort(mid + 1, r, p, p0);
	very_quick_sort(l, mid, q0, q);
}
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i ++)
		cin >> a[i];
	very_quick_sort(1, m, 1, n);

	for (int i = 1; i <= n; i ++
	     cout << a[i] << " ";
	     cout << endl;
	     return 0;
}
{{ vote && vote.total.up }}

共 2 条回复

CPP 刷题王

某种比较快的排序方法(应该是快排或者归并排序

Kinghero King of the summit

哪位知道