Submission #131369

# Submission time Handle Problem Language Result Execution time Memory
131369 2019-07-17T05:36:43 Z antimirage Scales (IOI15_scales) C++14
57.1181 / 100
3 ms 392 KB
#include "scales.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
 
using namespace std;
 
void init(int T) {
}
 
void orderCoins() {
	int ans[6], cnt = 0;
	
	int res1[3] = {1, 2, 3}, res2[3] = {4, 5, 6};
	
	res1[0] = getLightest(1, 2, 3); cnt++;
	res2[0] = getLightest(4, 5, 6); cnt++;
	
	res1[2] = getHeaviest(1, 2, 3); cnt++;
	res2[2] = getHeaviest(4, 5, 6); cnt++;
	
	for (int i = 1; i <= 3; i++) {
		if (res1[0] != i && res1[2] != i) {
			res1[1] = i;
		}
		if (res2[0] != i + 3 && res2[2] != i + 3) {
			res2[1] = i + 3;
		}
	}
	int i = 0, j = 0;
	
	for (int k = 0; k < 6; k++) {
		if (i == 3) {
			ans[k] = res2[j++];
			continue;
		}
		if (j == 3) {
			ans[k] = res1[i++];
			continue;
		}
		if (i == 2 && j == 2) {
			ans[k + 1] = getHeaviest(res1[i], res2[j], ans[0]); cnt++;
			if (ans[k + 1] == res1[i])
				ans[k] = res2[j];
			else
				ans[k] = res1[i];
			answer(ans);
	assert(cnt <= 9);
			return;
		}
		int m;
		if (i == 2) {
			m = getMedian(res1[i], res2[j], res2[j + 1]); cnt++;
			if (res1[i] == m) {
				ans[k] = res2[j];
				k++;
				j++;
				ans[k] = res1[i];
				i++;
			} else if (res2[j] == m) {
				ans[k] = res1[i];
				i++;
			} else {
				ans[k] = res2[j];
				k++;
				j++;
				ans[k] = res2[j];
				j++;
			}
		}
		else {
			m = getMedian(res1[i], res1[i + 1], res2[j]); cnt++;
			if (res2[j] == m) {
				ans[k] = res1[i];
				k++;
				i++;
				ans[k] = res2[j];
				j++;
			} else if (res1[i] == m) {
				ans[k] = res2[j];
				j++;
			} else {
				ans[k] = res1[i];
				k++;
				i++;
				ans[k] = res1[i];
				i++;
			}
		}
	}
	answer(ans);
	assert(cnt <= 9);
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:7:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 376 KB Output is partially correct
2 Partially correct 2 ms 356 KB Output is partially correct
3 Partially correct 2 ms 256 KB Output is partially correct
4 Partially correct 2 ms 256 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 376 KB Output is partially correct
8 Partially correct 2 ms 252 KB Output is partially correct
9 Partially correct 2 ms 376 KB Output is partially correct
10 Partially correct 2 ms 252 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 380 KB Output is partially correct
14 Partially correct 2 ms 376 KB Output is partially correct
15 Partially correct 2 ms 376 KB Output is partially correct
16 Partially correct 2 ms 252 KB Output is partially correct
17 Partially correct 2 ms 376 KB Output is partially correct
18 Partially correct 2 ms 256 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 376 KB Output is partially correct
22 Partially correct 2 ms 376 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 376 KB Output is partially correct
27 Partially correct 2 ms 376 KB Output is partially correct
28 Partially correct 2 ms 376 KB Output is partially correct
29 Partially correct 2 ms 392 KB Output is partially correct
30 Partially correct 2 ms 376 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 376 KB Output is partially correct
36 Partially correct 2 ms 252 KB Output is partially correct
37 Partially correct 2 ms 376 KB Output is partially correct
38 Partially correct 2 ms 256 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