#include <bits/stdc++.h>
using namespace std;
#include "bartender.h"
std::vector<int> BlendWines(int K, std::vector<int> R){
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);
jus(1, 3, v);
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) {
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())
continue;
if(x.size() == 2)
{
r[x[0]] = p;
r[x[1]] = p + 5;
if(Compare(x[0], x[1]) == 1)
swap(r[x[0]], r[x[1]]);
sort4(y);
for(int j = 0; j < 4; j++)
r[y[j]] = p + 1 + j;
}
else
{
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:19:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for(int i = 0; i < N; i++)
^~~
bartender.cpp:22:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
return a;
^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
772 KB |
Correct |
2 |
Correct |
9 ms |
772 KB |
Correct |
3 |
Correct |
10 ms |
780 KB |
Correct |
4 |
Correct |
10 ms |
772 KB |
Correct |
5 |
Correct |
10 ms |
772 KB |
Correct |
6 |
Incorrect |
10 ms |
908 KB |
Wrong |
7 |
Halted |
0 ms |
0 KB |
- |