-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathantiqs.cpp
More file actions
55 lines (52 loc) · 1.34 KB
/
antiqs.cpp
File metadata and controls
55 lines (52 loc) · 1.34 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <stack>
#include <set>
typedef long long ll;
typedef unsigned long long ull;
#define all(v) v.begin(), v.rend()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
int partition_(vector<int> &vec, int l, int r){
int m = vec[(l + r)/2];
int i = l;
int j = r;
while(i <= j){
while(vec[i] < m) i++;
while(vec[j] > m) j--;
if(i >= j) break;
swap(vec[i++], vec[j--]);
}
return j;
}
void quickSort(vector<int> &a, int l, int r){
if(l < r){
int q = partition_(a, l, r);
quickSort(a, l, q);
quickSort(a, q + 1, r);
}
}
void file_cin(){
freopen("antiqs.in", "r", stdin);
freopen("antiqs.out", "w", stdout);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
file_cin();
int n;
cin >> n;
vector<int> vec;
for(int i = 0; i < n; i++){
vec.push_back(i + 1);
swap(vec[(vec.size() - 1) / 2], vec.back());
}
for(int i = 0; i < n; i++){
cout << vec[i] << " ";
}
}