# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247139 | dwsc | Wine Tasting (FXCUP4_wine) | C++17 | 11 ms | 1208 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 <bits/stdc++.h>
#include "bartender.h"
using namespace std;
std::vector<int> BlendWines(int K, std::vector<int> R){
int n = R.size();
vector<int> v(n,0);
for (int i = 0; i < n; i++){
int bracket = (R[i]+5)/6;
if (R[i]%2 == 0) v[i] = 11-bracket;
else v[i] = bracket;
//cout << v[i] << "\n";
}
return v;
}
#include <bits/stdc++.h>
#include "taster.h"
using namespace std;
vector<int> pos[11];
vector<int> ans;
void solve(int a){
vector<int> temp;
int tot = pos[a].size()+pos[11-a].size();
if (tot == 0) return;
else if (tot == 1){
temp.push_back(pos[a][0]);
}
else if (tot == 2){
temp.push_back(pos[a][0]);
temp.push_back(pos[11-a][0]);
}
else if (tot == 3){
temp.push_back(pos[a][0]);
temp.push_back(pos[11-a][0]);
temp.push_back(pos[a][1]);
if (Compare(temp[0],temp[2]) != -1) swap(temp[0],temp[2]);
}
else if (tot == 4){
temp.push_back(pos[a][0]);
temp.push_back(pos[11-a][0]);
temp.push_back(pos[a][1]);
temp.push_back(pos[11-a][1]);
if (Compare(temp[0],temp[2]) != -1) swap(temp[0],temp[2]);
if (Compare(temp[1],temp[2]) != -1) swap(temp[1],temp[3]);
}
else if (tot == 5){
temp.push_back(pos[a][0]);
temp.push_back(pos[11-a][0]);
temp.push_back(pos[a][1]);
temp.push_back(pos[11-a][1]);
temp.push_back(pos[a][2]);
if (Compare(temp[2],temp[4]) != -1) swap(temp[2],temp[4]);
if (Compare(temp[0],temp[2]) != -1) swap(temp[0],temp[2]);
if (Compare(temp[2],temp[4]) != -1) swap(temp[2],temp[4]);
if (Compare(temp[1],temp[2]) != -1) swap(temp[1],temp[3]);
}
else if (tot == 6){
temp.push_back(pos[a][0]);
temp.push_back(pos[11-a][0]);
temp.push_back(pos[a][1]);
temp.push_back(pos[11-a][1]);
temp.push_back(pos[a][2]);
temp.push_back(pos[11-a][2]);
if (Compare(temp[2],temp[4]) != -1) swap(temp[2],temp[4]);
if (Compare(temp[0],temp[2]) != -1) swap(temp[0],temp[2]);
if (Compare(temp[2],temp[4]) != -1) swap(temp[2],temp[4]);
int val1 = Compare(temp[1],temp[4]),val2 = Compare(temp[3],temp[4]);
if (val1 != -1) swap(temp[1],temp[5]);
else if (val2 != -1) swap(temp[3],temp[5]);
if (Compare(temp[1],temp[2]) != -1) swap(temp[1],temp[3]);
}
for (int i = 0; i < temp.size(); i++){
ans[temp[i]] = (a-1)*6+i+1;
}
return;
}
std::vector<int> SortWines(int K, std::vector<int> A) {
int n = A.size();
for (int i = 0; i < n; i++) ans.push_back(i);
for (int i = 0; i < n; i++){
//cout << A[i] << "\n";
pos[A[i]].push_back(i);
}
for (int i = 1; i <= 5; i++) solve(i);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |