Task: | Just do it |
Sender: | asdf4321 |
Submission time: | 2024-11-16 14:08:19 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
Code
#include <bits/stdc++.h>using namespace std;#define int long long#define rep(i, a, b) for (int i = a; i < (b); i++)#define all(x) begin(x), end(x)#define sz(x) (int)(x).size()typedef long long ll;typedef pair<int, int> pii;typedef vector<int> vi;inline int median(const int& a, const int& b, const int& c){int m1 = min(a, b), m2 = min(a, c), m3 = min(b, c);int ret = max(max(m1, m2), m3);return ret;}int HiitSort(vi& array, int low, int high){if(high - low <= 1)return 0;int ret = 0, pivot = median(array[low], array[(low+high)/2], array[high-1]);int a = low, b = high - 1;while(true){while(array[a] < pivot) {a++, ret++;}while(array[b] > pivot) {b--, ret++;}if(a >= b)break;swap(array[a], array[b]);a++, b--;}ret += HiitSort(array, low, a);ret += HiitSort(array, a, high);return ret;}signed main() {#ifdef LOCALfreopen(".inp", "r", stdin);freopen(".out", "w", stdout);#endifint n;cin >> n;vi test(n, 0);// for(int i = 0; i<n; i++)// test[i] = i+1;if( n <= 5){for(int i=0; i<n; i++)test[i] = i+1;int the = n*n / 4, times;bool flag = true;while(flag){vi array = test;times = HiitSort(array, 0, n);if(times >= the){for(int x: test)cout << x << " ";cout << endl;// the = times;return 0;}next_permutation(all(test));}} else {test[n/2] = n;test[n/2 - 1] = 1;for(int i = 0; i < n/2 - 1; i++)test[i] = i+2;for(int i = n/2 + 1; i < n; i++)test[i] = i;for(int x: test)cout << x << " ";}// int the = n*n / 4, times;// vi array = test;// times = HiitSort(array, 0, n);// cerr << (times > the) << ' ' << times << ' ' << the;return 0;}
Test details
Test 1
Verdict: ACCEPTED
input |
---|
2 |
correct output |
---|
1 2 |
user output |
---|
1 2 |
Test 2
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
1 2 3 |
user output |
---|
1 2 3 |
Test 3
Verdict: ACCEPTED
input |
---|
4 |
correct output |
---|
1 2 3 4 |
user output |
---|
1 2 3 4 |
Test 4
Verdict: ACCEPTED
input |
---|
5 |
correct output |
---|
1 2 4 3 5 |
user output |
---|
1 2 3 4 5 |
Test 5
Verdict: ACCEPTED
input |
---|
6 |
correct output |
---|
1 2 3 5 4 6 |
user output |
---|
2 3 1 6 4 5 |
Test 6
Verdict: ACCEPTED
input |
---|
7 |
correct output |
---|
1 2 4 6 5 3 7 |
user output |
---|
2 3 1 7 4 5 6 |
Test 7
Verdict: ACCEPTED
input |
---|
8 |
correct output |
---|
1 2 3 5 7 6 4 8 |
user output |
---|
2 3 4 1 8 5 6 7 |
Test 8
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
1 2 4 6 8 3 7 5 9 |
user output |
---|
2 3 4 1 9 5 6 7 8 |
Test 9
Verdict: ACCEPTED
input |
---|
10 |
correct output |
---|
1 2 3 5 7 9 4 8 6 10 |
user output |
---|
2 3 4 5 1 10 6 7 8 9 |
Test 10
Verdict: ACCEPTED
input |
---|
99 |
correct output |
---|
1 2 4 6 8 10 12 14 16 18 20 22... |
user output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
Test 11
Verdict: ACCEPTED
input |
---|
100 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
Test 12
Verdict: ACCEPTED
input |
---|
101 |
correct output |
---|
1 2 4 6 8 10 12 14 16 18 20 22... |
user output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
Test 13
Verdict: ACCEPTED
input |
---|
300 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
Test 14
Verdict: ACCEPTED
input |
---|
500 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
Test 15
Verdict: ACCEPTED
input |
---|
998 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
Test 16
Verdict: ACCEPTED
input |
---|
999 |
correct output |
---|
1 2 4 6 8 10 12 14 16 18 20 22... |
user output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
Test 17
Verdict: ACCEPTED
input |
---|
1000 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |