Submission #149655

# Submission time Handle Problem Language Result Execution time Memory
149655 2019-09-01T06:54:53 Z Torat(#3726, Osama_Alkhodairy, mohammedehab2002, mahmoudbadawy) Wine Tasting (FXCUP4_wine) C++17
0 / 100
5 ms 512 KB
#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;
	if (n==4)
	return vector<int>({1,1,1,2});
	vector<int> ans;
	for (int i=0;i<n;i++)
	ans.push_back((r[i]-1)%b+1);
	assert(count(ans.begin(),ans.end(),1)==3);
	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);
	}
	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;
}
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -