Submission #520288

#TimeUsernameProblemLanguageResultExecution timeMemory
520288silverfishScales (IOI15_scales)C++17
38.46 / 100
1 ms300 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
 
void init(int T) {
	return;
}
 
void orderCoins() {
	int w[] = {1, 2, 3, 4, 5, 6};
	vector<int> lst = {0, 3};

	for(int i : lst){
	  int v = getLightest(w[i], w[i+1], w[i+2]);
	  for(int j = i; j <= i+2; ++j) if(v == w[j]) swap(w[i], w[j]);
	  v = getMedian(w[i], w[i+1], w[i+2]);
	  for(int j = i; j <= i+2; ++j) if(v == w[j]) swap(w[i+1], w[j]);
	}


	vector<int> before, after[6];
	map<int,int> mp;
	//1: before3
	//2: after3
	//3: after4
	//4: after5

	for(int i = 0; i < 3; ++i){
		if(getLightest(w[i], w[3], w[4]) == w[i]){
			before.pb(w[i]);
			mp[w[i]] = 1;
		}
	}

	for(int i = 0; i < 3; ++i){
		int c = getNextLightest(w[3], w[4], w[5], w[i]);
		if(c == w[3]){
			if(mp[w[i]] != 1){
				after[5].pb(w[i]);
				mp[w[i]] = 4;
			}
		}else if(c == w[4]){
			after[3].pb(w[i]);
			mp[w[i]] = 2;
		}else{
			after[4].pb(w[i]);
			mp[w[i]] = 3;
		}
	}

	vector<int> ans;
	for(int i : before) ans.pb(i);
	ans.pb(w[3]);
	for(int i : after[3]) ans.pb(i);
	ans.pb(w[4]);
	for(int i : after[4]) ans.pb(i);
	ans.pb(w[5]);
	for(int i : after[5]) ans.pb(i);
	for(int i = 0; i < 6; ++i){
		w[i] = ans[i];
	}



	answer(w);
	return;
}

Compilation message (stderr)

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