Submission #133238

# Submission time Handle Problem Language Result Execution time Memory
133238 2019-07-20T09:49:20 Z Mahdi_Jfri Scales (IOI15_scales) C++14
45.4545 / 100
2 ms 380 KB
#include "scales.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back

#define gh getHeaviest
#define gl getLightest
#define gm getMedian
#define gnl getNextLightest

const int maxn = 1e5 + 20;

void init(int T)
{

}

void orderCoins()
{
	int res[] = {85 , 1, 2, 3, 4, 5, 6};
	{
		int x = gl(res[1] , res[2] , res[3]) , y;
		swap(res[1] , res[x]);

		x = gl(res[4] , res[5] , res[6]);
		swap(res[4] , res[x]);
	}

	int w[6];
	if(gl(res[1] , res[2] , res[4]) == res[4])
	{
		swap(res[1] , res[4]);
		swap(res[2] , res[5]);
		swap(res[3] , res[6]);
	}

	{
		int x = gm(res[4] , res[5] , res[6]);
		if(x != res[5])
			swap(res[5] , res[6]);
	}

	int tx = gnl(res[1] , res[4] , res[5] , res[2]);

	if(tx == res[1])
	{
		int a = res[2] , b = res[3];
		res[2] = gm(res[1] , res[2] , res[3]);
		res[3] = a + b - res[2];
		if(res[2] != a)
			tx = gnl(res[1] , res[4] , res[5] , res[2]);
	}

	if(tx == res[1])
	{
		w[0] = res[1] , w[1] = res[4] , w[2] = res[5];
		w[3] = gl(res[2] , res[3] , res[6]);
		w[4] = gm(res[2] , res[3] , res[6]);
		w[5] = res[2] + res[3] + res[6] - w[3] - w[4];
	}
	else if(tx == res[4])
	{
		tx = gnl(res[1] , res[4] , res[5] , res[3]);
		if(tx == res[1])
		{
			w[0] = res[1] , w[1] = res[2] , w[2] = res[4] , w[3] = res[5];
			w[4] = gm(res[1] , res[3] , res[6]);
			w[5] = res[3] + res[6] - w[4];
		}
		else if(tx == res[4])
		{
			tx = gm(res[1] , res[2] , res[3]);
			if(tx == res[3])
				swap(res[2] , res[3]);

			w[0] = res[1] , w[1] = res[2] , w[2] = res[3] , w[3] = res[4] , w[4] = res[5] , w[5] = res[6];
		}
		else
		{
			w[0] = res[1] , w[1] = res[2] , w[2] = res[4] , w[3] = res[3] , w[4] = res[5] , w[5] = res[6];
		}
	}
	else
	{
		tx = gm(res[1] , res[2] , res[3]);
		if(tx == res[2])
		{
			tx = gnl(res[2] , res[5] , res[6] , res[3]);
			if(tx == res[2])
				w[0] = res[1] , w[1] = res[4] , w[2] = res[2] , w[3] = res[5] , w[4] = res[6] , w[5] = res[3];
			else if(tx == res[5])
				w[0] = res[1] , w[1] = res[4] , w[2] = res[2] , w[3] = res[3] , w[4] = res[5] , w[5] = res[6];
			else
				w[0] = res[1] , w[1] = res[4] , w[2] = res[2] , w[3] = res[5] , w[4] = res[3] , w[5] = res[6];
		}
		else
		{
			tx = gl(res[4] , res[2] , res[3]);
			swap(res[2] , res[3]);
			if(tx == res[4])
				w[0] = res[1] , w[1] = res[4] , w[2] = res[2] , w[3] = res[3] , w[4] = res[5] , w[5] = res[6];
			else
				w[0] = res[1] , w[1] = res[2] , w[2] = res[4] , w[3] = res[3] , w[4] = res[5] , w[5] = res[6];
		}
	}










	answer(w);
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:16:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T)
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:25:42: warning: unused variable 'y' [-Wunused-variable]
   int x = gl(res[1] , res[2] , res[3]) , y;
                                          ^
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 376 KB Output is partially correct
2 Partially correct 2 ms 376 KB Output is partially correct
3 Partially correct 2 ms 376 KB Output is partially correct
4 Partially correct 2 ms 380 KB Output is partially correct
5 Partially correct 2 ms 376 KB Output is partially correct
6 Partially correct 2 ms 376 KB Output is partially correct
7 Partially correct 2 ms 256 KB Output is partially correct
8 Partially correct 2 ms 376 KB Output is partially correct
9 Partially correct 2 ms 380 KB Output is partially correct
10 Partially correct 2 ms 376 KB Output is partially correct
11 Partially correct 2 ms 256 KB Output is partially correct
12 Partially correct 2 ms 256 KB Output is partially correct
13 Partially correct 2 ms 256 KB Output is partially correct
14 Partially correct 2 ms 380 KB Output is partially correct
15 Partially correct 2 ms 376 KB Output is partially correct
16 Partially correct 2 ms 256 KB Output is partially correct
17 Partially correct 2 ms 376 KB Output is partially correct
18 Partially correct 2 ms 376 KB Output is partially correct
19 Partially correct 2 ms 376 KB Output is partially correct
20 Partially correct 2 ms 376 KB Output is partially correct
21 Partially correct 2 ms 380 KB Output is partially correct
22 Partially correct 2 ms 256 KB Output is partially correct
23 Partially correct 2 ms 376 KB Output is partially correct
24 Partially correct 2 ms 256 KB Output is partially correct
25 Partially correct 2 ms 256 KB Output is partially correct
26 Partially correct 2 ms 256 KB Output is partially correct
27 Partially correct 2 ms 256 KB Output is partially correct
28 Partially correct 2 ms 256 KB Output is partially correct
29 Partially correct 2 ms 256 KB Output is partially correct
30 Partially correct 2 ms 256 KB Output is partially correct
31 Partially correct 2 ms 376 KB Output is partially correct
32 Partially correct 2 ms 256 KB Output is partially correct
33 Partially correct 2 ms 256 KB Output is partially correct
34 Partially correct 2 ms 376 KB Output is partially correct
35 Partially correct 2 ms 256 KB Output is partially correct
36 Partially correct 2 ms 256 KB Output is partially correct
37 Partially correct 2 ms 256 KB Output is partially correct
38 Partially correct 2 ms 376 KB Output is partially correct
39 Partially correct 2 ms 256 KB Output is partially correct
40 Partially correct 2 ms 376 KB Output is partially correct