# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150992 | mohammedehab2002 | Wine Tasting (FXCUP4_wine) | C++17 | 10 ms | 1024 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"
#include <bits/stdc++.h>
using namespace std;
vector<int> BlendWines(int k,vector<int> r)
{
int n=r.size(),b=(n+2)/3;
vector<int> ans;
for (int i=0;i<n;i++)
ans.push_back((r[i]-1)%b+1);
return ans;
}
#include "taster.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> d[3];
bool cmp(int a,int b)
{
return Compare(a,b)==-1;
}
void go(int l,int r,vector<pair<int,int> > &tmp,int j)
{
if (l==r)
{
d[tmp[l].second].push_back(j);
tmp.erase(tmp.begin()+l);
}
else
{
int mid=(l+r+1)/2;
if (Compare(tmp[mid].first,j)==-1)
go(mid,r,tmp,j);
else
go(l,mid-1,tmp,j);
}
}
vector<int> SortWines(int k,vector<int> a)
{
int n=a.size();
vector<int> v,r(n);
for (int i=0;i<n;i++)
{
if (a[i]==1)
v.push_back(i);
}
if (v.size()<3)
{
sort(v.begin(),v.end(),cmp);
for (int i=0;i<n;i++)
r[v[i]]=i+1;
return r;
}
if (Compare(v[0],v[1])==1)
swap(v[0],v[1]);
if (Compare(v[0],v[2])==1)
swap(v[0],v[2]);
if (Compare(v[1],v[2])==1)
swap(v[1],v[2]);
for (int i=0;i<3;i++)
d[i].push_back(v[i]);
for (int i=2;i<=n;i++)
{
vector<pair<int,int> > tmp;
for (int j=0;j<3;j++)
tmp.push_back({v[j],j});
for (int j=0;j<n;j++)
{
if (a[j]==i)
go(0,(int)tmp.size()-1,tmp,j);
}
}
vector<int> ans;
for (int i=0;i<3;i++)
{
for (int j:d[i])
ans.push_back(j);
}
for (int i=0;i<n;i++)
r[ans[i]]=i+1;
return r;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |