| Task: | Just do it |
| Sender: | asdf4321 |
| Submission time: | 2024-11-16 13:24:56 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | 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 | TIME LIMIT EXCEEDED | -- | details |
| #11 | TIME LIMIT EXCEEDED | -- | details |
| #12 | TIME LIMIT EXCEEDED | -- | details |
| #13 | TIME LIMIT EXCEEDED | -- | details |
| #14 | TIME LIMIT EXCEEDED | -- | details |
| #15 | TIME LIMIT EXCEEDED | -- | details |
| #16 | TIME LIMIT EXCEEDED | -- | details |
| #17 | TIME LIMIT EXCEEDED | -- | 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;
int median(int a, int b, 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;
}
int cur;
void Put(vi& v, int l, int r)
{
int m = (l+r) / 2;
if(!v[m])
v[m] = cur--;
if(r - l > 1) {
Put(v, m, r);
Put(v, l, m);
}
}
signed main() {
#ifdef LOCAL
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
#endif
int n;
cin >> n;
vi test(n, 0);
test[0] = 1, test[n-1] = n;
cur = n - 1;
Put(test, 0, n);
// for(int x: test)
// cout << x << " ";
// cout << endl;
// vi array = test;
// int times = HiitSort(array, 0, n);
// cerr << times << " " << the << endl;
int the = n*n / 4, times;
bool flag = true;
while(flag)
{
vi array = test;
times = HiitSort(array, 0, n);
if(times > the)
{
cerr << times << " " << the << endl;
for(int x: test)
cout << x << " ";
return 0;
}
next_permutation(all(test));
}
return 0;
}Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 2 |
| correct output |
|---|
| 1 2 |
| user output |
|---|
| (empty) |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 3 |
| correct output |
|---|
| 1 2 3 |
| user output |
|---|
| 1 2 3 |
Error:
3 2
Test 3
Verdict: ACCEPTED
| input |
|---|
| 4 |
| correct output |
|---|
| 1 2 3 4 |
| user output |
|---|
| 1 2 3 4 |
Error:
5 4
Test 4
Verdict: ACCEPTED
| input |
|---|
| 5 |
| correct output |
|---|
| 1 2 4 3 5 |
| user output |
|---|
| 1 2 4 3 5 |
Error:
7 6
Test 5
Verdict: ACCEPTED
| input |
|---|
| 6 |
| correct output |
|---|
| 1 2 3 5 4 6 |
| user output |
|---|
| 1 3 2 6 4 5 |
Error:
10 9
Test 6
Verdict: ACCEPTED
| input |
|---|
| 7 |
| correct output |
|---|
| 1 2 4 6 5 3 7 |
| user output |
|---|
| 1 3 2 6 5 4 7 |
Error:
13 12
Test 7
Verdict: ACCEPTED
| input |
|---|
| 8 |
| correct output |
|---|
| 1 2 3 5 7 6 4 8 |
| user output |
|---|
| 1 2 4 3 7 6 5 8 |
Error:
17 16
Test 8
Verdict: ACCEPTED
| input |
|---|
| 9 |
| correct output |
|---|
| 1 2 4 6 8 3 7 5 9 |
| user output |
|---|
| 1 2 4 3 8 6 7 5 9 |
Error:
21 20
Test 9
Verdict: ACCEPTED
| input |
|---|
| 10 |
| correct output |
|---|
| 1 2 3 5 7 9 4 8 6 10 |
| user output |
|---|
| 1 2 5 4 3 9 7 8 6 10 |
Error:
26 25
Test 10
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 99 |
| correct output |
|---|
| 1 2 4 6 8 10 12 14 16 18 20 22... |
| user output |
|---|
| (empty) |
Test 11
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100 |
| correct output |
|---|
| 1 2 3 5 7 9 11 13 15 17 19 21 ... |
| user output |
|---|
| (empty) |
Test 12
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 101 |
| correct output |
|---|
| 1 2 4 6 8 10 12 14 16 18 20 22... |
| user output |
|---|
| (empty) |
Test 13
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 300 |
| correct output |
|---|
| 1 2 3 5 7 9 11 13 15 17 19 21 ... |
| user output |
|---|
| (empty) |
Test 14
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500 |
| correct output |
|---|
| 1 2 3 5 7 9 11 13 15 17 19 21 ... |
| user output |
|---|
| (empty) |
Test 15
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 998 |
| correct output |
|---|
| 1 2 3 5 7 9 11 13 15 17 19 21 ... |
| user output |
|---|
| (empty) |
Test 16
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 999 |
| correct output |
|---|
| 1 2 4 6 8 10 12 14 16 18 20 22... |
| user output |
|---|
| (empty) |
Test 17
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 |
| correct output |
|---|
| 1 2 3 5 7 9 11 13 15 17 19 21 ... |
| user output |
|---|
| (empty) |
