#include <bits/stdc++.h>
using namespace std;
#include "bartender.h"
std::vector<int> BlendWines(int K, std::vector<int> R){
assert(K >= 11);
int N = R.size();
vector<int> v;
for(int i = 1; i <= 5; i++)
{
v.push_back(11 - i);
for(int j = 0; j < 4; j++)
v.push_back(i);
v.push_back(11 - i);
}
vector<int> a(N);
for(int i = 0; i < N; i++)
a[i] = v[R[i] - 1];
return a;
}
#include <bits/stdc++.h>
using namespace std;
#include "taster.h"
void jus(int x, int y, vector<int> &v)
{
if(Compare(v[x], v[y]) == 1)
swap(v[x], v[y]);
}
void sort4(vector<int> &v)
{
assert((int)v.size() == 4);
jus(0, 1, v);
jus(2, 3, v);
if(Compare(v[1], v[3]) == 1)
{
swap(v[1], v[3]);
swap(v[0], v[2]);
}
jus(1, 2, v);
jus(0, 1, v);
}
void sort3(vector<int> &v)
{
assert((int)v.size() == 3);
jus(0, 1, v);
jus(1, 2, v);
jus(0, 1, v);
}
void sort2(vector<int> &v)
{
assert((int)v.size() == 2);
jus(0, 1, v);
}
std::vector<int> SortWines(int K, std::vector<int> A) {
assert(K >= 11);
int N = A.size();
vector<int> r(N);
for(int i = 1; i <= 5; i++)
{
int p = 6 * i - 5;
vector<int> x, y;
for(int j = 0; j < N; j++)
{
if(A[j] == 11 - i)
x.push_back(j);
else if(A[j] == i)
y.push_back(j);
}
if(x.empty())
{
assert(y.empty());
continue;
}
if(x.size() == 2)
{
r[x[0]] = p;
r[x[1]] = p + 5;
if(Compare(x[0], y[0]) == 1)
swap(r[x[0]], r[x[1]]);
sort4(y);
for(int j = 0; j < 4; j++)
r[y[j]] = p + 1 + j;
}
else
{
assert((int)x.size() == 1);
r[x[0]] = p;
int sz = (int)y.size();
if(sz == 4)
sort4(y);
else if(sz == 3)
sort3(y);
else if(sz == 2)
sort2(y);
for(int j = 0; j < sz; j++)
r[y[j]] = p + 1 + j;
}
}
return r;
}
Compilation message
bartender.cpp: In function 'std::vector<int> BlendWines(int, std::vector<int>)':
bartender.cpp:20:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for(int i = 0; i < N; i++)
^~~
bartender.cpp:23:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
return a;
^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
872 KB |
Correct |
2 |
Correct |
11 ms |
880 KB |
Correct |
3 |
Correct |
9 ms |
644 KB |
Correct |
4 |
Correct |
9 ms |
676 KB |
Correct |
5 |
Correct |
9 ms |
820 KB |
Correct |
6 |
Correct |
10 ms |
772 KB |
Correct |
7 |
Correct |
10 ms |
772 KB |
Correct |
8 |
Correct |
10 ms |
644 KB |
Correct |
9 |
Correct |
9 ms |
788 KB |
Correct |
10 |
Correct |
10 ms |
644 KB |
Correct |
11 |
Correct |
10 ms |
908 KB |
Correct |
12 |
Correct |
10 ms |
956 KB |
Correct |
13 |
Correct |
8 ms |
780 KB |
Correct |
14 |
Correct |
9 ms |
772 KB |
Correct |
15 |
Correct |
8 ms |
772 KB |
Correct |
16 |
Correct |
11 ms |
772 KB |
Correct |
17 |
Correct |
8 ms |
908 KB |
Correct |
18 |
Correct |
9 ms |
772 KB |
Correct |
19 |
Correct |
10 ms |
664 KB |
Correct |
20 |
Correct |
10 ms |
1012 KB |
Correct |
21 |
Correct |
9 ms |
772 KB |
Correct |
22 |
Correct |
9 ms |
888 KB |
Correct |
23 |
Correct |
9 ms |
772 KB |
Correct |
24 |
Correct |
9 ms |
772 KB |
Correct |
25 |
Correct |
8 ms |
772 KB |
Correct |
26 |
Correct |
10 ms |
772 KB |
Correct |
27 |
Correct |
10 ms |
644 KB |
Correct |
28 |
Correct |
8 ms |
772 KB |
Correct |
29 |
Correct |
8 ms |
780 KB |
Correct |
30 |
Correct |
10 ms |
780 KB |
Correct |
31 |
Correct |
9 ms |
772 KB |
Correct |
32 |
Correct |
9 ms |
772 KB |
Correct |
33 |
Correct |
9 ms |
772 KB |
Correct |
34 |
Correct |
10 ms |
864 KB |
Correct |
35 |
Correct |
8 ms |
772 KB |
Correct |
36 |
Correct |
9 ms |
780 KB |
Correct |
37 |
Correct |
10 ms |
908 KB |
Correct |
38 |
Correct |
11 ms |
1020 KB |
Correct |
39 |
Correct |
11 ms |
644 KB |
Correct |
40 |
Correct |
10 ms |
644 KB |
Correct |
41 |
Correct |
10 ms |
772 KB |
Correct |
42 |
Correct |
11 ms |
908 KB |
Correct |
43 |
Correct |
9 ms |
884 KB |
Correct |
44 |
Correct |
8 ms |
772 KB |
Correct |
45 |
Correct |
10 ms |
784 KB |
Correct |
46 |
Correct |
10 ms |
1016 KB |
Correct |
47 |
Correct |
11 ms |
1024 KB |
Correct |
48 |
Correct |
10 ms |
888 KB |
Correct |
49 |
Correct |
9 ms |
644 KB |
Correct |
50 |
Correct |
11 ms |
1024 KB |
Correct |
51 |
Correct |
10 ms |
776 KB |
Correct |
52 |
Correct |
9 ms |
780 KB |
Correct |
53 |
Correct |
9 ms |
1008 KB |
Correct |
54 |
Correct |
11 ms |
1012 KB |
Correct |
55 |
Correct |
11 ms |
884 KB |
Correct |
56 |
Correct |
10 ms |
772 KB |
Correct |
57 |
Correct |
9 ms |
772 KB |
Correct |
58 |
Correct |
10 ms |
908 KB |
Correct |
59 |
Correct |
10 ms |
644 KB |
Correct |
60 |
Correct |
10 ms |
1024 KB |
Correct |
61 |
Correct |
10 ms |
772 KB |
Correct |
62 |
Correct |
10 ms |
772 KB |
Correct |
63 |
Correct |
9 ms |
660 KB |
Correct |
64 |
Correct |
10 ms |
844 KB |
Correct |
65 |
Correct |
9 ms |
772 KB |
Correct |
66 |
Correct |
10 ms |
772 KB |
Correct |
67 |
Correct |
11 ms |
980 KB |
Correct |
68 |
Correct |
9 ms |
772 KB |
Correct |
69 |
Correct |
11 ms |
804 KB |
Correct |
70 |
Correct |
11 ms |
772 KB |
Correct |
71 |
Correct |
10 ms |
732 KB |
Correct |
72 |
Correct |
9 ms |
772 KB |
Correct |
73 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
74 |
Halted |
0 ms |
0 KB |
- |