Submission #104275

#TimeUsernameProblemLanguageResultExecution timeMemory
104275arman_ferdousScales (IOI15_scales)C++17
45.45 / 100
4 ms512 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;

void init(int T) {
    
}

void orderCoins() {
	int W[6] = {1,2,3,4,5,6};

	int a = 1, b = 2, c = 3;
	int lo = getLightest(a,b,c);
	int mid = getMedian(a,b,c), hi;
	if(a != lo && a != mid) hi = a;
	else if(b != lo && b != mid) hi = b;
	else hi = c;
	W[0] = lo, W[1] = mid, W[2] = hi;

	a = 4, b = 5, c = 6;
	lo = getLightest(a,b,c);
	mid = getMedian(a,b,c);
	if(a != lo && a != mid) hi = a;
	else if(b != lo && b != mid) hi = b;
	else hi = c;

	W[3] = lo, W[4] = mid, W[5] = hi;

	vector<int> L(3), R(3), soln;
	for(int i = 0; i < 3; i++) L[i] = W[i];
	for(int i = 0; i < 3; i++) R[i] = W[i+3];

	for(;;) {
		if(L.empty()) {
			while(!R.empty()) {
				soln.push_back(R.back());
				R.pop_back();
			} break;
		}
		if(R.empty()) {
			while(!L.empty()) {
				soln.push_back(L.back());
				L.pop_back();
			} break;
		}

		if(L.size() < 2 && R.size() < 2) {
			int got = getLightest(L[0], R[0], soln.back());
			if(got == L[0]) {
				soln.push_back(R[0]);
				soln.push_back(L[0]);
			} else {
				soln.push_back(L[0]);
				soln.push_back(R[0]);
			} R.pop_back(); L.pop_back();
			break;
		}

		if(L.size() > 1) {
			int got = getHeaviest(L[L.size()-2], L.back(), R.back());
			if(got == L.back()) {
				soln.push_back(L.back());
				L.pop_back();
			} else {
				soln.push_back(R.back());
				R.pop_back();
			}
		}
		else {
			int got = getHeaviest(L.back(), R.back(), R[R.size()-2]);
			if(got == L.back()) {
				soln.push_back(L.back());
				L.pop_back();
			} else {
				soln.push_back(R.back());
				R.pop_back();
			}
		}
	}
	for(int i = 0; i < 6; i++) W[i] = soln[5-i];
	answer(W);
}

Compilation message (stderr)

In file included from grader.c:2:0:
graderlib.c: In function 'void answer(int*)':
graderlib.c:53:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (_ghksjhdfkae19ga_ > 1) 
     ^~
graderlib.c:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  for (i = 0; i < 6; i++) {
  ^~~
scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
#Verdict Execution timeMemoryGrader output
Fetching results...