#include "bartender.h"
using namespace std;
vector<int> BlendWines(int K, vector<int> R){
int N = R.size();
vector<int> A(N);
for(int i = 0; i < N; i++) A[i] = (R[i]-1) % 16 + 1;
return A;
}
#include "taster.h"
using namespace std;
vector<int> g[31];
void get_piv(int v){
if(Compare(g[1][0], g[v][0]) == -1){
if(Compare(g[1][0], g[v][1]) == -1){
if(Compare(g[1][1], g[v][0]) == -1) swap(g[v][0], g[v][1]);
}else{
swap(g[1][0], g[1][1]);
swap(g[v][0], g[v][1]);
}
}else{
swap(g[1][0], g[1][1]);
}
for(int i = 2; i < v; i++){
if(Compare(g[i][1], g[1][1]) == -1){
swap(g[i][0], g[i][1]);
}
}
}
vector<int> SortWines(int K, vector<int> A) {
int N = A.size();
for(int i = 0; i < N; i++) g[A[i]].push_back(i);
int v = 0;
for(int i = 14; i >= 1; i--){
if(g[i].size() == 2){
v = i;
break;
}
}
vector<int> R(N);
if(v > 1) get_piv(v);
else if(v == 1){
if(Compare(g[1][0], g[1][1]) == -1) swap(g[1][0], g[1][1]);
}
else{
return A;
}
for(int i = 1; i <= 16; i++){
for(int j = 0; j < g[i].size(); j++){
int k = g[i][j];
R[k] = j * 16 + i;
}
}
return R;
}
Compilation message
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:41:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0; j < g[i].size(); j++){
~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
780 KB |
Correct |
2 |
Correct |
8 ms |
780 KB |
Correct |
3 |
Correct |
9 ms |
780 KB |
Correct |
4 |
Correct |
10 ms |
908 KB |
Correct |
5 |
Correct |
10 ms |
772 KB |
Correct |
6 |
Correct |
9 ms |
772 KB |
Correct |
7 |
Correct |
8 ms |
644 KB |
Correct |
8 |
Correct |
8 ms |
644 KB |
Correct |
9 |
Correct |
8 ms |
644 KB |
Correct |
10 |
Correct |
9 ms |
772 KB |
Correct |
11 |
Correct |
10 ms |
644 KB |
Correct |
12 |
Correct |
10 ms |
644 KB |
Correct |
13 |
Correct |
8 ms |
780 KB |
Correct |
14 |
Correct |
9 ms |
932 KB |
Correct |
15 |
Correct |
10 ms |
780 KB |
Correct |
16 |
Correct |
9 ms |
644 KB |
Correct |
17 |
Correct |
9 ms |
908 KB |
Correct |
18 |
Correct |
8 ms |
644 KB |
Correct |
19 |
Correct |
9 ms |
644 KB |
Correct |
20 |
Correct |
8 ms |
644 KB |
Correct |
21 |
Correct |
9 ms |
644 KB |
Correct |
22 |
Correct |
9 ms |
908 KB |
Correct |
23 |
Correct |
8 ms |
644 KB |
Correct |
24 |
Correct |
9 ms |
676 KB |
Correct |
25 |
Correct |
8 ms |
644 KB |
Correct |
26 |
Correct |
9 ms |
748 KB |
Correct |
27 |
Correct |
10 ms |
644 KB |
Correct |
28 |
Correct |
9 ms |
644 KB |
Correct |
29 |
Correct |
9 ms |
780 KB |
Correct |
30 |
Correct |
9 ms |
644 KB |
Correct |
31 |
Correct |
10 ms |
780 KB |
Correct |
32 |
Correct |
8 ms |
772 KB |
Correct |
33 |
Correct |
9 ms |
644 KB |
Correct |
34 |
Correct |
10 ms |
644 KB |
Correct |
35 |
Correct |
9 ms |
692 KB |
Correct |
36 |
Correct |
9 ms |
644 KB |
Correct |
37 |
Correct |
9 ms |
644 KB |
Correct |
38 |
Correct |
9 ms |
644 KB |
Correct |
39 |
Correct |
10 ms |
644 KB |
Correct |
40 |
Correct |
9 ms |
644 KB |
Correct |
41 |
Correct |
8 ms |
772 KB |
Correct |
42 |
Correct |
8 ms |
804 KB |
Correct |
43 |
Correct |
9 ms |
644 KB |
Correct |
44 |
Correct |
9 ms |
772 KB |
Correct |
45 |
Correct |
9 ms |
780 KB |
Correct |
46 |
Correct |
10 ms |
780 KB |
Correct |
47 |
Correct |
9 ms |
644 KB |
Correct |
48 |
Correct |
8 ms |
644 KB |
Correct |
49 |
Correct |
10 ms |
780 KB |
Correct |
50 |
Correct |
10 ms |
772 KB |
Correct |
51 |
Correct |
9 ms |
644 KB |
Correct |
52 |
Correct |
8 ms |
820 KB |
Correct |
53 |
Correct |
8 ms |
860 KB |
Correct |
54 |
Correct |
9 ms |
864 KB |
Correct |
55 |
Correct |
9 ms |
772 KB |
Correct |
56 |
Correct |
8 ms |
692 KB |
Correct |
57 |
Correct |
8 ms |
908 KB |
Correct |
58 |
Partially correct |
9 ms |
696 KB |
Wrong |
59 |
Partially correct |
8 ms |
780 KB |
Wrong |
60 |
Partially correct |
9 ms |
644 KB |
Wrong |
61 |
Partially correct |
9 ms |
772 KB |
Wrong |
62 |
Partially correct |
8 ms |
644 KB |
Wrong |
63 |
Partially correct |
9 ms |
672 KB |
Wrong |
64 |
Partially correct |
9 ms |
772 KB |
Wrong |
65 |
Partially correct |
10 ms |
780 KB |
Wrong |
66 |
Partially correct |
8 ms |
756 KB |
Wrong |
67 |
Partially correct |
10 ms |
908 KB |
Wrong |
68 |
Partially correct |
8 ms |
896 KB |
Wrong |
69 |
Partially correct |
9 ms |
868 KB |
Wrong |
70 |
Partially correct |
10 ms |
644 KB |
Wrong |
71 |
Partially correct |
9 ms |
904 KB |
Wrong |
72 |
Partially correct |
9 ms |
820 KB |
Wrong |
73 |
Partially correct |
9 ms |
644 KB |
Wrong |
74 |
Partially correct |
9 ms |
908 KB |
Wrong |
75 |
Partially correct |
10 ms |
644 KB |
Wrong |
76 |
Correct |
8 ms |
644 KB |
Correct |
77 |
Correct |
9 ms |
772 KB |
Correct |
78 |
Correct |
9 ms |
780 KB |
Correct |
79 |
Partially correct |
9 ms |
644 KB |
Wrong |
80 |
Partially correct |
9 ms |
644 KB |
Wrong |
81 |
Partially correct |
9 ms |
780 KB |
Wrong |
82 |
Partially correct |
9 ms |
644 KB |
Wrong |
83 |
Partially correct |
9 ms |
644 KB |
Wrong |
84 |
Partially correct |
9 ms |
772 KB |
Wrong |
85 |
Partially correct |
9 ms |
864 KB |
Wrong |
86 |
Partially correct |
8 ms |
644 KB |
Wrong |
87 |
Partially correct |
9 ms |
908 KB |
Wrong |
88 |
Correct |
8 ms |
644 KB |
Correct |
89 |
Correct |
9 ms |
644 KB |
Correct |
90 |
Correct |
8 ms |
644 KB |
Correct |
91 |
Partially correct |
9 ms |
644 KB |
Wrong |
92 |
Partially correct |
9 ms |
644 KB |
Wrong |
93 |
Partially correct |
10 ms |
772 KB |
Wrong |
94 |
Partially correct |
9 ms |
900 KB |
Wrong |
95 |
Partially correct |
9 ms |
892 KB |
Wrong |
96 |
Partially correct |
9 ms |
772 KB |
Wrong |
97 |
Partially correct |
10 ms |
772 KB |
Wrong |
98 |
Partially correct |
10 ms |
908 KB |
Wrong |
99 |
Partially correct |
8 ms |
792 KB |
Wrong |
100 |
Partially correct |
9 ms |
644 KB |
Wrong |
101 |
Partially correct |
10 ms |
644 KB |
Wrong |
102 |
Partially correct |
10 ms |
772 KB |
Wrong |
103 |
Correct |
8 ms |
772 KB |
Correct |
104 |
Correct |
9 ms |
908 KB |
Correct |
105 |
Correct |
8 ms |
656 KB |
Correct |
106 |
Partially correct |
9 ms |
644 KB |
Wrong |
107 |
Partially correct |
8 ms |
644 KB |
Wrong |
108 |
Partially correct |
10 ms |
908 KB |
Wrong |
109 |
Partially correct |
10 ms |
892 KB |
Wrong |
110 |
Partially correct |
11 ms |
900 KB |
Wrong |
111 |
Partially correct |
9 ms |
892 KB |
Wrong |
112 |
Partially correct |
10 ms |
896 KB |
Wrong |
113 |
Partially correct |
9 ms |
800 KB |
Wrong |
114 |
Partially correct |
10 ms |
920 KB |
Wrong |
115 |
Partially correct |
9 ms |
900 KB |
Wrong |
116 |
Partially correct |
11 ms |
900 KB |
Wrong |
117 |
Partially correct |
8 ms |
772 KB |
Wrong |
118 |
Partially correct |
9 ms |
896 KB |
Wrong |
119 |
Partially correct |
10 ms |
896 KB |
Wrong |
120 |
Partially correct |
9 ms |
780 KB |
Wrong |