Task: | Just do it |
Sender: | Orangutans |
Submission time: | 2024-11-16 14:59:11 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | WRONG ANSWER | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | WRONG ANSWER | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | WRONG ANSWER | 0.00 s | details |
#10 | WRONG ANSWER | 0.00 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | WRONG ANSWER | 0.00 s | details |
#14 | WRONG ANSWER | 0.00 s | details |
#15 | WRONG ANSWER | 0.00 s | details |
#16 | WRONG ANSWER | 0.00 s | details |
#17 | WRONG ANSWER | 0.00 s | details |
Compiler report
input/code.cpp: In function 'int median(int, int, int)': input/code.cpp:19:11: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses] 19 | if (a >= b >= c) | ~~^~~~ input/code.cpp:21:11: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses] 21 | if (c >= b >= a) | ~~^~~~ input/code.cpp:23:11: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses] 23 | if (b >= a >= c) | ~~^~~~ input/code.cpp:25:11: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses] 25 | if (c >= a >= b) | ~~^~~~ input/code.cpp:27:11: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses] 27 | if (a >= c >=b) | ~~^~~~ input/code.cpp:29:11: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses] 29...
Code
// Sort an array. Initialize with low = 0 and high = len(array) #include <vector> #include <string> #include <iostream> #include <cmath> using namespace std; int count = 0; void swap(vector<int>&array, int a, int b){ int aux = array[b]; array[b] = a; array[a] = aux; } int median(int a, int b, int c){ if (a >= b >= c) return b; if (c >= b >= a) return b; if (b >= a >= c) return a; if (c >= a >= b) return a; if (a >= c >=b) return c; if (b >= c >= a) return c; } void HiitSort(vector<int>& array, int low,int high){ if (high - low > 1) { int pivot = median(array[low], array[(low + high) / 2], array[high - 1]); int a = low; int b = high - 1; while (true){ while (array[a] < pivot){ a = a + 1; count++; } while (array[b] > pivot) { b = b - 1; count++; } if (a >= b) break; swap(array, a, b); a = a + 1; b = b - 1; } HiitSort(array, low, a); HiitSort(array, a, high); } } int main(){ int n; cin >> n; vector<int> array = vector<int>(n); for (int i = 0; i < n; ++i) cin >> array[i]; HiitSort(array, 0, n); cout << count << endl; if (count >= (n *n)/4) cout << "YES"<<endl; else cout <<"NO" << endl; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
2 |
correct output |
---|
1 2 |
user output |
---|
0 NO |
Test 2
Verdict: WRONG ANSWER
input |
---|
3 |
correct output |
---|
1 2 3 |
user output |
---|
0 NO |
Test 3
Verdict: WRONG ANSWER
input |
---|
4 |
correct output |
---|
1 2 3 4 |
user output |
---|
0 NO |
Test 4
Verdict: WRONG ANSWER
input |
---|
5 |
correct output |
---|
1 2 4 3 5 |
user output |
---|
1 NO |
Test 5
Verdict: WRONG ANSWER
input |
---|
6 |
correct output |
---|
1 2 3 5 4 6 |
user output |
---|
1 NO |
Test 6
Verdict: WRONG ANSWER
input |
---|
7 |
correct output |
---|
1 2 4 6 5 3 7 |
user output |
---|
2 NO |
Test 7
Verdict: WRONG ANSWER
input |
---|
8 |
correct output |
---|
1 2 3 5 7 6 4 8 |
user output |
---|
1 NO |
Test 8
Verdict: WRONG ANSWER
input |
---|
9 |
correct output |
---|
1 2 4 6 8 3 7 5 9 |
user output |
---|
2 NO |
Test 9
Verdict: WRONG ANSWER
input |
---|
10 |
correct output |
---|
1 2 3 5 7 9 4 8 6 10 |
user output |
---|
4 NO |
Test 10
Verdict: WRONG ANSWER
input |
---|
99 |
correct output |
---|
1 2 4 6 8 10 12 14 16 18 20 22... |
user output |
---|
536 NO |
Test 11
Verdict: WRONG ANSWER
input |
---|
100 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
558 NO |
Test 12
Verdict: WRONG ANSWER
input |
---|
101 |
correct output |
---|
1 2 4 6 8 10 12 14 16 18 20 22... |
user output |
---|
565 NO |
Test 13
Verdict: WRONG ANSWER
input |
---|
300 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
5035 NO |
Test 14
Verdict: WRONG ANSWER
input |
---|
500 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
13961 NO |
Test 15
Verdict: WRONG ANSWER
input |
---|
998 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
55361 NO |
Test 16
Verdict: WRONG ANSWER
input |
---|
999 |
correct output |
---|
1 2 4 6 8 10 12 14 16 18 20 22... |
user output |
---|
55424 NO |
Test 17
Verdict: WRONG ANSWER
input |
---|
1000 |
correct output |
---|
1 2 3 5 7 9 11 13 15 17 19 21 ... |
user output |
---|
55770 NO |