0%

sort

1
2
3
4
bool cmp(const int &a, const int &b) {
return a > b;//从大到小
}
sort(a + 1, a + 1 + n, cmp);

qsort

1
2
3
4
int cmp2(const void* a, const void* b) {
return *(int*)b - *(int*)a;//从大到小
}
qsort(a+1, n, sizeof(a[0]),cmp2);

快排

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void mysort(int l, int r) {
if (l == r) return;

int mid = (l + r) / 2;
mysort(l, mid);
mysort(mid + 1, r);

int i = l;
int j = mid + 1;
int k = l;
while (i <= mid && j <= r) {
if (a[i] <= a[j]) {
b[k++] = a[i++];
}
else {
b[k++] = a[j++];
}
}
while (i <= mid) {
b[k++] = a[i++];
}
while (j <= r) {
b[k++] = a[j++];
}
for (int t = l; t <= r; t++) {
a[t] = b[t];
}
}

归并排序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void mysort2(int l, int r) {
if (l >= r) return;
int mid = (l + r) / 2;
int i = l;
int j = r;
int flag = a[i];
while (i<j) {
while (i < j && flag <= a[j]) {
j--;
}
a[i] = a[j];
while (i < j && a[i] <= flag) {
i++;
}
a[j] = a[i];
}
a[i] = flag;
mysort2(l, i);
mysort2(i + 1, r);
}

改host

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
140.82.113.3      github.com
140.82.114.20 gist.github.com

151.101.184.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.184.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.184.133 camo.githubusercontent.com
151.101.184.133 avatars0.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.28.133 avatars1.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com

改DNS

1
2
233.5.5.5
233.6.6.6

结果都没用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void mysort(vector<int>& nums, int l, int r){
if(l>=r) return;
int tl = l;
int tr = r;

int flag = nums[l];
while(l<r){

while(l<r&&flag<=nums[r]){
r--;
}
nums[l] = nums[r];
while(l<r&&nums[l]<=flag){
l ++;
}
nums[r] = nums[l];
}
nums[l] = flag;

mysort(nums, tl, l-1);
mysort(nums, l+1, tr);
}