답안 #149587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149587 2019-09-01T06:47:32 Z Torat(#3726, Osama_Alkhodairy, mohammedehab2002, mahmoudbadawy) 포도주 시음 (FXCUP4_wine) C++17
0 / 100
10 ms 1024 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/3;
	vector<int> ans;
	for (int i=0;i<n;i++)
	{
		if (n<3)
		ans.push_back(1);
		else if (r[i]>3*b)
		ans.push_back(r[i]-3*b+1);
		else
		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);
	}
	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 Correct 10 ms 1024 KB Correct
2 Correct 10 ms 776 KB Correct
3 Correct 9 ms 1020 KB Correct
4 Incorrect 9 ms 780 KB Wrong
5 Halted 0 ms 0 KB -