Submission #759436

#TimeUsernameProblemLanguageResultExecution timeMemory
759436pawnedScales (IOI15_scales)C++17
45.45 / 100
1 ms300 KiB
#include "scales.h"

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

int lightest(int x, int y, int z) {
	int res = getLightest(x + 1, y + 1, z + 1) - 1;
	return res;
}

int median(int x, int y, int z) {
	int res = getMedian(x + 1, y + 1, z + 1) - 1;
	return res;
}

int heaviest(int x, int y, int z) {
	int res = getHeaviest(x + 1, y + 1, z + 1) - 1;
	return res;
}

void init(int T) {
	/* ... */
}

void orderCoins() {
	bool used[6] = {false};
//------------------------
	int x1 = lightest(0, 1, 2);
	x1 = lightest(x1, 3, 4);
	if (x1 != 4)
		x1 = lightest(x1, 4, 5);
	else
		x1 = lightest(x1, 3, 5);
	used[x1] = true;
//  cout<<"x1: "<<x1<<endl;
	// now x1 is the lighest
//------------------------
	vi un;  // unused
	for (int j = 0; j < 6; j++) {
		if (!used[j])
			un.pb(j);
	}
	int x2 = lightest(un[0], un[1], un[2]);
	x2 = lightest(x2, un[3], un[4]);
	used[x2] = true;
//	  cout<<"x2: "<<x2<<endl;
	// now x2 is the second lightest
//------------------------
	un.clear();
	for (int j = 0; j < 6; j++) {
		if (!used[j])
			un.pb(j);
	}
	int x6 = heaviest(un[0], un[1], un[2]);
	// this if-else is just to get rid of duplicates
	if (x6 != un[0])
		x6 = heaviest(x6, un[0], un[3]);
	else
		x6 = heaviest(x6, un[1], un[3]);
	used[x6] = true;
//	  cout<<"x6: "<<x6<<endl;
	// now x6 is the heaviest
//------------------------
	un.clear();
	for (int j = 0; j < 6; j++) {
		if (!used[j])
			un.pb(j);
	}
	int x5 = heaviest(un[0], un[1], un[2]);
	used[x5] = true;
//	  cout<<"x5: "<<x5<<endl;
	// now x6 is the second heaviest
//------------------------
	un.clear();
	for (int j = 0; j < 6; j++) {
		if (!used[j])
			un.pb(j);
	}
	int x3 = lightest(un[0], un[1], x6);
	int x4;
	if (x3 == un[0])
		x4 = un[1];
	else
		x4 = un[0];
//	  cout<<"x3: "<<x3<<endl;
//	  cout<<"x4: "<<x4<<endl;
//------------------------
	int W[] = {x1 + 1, x2 + 1, x3 + 1, x4 + 1, x5 + 1, x6 + 1};
	answer(W);
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:28:15: warning: unused parameter 'T' [-Wunused-parameter]
   28 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...