#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]+b-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)
{
assert(k<=11);
int n=a.size();
vector<int> v,r(n);
for (int i=0;i<n;i++)
{
if (a[i]==1)
v.push_back(i);
}
sort(v.begin(),v.end(),cmp);
if (n<3)
{
for (int i=0;i<n;i++)
r[v[i]]=i+1;
return r;
}
for (int i=0;i<3;i++)
d[i].push_back(v[i]);
for (int i=2;i<=10;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,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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
1020 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |