Submission #131363

# Submission time Handle Problem Language Result Execution time Memory
131363 2019-07-17T05:31:08 Z antimirage Scales (IOI15_scales) C++14
0 / 100
3 ms 504 KB
#include "scales.h"
#include <bits/stdc++.h>

#define pb push_back
#define all(s) s.begin(), s.end()

using namespace std;

int in[7];

void init(int T) {
	srand(time(NULL));
}

void orderCoins() {
    int ans[6], cnt = 0;
		
    int res1[3] = {1, 2, 3}, res2[3] = {4, 5, 6};
    
    res1[0] = getLightest(in[1], in[2], in[3]); cnt++;
    res2[0] = getLightest(in[4], in[5], in[6]); cnt++;
	
	res1[2] = getHeaviest(in[1], in[2], in[3]); cnt++;
	res2[2] = getHeaviest(in[4], in[5], in[6]); cnt++;
	
	for (int i = 1; i <= 3; i++) {
		if (res1[0] != in[i] && res1[2] != in[i]) {
			res1[1] = in[i];
		}
		if (res2[0] != in[i + 3] && res2[2] != in[i + 3]) {
			res2[1] = in[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 <= 8);
			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++;
			}
		}
	}
	assert(cnt <= 8);
	answer(ans);
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:12:12: warning: conversion to 'unsigned int' from 'time_t {aka long int}' may alter its value [-Wconversion]
  srand(time(NULL));
        ~~~~^~~~~~
scales.cpp:11:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 2 ms 380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 2 ms 476 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 2 ms 380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)