Submission #345989

# Submission time Handle Problem Language Result Execution time Memory
345989 2021-01-08T20:37:57 Z emaborevkovic Scales (IOI15_scales) C++14
0 / 100
1 ms 512 KB
#include <bits/stdc++.h> 
#include "scales.h"

using namespace std;

#define ll long long
#define ss second
#define ff first
#define mp make_pair
#define pb push_back

int res[6];

void orderCoins() {
	int a1, a2, a3, a4, a5, a6;  // a1 < a2 < a3 && a4 < a5 < a6
	a1 = getLightest(1, 2, 3);
	a2 = getMedian(1, 2, 3);
	if (a1 != 1 && a2 != 1) a3 = 1;
	if (a1 != 2 && a2 != 2) a3 = 2;
	if (a1 != 3 && a2 != 3) a3 = 3;
	a4 = getLightest(4, 5, 6);
	a5 = getMedian(4, 5, 6);
	if (a4 != 4 && a5 != 4) a3 = 4;
	if (a4 != 5 && a5 != 5) a3 = 5; 
	if (a4 != 6 && a5 != 6) a3 = 6;  // do sad smo iskoristili 4 upita
	int x = getNextLightest(a4, a5, a3, a2);
	if (x == a4) {
		int srednji = getMedian(a5, a3, a6);
		res[0] = a1; res[1] = a2; res[2] = a4;
		if (srednji == a5) {
			res[3] = a3;
			res[5] = a6;
		} 
		else if (srednji == a3) {
			res[3] = a5;
			res[5] = a6;
		}
		else {
			res[3] = a5;
			res[5] = a3;
		}
		res[4] = srednji;
	}
	else if (x == a3) {
		int manji = getLightest(a1, a4, a2);
		if (manji == a1) {
			res[0] = a1;
			res[1] = a4;
		}
		else {
			res[0] = a4;
			res[1] = a1;
		}
		res[2] = a2;
		res[3] = a5;
		int veci = getHeaviest(a3, a6, a1);
		if (veci == a3) {
			res[5] = a3;
			res[4] = a6;
		}
		else {
			res[4] = a3;
			res[5] = a6;
		}
	}
	else {
		int next1 = getNextLightest(a4, a5, a2, a1);
		if (next1 == a4) {
			res[0] = a1;
			res[1] = a4;
			res[2] = a5;
			int next2 = getNextLightest(a2, a3, a1, a6);
			if (next2 == a2) {
				res[3] = a6;
				res[4] = a2;
				res[5] = a3;
			}
			else if (next2 == a3) {
				res[3] = a2;
				res[4] = a6;
				res[5] = a3;
			}
			else {
				res[3] = a2;
				res[4] = a3;
				res[5] = a6;
			}
		}
		else if (next1 == a5) {
			res[0] = a4;
			res[1] = a1;
			res[2] = a5;
			int next2 = getNextLightest(a2, a3, a1, a6);
			if (next2 == a2) {
				res[3] = a6;
				res[4] = a2;
				res[5] = a3;
			}
			else if (next2 == a3) {
				res[3] = a2;
				res[4] = a6;
				res[5] = a3;
			}
			else {
				res[3] = a2;
				res[4] = a3;
				res[5] = a6;
			}
		}
		else {
			res[0] = a4;
			res[1] = a5;
			int next2 = getNextLightest(a1, a2, a3, a6);
			if (next2 == a2) {
				res[2] = a1;
				res[3] = a6;
				res[4] = a2;
				res[5] = a3;
			}
			else if (next2 == a3) {
				res[2] = a1;
				res[3] = a2;
				res[4] = a6;
				res[5] = a3;
			}
			else {
				int najmanji = getLightest(a1, a6, a2);
				if (najmanji == a6) {
					res[2] = a6;
					res[3] = a1;
					res[4] = a2;
					res[5] = a3;
				}
				else {
					res[2] = a1;
					res[3] = a2;
					res[4] = a3;
					res[5] = a6;
				}
			}
		}
	}
	answer(res);
	return;
}

void init(int t) {
	while(t--) orderCoins();
}
/*
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector <int> v = {1, 2, 5};
	cout << delivery(3, 2, 8, v);
	return 0;
}
*/

Compilation message

scales.cpp: In function 'void orderCoins()':
scales.cpp:28:26: warning: 'a6' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |   int srednji = getMedian(a5, a3, a6);
      |                 ~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
3 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
4 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
5 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
6 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
7 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
8 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
9 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
10 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
11 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
12 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
13 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
14 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
15 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
16 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
17 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
18 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
19 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
20 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
21 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
22 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
23 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
24 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
25 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
26 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
27 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
28 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
29 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
30 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
31 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
32 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
33 Runtime error 1 ms 512 KB Execution killed with signal 6 (could be triggered by violating memory limits)
34 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
35 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
36 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
37 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
38 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
39 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
40 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)