#include "bartender.h"
std::vector<int> BlendWines(int K, std::vector<int> R){
int N = R.size();
std::vector<int> r(N);
for (int ni = 0; ni < N; ni++) {
if (R[ni] == 30) r[ni] = 10;
else if (R[ni] == 29) r[ni] = 1;
else r[ni] = R[ni] % 9 + 1;
}
return r;
}
#include "taster.h"
#include <bits/stdc++.h>
int Compare2(int N, int a, int b) {
if (a < N && b < N) return Compare(a, b);
if (b < N) return 1;
if (a > b) return 1;
return -1;
}
std::vector<int> SortWines(int K, std::vector<int> A) {
std::srand(unsigned(std::time(0)));
int N = A.size();
std::vector<int> r(30);
std::vector<int> cc[12];
for (int ni = 0; ni < 30; ni++) {
int aa;
if (ni < N) aa = A[ni];
else if (ni == 29) aa = 10;
else if (ni == 28) aa = 1;
else if (ni % 9 == 8) aa = 1;
else aa = ni % 9 + 2;
cc[aa].push_back(ni);
}
for (int i = 1; i < 9; i++) {
std::random_shuffle(cc[i].begin(), cc[i].end());
}
r[cc[10][0]] = 30;
int pos1, pos2, pos3, pos4;
int pivot1, pivot2;
int win1, lose1, win2, lose2;
if (Compare2(N, cc[1][0], cc[1][1]) == -1) {
win1 = cc[1][0];
lose1 = cc[1][1];
} else {
win1 = cc[1][1];
lose1 = cc[1][0];
}
if (Compare2(N, cc[1][2], cc[1][3]) == -1) {
win2 = cc[1][2];
lose2 = cc[1][3];
} else {
win2 = cc[1][3];
lose2 = cc[1][2];
}
if (Compare2(N, win1, win2) == -1) {
pos1 = win1;
if (Compare2(N, lose1, win2) == -1) {
pos2 = lose1;
pos3 = win2;
pos4 = lose2;
} else {
pos2 = win2;
if (Compare2(N, lose1, lose2) == -1) {
pos3 = lose1;
pos4 = lose2;
} else {
pos3 = lose2;
pos4 = lose1;
}
}
} else {
pos1 = win2;
if (Compare2(N, lose2, win1) == -1) {
pos2 = lose2;
pos3 = win1;
pos4 = lose1;
} else {
pos2 = win1;
if (Compare2(N, lose2, lose1) == -1) {
pos3 = lose2;
pos4 = lose1;
} else {
pos3 = lose1;
pos4 = lose2;
}
}
}
r[pos1] = 9;
r[pos2] = 18;
r[pos3] = 27;
r[pos4] = 29;
pivot1 = pos1;
pivot2 = pos2;
if (Compare2(N, cc[2][0], cc[2][1]) == -1) {
win1 = cc[2][0];
lose1 = cc[2][1];
} else {
win1 = cc[2][1];
lose1 = cc[2][0];
}
if (Compare2(N, cc[2][2], cc[2][3]) == -1) {
win2 = cc[2][2];
lose2 = cc[2][3];
} else {
win2 = cc[2][3];
lose2 = cc[2][2];
}
if (Compare2(N, win1, win2) == -1) {
pos1 = win1;
if (Compare2(N, lose1, win2) == -1) {
pos2 = lose1;
pos3 = win2;
pos4 = lose2;
} else {
pos2 = win2;
if (Compare2(N, lose1, lose2) == -1) {
pos3 = lose1;
pos4 = lose2;
} else {
pos3 = lose2;
pos4 = lose1;
}
}
} else {
pos1 = win2;
if (Compare2(N, lose2, win1) == -1) {
pos2 = lose2;
pos3 = win1;
pos4 = lose1;
} else {
pos2 = win1;
if (Compare2(N, lose2, lose1) == -1) {
pos3 = lose2;
pos4 = lose1;
} else {
pos3 = lose1;
pos4 = lose2;
}
}
}
r[pos1] = 1;
r[pos2] = 10;
r[pos3] = 19;
r[pos4] = 28;
for (int i = 3; i <= 9; i++) {
if (Compare2(N, cc[i][0], pivot1) == -1) {
r[cc[i][0]] = i - 1;
if (Compare2(N, cc[i][1], pivot2) == -1) {
r[cc[i][1]] = i + 8;
r[cc[i][2]] = i + 17;
} else {
r[cc[i][1]] = i + 17;
r[cc[i][2]] = i + 8;
}
} else {
if (Compare2(N, cc[i][1], pivot1) == -1) {
r[cc[i][1]] = i - 1;
if (Compare2(N, cc[i][2], pivot2) == -1) {
r[cc[i][0]] = i + 17;
r[cc[i][2]] = i + 8;
} else {
r[cc[i][0]] = i + 8;
r[cc[i][2]] = i + 17;
}
} else {
r[cc[i][2]] = i - 1;
if (Compare2(N, cc[i][0], pivot2) == -1) {
r[cc[i][0]] = i + 8;
r[cc[i][1]] = i + 17;
} else {
r[cc[i][0]] = i + 17;
r[cc[i][1]] = i + 8;
}
}
}
}
std::vector<int> rr(N);
for (int ni = 0; ni < N; ni++) {
rr[ni] = r[ni];
}
return rr;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
892 KB |
Correct |
2 |
Correct |
8 ms |
772 KB |
Correct |
3 |
Correct |
9 ms |
772 KB |
Correct |
4 |
Correct |
8 ms |
772 KB |
Correct |
5 |
Correct |
8 ms |
908 KB |
Correct |
6 |
Correct |
8 ms |
908 KB |
Correct |
7 |
Correct |
8 ms |
772 KB |
Correct |
8 |
Correct |
8 ms |
772 KB |
Correct |
9 |
Correct |
8 ms |
644 KB |
Correct |
10 |
Correct |
10 ms |
908 KB |
Correct |
11 |
Correct |
9 ms |
772 KB |
Correct |
12 |
Correct |
9 ms |
772 KB |
Correct |
13 |
Correct |
8 ms |
772 KB |
Correct |
14 |
Correct |
9 ms |
772 KB |
Correct |
15 |
Correct |
8 ms |
772 KB |
Correct |
16 |
Correct |
8 ms |
796 KB |
Correct |
17 |
Correct |
9 ms |
772 KB |
Correct |
18 |
Partially correct |
9 ms |
772 KB |
Wrong |
19 |
Correct |
9 ms |
772 KB |
Correct |
20 |
Correct |
9 ms |
908 KB |
Correct |
21 |
Correct |
9 ms |
772 KB |
Correct |
22 |
Correct |
8 ms |
908 KB |
Correct |
23 |
Correct |
8 ms |
772 KB |
Correct |
24 |
Correct |
10 ms |
940 KB |
Correct |
25 |
Correct |
9 ms |
800 KB |
Correct |
26 |
Correct |
8 ms |
772 KB |
Correct |
27 |
Correct |
8 ms |
908 KB |
Correct |
28 |
Correct |
8 ms |
644 KB |
Correct |
29 |
Correct |
8 ms |
772 KB |
Correct |
30 |
Correct |
8 ms |
804 KB |
Correct |
31 |
Correct |
9 ms |
772 KB |
Correct |
32 |
Correct |
9 ms |
772 KB |
Correct |
33 |
Correct |
8 ms |
908 KB |
Correct |
34 |
Correct |
10 ms |
772 KB |
Correct |
35 |
Correct |
9 ms |
908 KB |
Correct |
36 |
Correct |
9 ms |
908 KB |
Correct |
37 |
Correct |
8 ms |
644 KB |
Correct |
38 |
Correct |
9 ms |
772 KB |
Correct |
39 |
Correct |
9 ms |
792 KB |
Correct |
40 |
Correct |
9 ms |
772 KB |
Correct |
41 |
Partially correct |
9 ms |
908 KB |
Wrong |
42 |
Correct |
9 ms |
644 KB |
Correct |
43 |
Correct |
9 ms |
772 KB |
Correct |
44 |
Correct |
9 ms |
644 KB |
Correct |
45 |
Correct |
8 ms |
956 KB |
Correct |
46 |
Correct |
10 ms |
772 KB |
Correct |
47 |
Correct |
9 ms |
780 KB |
Correct |
48 |
Correct |
10 ms |
908 KB |
Correct |
49 |
Correct |
10 ms |
772 KB |
Correct |
50 |
Correct |
9 ms |
772 KB |
Correct |
51 |
Correct |
8 ms |
772 KB |
Correct |
52 |
Correct |
9 ms |
908 KB |
Correct |
53 |
Correct |
8 ms |
644 KB |
Correct |
54 |
Correct |
10 ms |
772 KB |
Correct |
55 |
Correct |
9 ms |
780 KB |
Correct |
56 |
Correct |
8 ms |
644 KB |
Correct |
57 |
Correct |
9 ms |
644 KB |
Correct |
58 |
Correct |
10 ms |
772 KB |
Correct |
59 |
Correct |
9 ms |
772 KB |
Correct |
60 |
Correct |
8 ms |
908 KB |
Correct |
61 |
Correct |
8 ms |
908 KB |
Correct |
62 |
Correct |
9 ms |
780 KB |
Correct |
63 |
Correct |
9 ms |
908 KB |
Correct |
64 |
Correct |
9 ms |
784 KB |
Correct |
65 |
Correct |
10 ms |
908 KB |
Correct |
66 |
Correct |
9 ms |
908 KB |
Correct |
67 |
Correct |
10 ms |
1032 KB |
Correct |
68 |
Correct |
9 ms |
772 KB |
Correct |
69 |
Correct |
9 ms |
908 KB |
Correct |
70 |
Correct |
8 ms |
772 KB |
Correct |
71 |
Correct |
10 ms |
928 KB |
Correct |
72 |
Correct |
9 ms |
772 KB |
Correct |
73 |
Correct |
10 ms |
920 KB |
Correct |
74 |
Correct |
9 ms |
908 KB |
Correct |
75 |
Correct |
8 ms |
804 KB |
Correct |
76 |
Correct |
10 ms |
896 KB |
Correct |
77 |
Correct |
9 ms |
1024 KB |
Correct |
78 |
Correct |
9 ms |
908 KB |
Correct |
79 |
Partially correct |
10 ms |
772 KB |
Wrong |
80 |
Partially correct |
9 ms |
908 KB |
Wrong |
81 |
Partially correct |
8 ms |
788 KB |
Wrong |
82 |
Partially correct |
8 ms |
772 KB |
Wrong |
83 |
Partially correct |
8 ms |
908 KB |
Wrong |
84 |
Partially correct |
9 ms |
960 KB |
Wrong |
85 |
Partially correct |
9 ms |
804 KB |
Wrong |
86 |
Partially correct |
10 ms |
772 KB |
Wrong |
87 |
Partially correct |
9 ms |
908 KB |
Wrong |
88 |
Correct |
9 ms |
796 KB |
Correct |
89 |
Correct |
9 ms |
908 KB |
Correct |
90 |
Correct |
8 ms |
772 KB |
Correct |
91 |
Partially correct |
9 ms |
1032 KB |
Wrong |
92 |
Partially correct |
8 ms |
792 KB |
Wrong |
93 |
Partially correct |
9 ms |
908 KB |
Wrong |
94 |
Partially correct |
9 ms |
1024 KB |
Wrong |
95 |
Partially correct |
9 ms |
772 KB |
Wrong |
96 |
Partially correct |
8 ms |
908 KB |
Wrong |
97 |
Partially correct |
8 ms |
644 KB |
Wrong |
98 |
Partially correct |
8 ms |
1024 KB |
Wrong |
99 |
Partially correct |
9 ms |
772 KB |
Wrong |
100 |
Partially correct |
9 ms |
860 KB |
Wrong |
101 |
Partially correct |
9 ms |
908 KB |
Wrong |
102 |
Partially correct |
8 ms |
804 KB |
Wrong |
103 |
Correct |
8 ms |
772 KB |
Correct |
104 |
Correct |
10 ms |
908 KB |
Correct |
105 |
Correct |
9 ms |
772 KB |
Correct |
106 |
Partially correct |
8 ms |
908 KB |
Wrong |
107 |
Partially correct |
9 ms |
916 KB |
Wrong |
108 |
Partially correct |
9 ms |
772 KB |
Wrong |
109 |
Partially correct |
10 ms |
820 KB |
Wrong |
110 |
Partially correct |
9 ms |
908 KB |
Wrong |
111 |
Partially correct |
9 ms |
780 KB |
Wrong |
112 |
Partially correct |
10 ms |
1140 KB |
Wrong |
113 |
Partially correct |
9 ms |
644 KB |
Wrong |
114 |
Partially correct |
9 ms |
772 KB |
Wrong |
115 |
Partially correct |
9 ms |
908 KB |
Wrong |
116 |
Partially correct |
9 ms |
696 KB |
Wrong |
117 |
Partially correct |
10 ms |
644 KB |
Wrong |
118 |
Partially correct |
8 ms |
772 KB |
Wrong |
119 |
Partially correct |
10 ms |
772 KB |
Wrong |
120 |
Partially correct |
9 ms |
644 KB |
Wrong |