#include "bartender.h"
using namespace std;
vector<int> BlendWines(int K, vector<int> R) {
int N = R.size(), L = max(0, N - 27);
for(int i=0;i<N;i++) R[i]--;
vector<int> V;
vector<int> X;
for(int i=0;i<N;i++) {
V.push_back(0);
if(R[i] >= 27) {
X.push_back(R[i] - 26);
V[i] = 10;
}
}
for(int i=L+1;i<=9;i++) {
X.push_back(i);
}
for(int i=0;i<N;i++) {
if(V[i] == 10) continue;
V[i] = X[R[i] % 9];
}
return V;
}
#include "taster.h"
#include<cstdio>
using namespace std;
vector<int> val[15], tens;
void sortA (vector<int> &V) {
//printf("Call sortA: %d\n", V.size());
for(int i=0;i<V.size();i++) {
for(int j=i-1;j>=0;j--) {
if(Compare(V[j], V[j+1]) == 1) swap(V[j], V[j+1]);
else break;
}
}
}
void sortB (vector<int> &V, vector<int> &T) {
//printf("Call sortB: %d\n", V.size());
vector<int> R;
for(int i=0;i<V.size();i++) R.push_back(-1);
for(int i=0;i<V.size();i++) {
int lst = 0;
for(int j=V.size();j--;) {
if(R[j] == -1) {
lst = j;
break;
}
}
for(int j=0;j<V.size();j++) {
if(j == lst || (R[j] == -1 && Compare(T[j+1], V[i]) == 1)) {
R[j] = V[i];
break;
}
}
}
swap(R, V);
}
vector<int> SortWines(int K, vector<int> A) {
int N = A.size(), L = 0;
vector<int> R;
for(int i=0;i<N;i++) {
R.push_back(0);
if(A[i] == 10) {
tens.push_back(i);
L++;
}
else {
val[A[i]].push_back(i);
}
}
vector<int> hds;
for(int i=1;i<=L;i++) {
sortA(val[i]);
hds.push_back(val[i][0]);
}
sortA(hds);
for(int i=0;i<hds.size();i++) {
int T = A[hds[i]];
R[tens[i]] = 26 + T;
for(int j=0;j<val[T].size();j++) {
R[val[T][j]] = j * 9 + i;
}
}
for(int i=L+1;i<=9;i++) {
if(i == 1) sortA(val[i]);
else sortB(val[i], val[1]);
for(int j=0;j<val[i].size();j++) {
R[val[i][j]] = j * 9 + i - 1;
}
}
for(int i=0;i<N;i++) R[i]++;
return R;
}
Compilation message
taster.cpp: In function 'void sortA(std::vector<int>&)':
taster.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();i++) {
~^~~~~~~~~
taster.cpp: In function 'void sortB(std::vector<int>&, std::vector<int>&)':
taster.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();i++) R.push_back(-1);
~^~~~~~~~~
taster.cpp:21:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();i++) {
~^~~~~~~~~
taster.cpp:29:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<V.size();j++) {
~^~~~~~~~~
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:58:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<hds.size();i++) {
~^~~~~~~~~~~
taster.cpp:61:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<val[T].size();j++) {
~^~~~~~~~~~~~~~
taster.cpp:68:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<val[i].size();j++) {
~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
868 KB |
Correct |
2 |
Correct |
9 ms |
772 KB |
Correct |
3 |
Correct |
9 ms |
908 KB |
Correct |
4 |
Correct |
10 ms |
644 KB |
Correct |
5 |
Correct |
10 ms |
908 KB |
Correct |
6 |
Correct |
10 ms |
900 KB |
Correct |
7 |
Correct |
10 ms |
644 KB |
Correct |
8 |
Correct |
10 ms |
644 KB |
Correct |
9 |
Correct |
11 ms |
1028 KB |
Correct |
10 |
Correct |
10 ms |
780 KB |
Correct |
11 |
Correct |
9 ms |
668 KB |
Correct |
12 |
Correct |
10 ms |
664 KB |
Correct |
13 |
Correct |
9 ms |
1028 KB |
Correct |
14 |
Correct |
9 ms |
900 KB |
Correct |
15 |
Correct |
9 ms |
896 KB |
Correct |
16 |
Correct |
8 ms |
660 KB |
Correct |
17 |
Correct |
10 ms |
644 KB |
Correct |
18 |
Correct |
11 ms |
892 KB |
Correct |
19 |
Correct |
9 ms |
660 KB |
Correct |
20 |
Correct |
11 ms |
792 KB |
Correct |
21 |
Correct |
11 ms |
876 KB |
Correct |
22 |
Correct |
11 ms |
660 KB |
Correct |
23 |
Correct |
9 ms |
892 KB |
Correct |
24 |
Correct |
11 ms |
904 KB |
Correct |
25 |
Correct |
9 ms |
908 KB |
Correct |
26 |
Correct |
10 ms |
1020 KB |
Correct |
27 |
Correct |
9 ms |
1020 KB |
Correct |
28 |
Correct |
10 ms |
904 KB |
Correct |
29 |
Correct |
9 ms |
788 KB |
Correct |
30 |
Correct |
10 ms |
952 KB |
Correct |
31 |
Correct |
8 ms |
644 KB |
Correct |
32 |
Correct |
9 ms |
644 KB |
Correct |
33 |
Correct |
9 ms |
644 KB |
Correct |
34 |
Correct |
9 ms |
780 KB |
Correct |
35 |
Correct |
9 ms |
1024 KB |
Correct |
36 |
Correct |
10 ms |
680 KB |
Correct |
37 |
Correct |
10 ms |
656 KB |
Correct |
38 |
Correct |
9 ms |
856 KB |
Correct |
39 |
Correct |
9 ms |
644 KB |
Correct |
40 |
Correct |
9 ms |
772 KB |
Correct |
41 |
Correct |
10 ms |
900 KB |
Correct |
42 |
Correct |
10 ms |
956 KB |
Correct |
43 |
Correct |
11 ms |
780 KB |
Correct |
44 |
Correct |
9 ms |
644 KB |
Correct |
45 |
Correct |
9 ms |
768 KB |
Correct |
46 |
Correct |
10 ms |
664 KB |
Correct |
47 |
Correct |
8 ms |
644 KB |
Correct |
48 |
Correct |
10 ms |
644 KB |
Correct |
49 |
Correct |
8 ms |
644 KB |
Correct |
50 |
Correct |
10 ms |
908 KB |
Correct |
51 |
Correct |
10 ms |
780 KB |
Correct |
52 |
Correct |
10 ms |
804 KB |
Correct |
53 |
Correct |
9 ms |
908 KB |
Correct |
54 |
Correct |
10 ms |
644 KB |
Correct |
55 |
Correct |
10 ms |
856 KB |
Correct |
56 |
Correct |
8 ms |
772 KB |
Correct |
57 |
Correct |
8 ms |
644 KB |
Correct |
58 |
Correct |
9 ms |
644 KB |
Correct |
59 |
Correct |
8 ms |
652 KB |
Correct |
60 |
Correct |
9 ms |
780 KB |
Correct |
61 |
Correct |
9 ms |
644 KB |
Correct |
62 |
Correct |
9 ms |
772 KB |
Correct |
63 |
Correct |
8 ms |
644 KB |
Correct |
64 |
Correct |
9 ms |
672 KB |
Correct |
65 |
Correct |
11 ms |
664 KB |
Correct |
66 |
Correct |
10 ms |
796 KB |
Correct |
67 |
Correct |
9 ms |
644 KB |
Correct |
68 |
Correct |
9 ms |
772 KB |
Correct |
69 |
Correct |
9 ms |
908 KB |
Correct |
70 |
Correct |
10 ms |
644 KB |
Correct |
71 |
Correct |
10 ms |
696 KB |
Correct |
72 |
Correct |
8 ms |
772 KB |
Correct |
73 |
Correct |
10 ms |
748 KB |
Correct |
74 |
Correct |
9 ms |
644 KB |
Correct |
75 |
Correct |
8 ms |
780 KB |
Correct |
76 |
Correct |
9 ms |
644 KB |
Correct |
77 |
Correct |
10 ms |
644 KB |
Correct |
78 |
Correct |
8 ms |
644 KB |
Correct |
79 |
Correct |
10 ms |
772 KB |
Correct |
80 |
Partially correct |
10 ms |
772 KB |
Wrong |
81 |
Partially correct |
10 ms |
772 KB |
Wrong |
82 |
Partially correct |
9 ms |
644 KB |
Wrong |
83 |
Partially correct |
9 ms |
644 KB |
Wrong |
84 |
Partially correct |
9 ms |
684 KB |
Wrong |
85 |
Partially correct |
9 ms |
892 KB |
Wrong |
86 |
Partially correct |
9 ms |
780 KB |
Wrong |
87 |
Partially correct |
9 ms |
644 KB |
Wrong |
88 |
Correct |
8 ms |
664 KB |
Correct |
89 |
Correct |
10 ms |
644 KB |
Correct |
90 |
Correct |
9 ms |
628 KB |
Correct |
91 |
Partially correct |
8 ms |
644 KB |
Wrong |
92 |
Partially correct |
9 ms |
780 KB |
Wrong |
93 |
Partially correct |
8 ms |
644 KB |
Wrong |
94 |
Partially correct |
10 ms |
780 KB |
Wrong |
95 |
Partially correct |
8 ms |
644 KB |
Wrong |
96 |
Partially correct |
9 ms |
716 KB |
Wrong |
97 |
Partially correct |
9 ms |
644 KB |
Wrong |
98 |
Partially correct |
10 ms |
772 KB |
Wrong |
99 |
Partially correct |
9 ms |
644 KB |
Wrong |
100 |
Partially correct |
9 ms |
780 KB |
Wrong |
101 |
Partially correct |
9 ms |
772 KB |
Wrong |
102 |
Partially correct |
9 ms |
808 KB |
Wrong |
103 |
Correct |
9 ms |
644 KB |
Correct |
104 |
Correct |
8 ms |
644 KB |
Correct |
105 |
Correct |
9 ms |
772 KB |
Correct |
106 |
Partially correct |
9 ms |
772 KB |
Wrong |
107 |
Partially correct |
10 ms |
772 KB |
Wrong |
108 |
Partially correct |
10 ms |
772 KB |
Wrong |
109 |
Partially correct |
9 ms |
908 KB |
Wrong |
110 |
Partially correct |
9 ms |
700 KB |
Wrong |
111 |
Partially correct |
10 ms |
772 KB |
Wrong |
112 |
Partially correct |
9 ms |
772 KB |
Wrong |
113 |
Partially correct |
9 ms |
644 KB |
Wrong |
114 |
Partially correct |
8 ms |
644 KB |
Wrong |
115 |
Partially correct |
9 ms |
780 KB |
Wrong |
116 |
Partially correct |
9 ms |
908 KB |
Wrong |
117 |
Partially correct |
9 ms |
772 KB |
Wrong |
118 |
Partially correct |
9 ms |
772 KB |
Wrong |
119 |
Partially correct |
9 ms |
772 KB |
Wrong |
120 |
Partially correct |
9 ms |
780 KB |
Wrong |