Submission #1017794

#TimeUsernameProblemLanguageResultExecution timeMemory
1017794parsadox2Scales (IOI15_scales)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h>
#include "scales.h"

using namespace std;

int tc;

void init(int T)
{
	tc = T;
}

void orderCoins()
{
	vector <int> vec;
	int val[6];
	for(int i = 1 ; i <= 6 ; i++)
		vec.push_back(i);
	int mn = getLightest(1 , 2 , 3);
	int mx = getHeaviest(4 , 5 , 6);
	swap(vec[0] , vec[mn - 1]);
	swap(vec[5] , vec[mx - 1]);
	mx = getHeaviest(vec[1] , vec[2] , vec[5]);
	int W[6];
	if(mx != vec[5])
	{
		if(mx == vec[1])
			swap(vec[1] , vec[2]);
		if(vec[3] != getLightest(vec[3] , vec[4] , vec[5]))
			swap(vec[3] , vec[4]);
		for(int i = 3 ; i < 6 ; i++)
			val[i] = getNextLightest(vec[0] , vec[1] , vec[2] , vec[i]);
		int pa = 0 , pb = 3;
		for(int asd = 0 ; asd < 6 ; asd++)
		{
			if(pb == 6)
			{
				W[asd] = vec[pa];
				pa++;
			}
			else if(val[pb] == vec[pa])
			{
				W[asd] = vec[pb];
				pb++;
			}
			else
			{
				W[asd] = vec[pa];
				pa++;
			}
		}
		answer(W);
	}
	else
	{
		swap(vec[2] , vec[5]);
		vector <int> ans;
		for(int i = 0 ; i <= 2 ; i++)
			ans.push_back(vec[i]);
		int vl = getNextLightest(vec[0] , vec[1] , vec[2] , vec[3]);
		vector <int> tmp;
		for(auto u : ans)
		{
			if(vl == u)
				tmp.push_back(vec[3]);
			tmp.push_back(u);
		}
		ans = tmp;
		vl = getNextLightest(vec[1] , vec[2] , vec[3] , vec[5]);
		tmp.clear();
		for(auto u : ans)
		{
			if(vl == u)
				tmp.push_back(vec[5]);
			tmp.push_back(u);
		}
		ans = tmp;
		vl = getNextLightest(ans[0] , ans[1] , ans[2] , vec[4]);
		int v2 = getNextLightest(ans[2] , ans[3] , ans[4] , vec[4]);
		if(vl != v2)
			vl = v2;
		tmp.clear();
		for(auto u : ans)
		{
			if(vl == u)
				tmp.push_back(vec[4]);
			tmp.push_back(u);
		}
		ans = tmp;
		for(int i = 0 ; i < 6 ; i++)
			W[i] = ans[i];
		answer(W);
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...