# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150884 | khsoo01 | Wine Tasting (FXCUP4_wine) | C++17 | 11 ms | 1032 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
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) {
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |