Submission #840556

# Submission time Handle Problem Language Result Execution time Memory
840556 2023-08-31T13:47:18 Z PagodePaiva Scales (IOI15_scales) C++17
0 / 100
1 ms 304 KB
#include "scales.h"
#include<bits/stdc++.h>

using namespace std;

void init(int T) {
    /* ... */
}

void orderCoins(){
	map <int, int> res;
	int maxval = getHeaviest(1, 2, 3);
	int sv = maxval;
	int maxval2 = getHeaviest(4, 5, 6);
	maxval = getHeaviest(maxval, maxval2, (maxval != 1  and maxval2 != 1? 1 : (maxval != 2 and maxval2 != 2 ? 2 : 3)));
	res[maxval] = 1;

	vector <int> a1;

	for(int i = 1;i <= 3;i++){
		if(res[i] == 0) a1.push_back(i);
	}

	vector <int> a2;

	for(int i = 4;i <= 6;i++){
		if(res[i] == 0) a2.push_back(i);
	}

	if(a1.size() == 2){
		int a = a1[0];
		int b = a1[1];
		int t = getHeaviest(maxval2, a, b);
		res[t] = 2;
	}

	else{
		int a = a2[0];
		int b = a2[1];
		int t = getHeaviest(sv, a, b);
		res[t] = 2;
	}

	vector <int> v;

	for(int i = 1;i <= 6;i++){
		if(res[i] == 0) v.push_back(i);
	}

	int t = getHeaviest(v[0], v[1], v[2]);
	int pos = (t == v[0] ? 0 : (t == v[1] ? 1 : 2));

	swap(v[0], v[pos]);

	t = getMedian(v[0], v[1], v[3]);

	if(t == v[0]){
		res[v[3]] = 3;
		res[v[0]] = 4;
		t = getMedian(v[0], v[1], v[2]);

		if(t == v[1]){
			res[v[1]] = 5;
			res[v[2]] = 6;
		}

		else{
			res[v[2]] = 5;
			res[v[1]] = 6;
		}
	}

	else if(t == v[1]){
		res[v[0]] = 3;

		int t = getNextLightest(maxval, v[1], v[3], v[2]);

		if(t == maxval){
			res[v[2]] = 4;
			res[v[1]] = 5;
			res[v[3]] = 6;
		}

		else if(t == v[1]){
			res[v[1]] = 4;
			res[v[3]] = 6;
			res[v[2]] = 5;
		}

		else{
			res[v[1]] = 4;
			res[v[3]] = 5;
			res[v[2]] = 6;
		}
	}

	else{
		res[v[0]] = 3;

		swap(v[1], v[3]);
		int t = getNextLightest(maxval, v[1], v[3], v[2]);

		if(t == maxval){
			res[v[2]] = 4;
			res[v[1]] = 5;
			res[v[3]] = 6;
		}

		else if(t == v[1]){
			res[v[1]] = 4;
			res[v[3]] = 6;
			res[v[2]] = 5;
		}

		else{
			res[v[1]] = 4;
			res[v[3]] = 5;
			res[v[2]] = 6;
		}
	}

	vector <pair <int , int>> aa;

	for(int i = 1;i <= 6;i++){
		aa.push_back({res[i], i});
	}

	sort(aa.begin(), aa.end());

	vector <int> ans;
	for(auto x : aa){
		ans.push_back(x.second);
	}

	int W[6];

	for(int i = 0;i < 6;i++){
		W[i] = ans[i];
	}

	answer(W);
	return;
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:6:15: warning: unused parameter 'T' [-Wunused-parameter]
    6 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:76:7: warning: declaration of 't' shadows a previous local [-Wshadow]
   76 |   int t = getNextLightest(maxval, v[1], v[3], v[2]);
      |       ^
scales.cpp:50:6: note: shadowed declaration is here
   50 |  int t = getHeaviest(v[0], v[1], v[2]);
      |      ^
scales.cpp:101:7: warning: declaration of 't' shadows a previous local [-Wshadow]
  101 |   int t = getNextLightest(maxval, v[1], v[3], v[2]);
      |       ^
scales.cpp:50:6: note: shadowed declaration is here
   50 |  int t = getHeaviest(v[0], v[1], v[2]);
      |      ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Incorrect 1 ms 300 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Incorrect 1 ms 300 KB Output isn't correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Incorrect 0 ms 212 KB Output isn't correct
17 Incorrect 0 ms 212 KB Output isn't correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Incorrect 0 ms 212 KB Output isn't correct
20 Incorrect 0 ms 212 KB Output isn't correct
21 Incorrect 1 ms 212 KB Output isn't correct
22 Incorrect 0 ms 212 KB Output isn't correct
23 Incorrect 0 ms 212 KB Output isn't correct
24 Incorrect 1 ms 212 KB Output isn't correct
25 Incorrect 1 ms 304 KB Output isn't correct
26 Incorrect 0 ms 212 KB Output isn't correct
27 Incorrect 1 ms 212 KB Output isn't correct
28 Incorrect 1 ms 300 KB Output isn't correct
29 Incorrect 1 ms 212 KB Output isn't correct
30 Incorrect 1 ms 212 KB Output isn't correct
31 Incorrect 0 ms 296 KB Output isn't correct
32 Incorrect 0 ms 212 KB Output isn't correct
33 Incorrect 1 ms 300 KB Output isn't correct
34 Incorrect 1 ms 212 KB Output isn't correct
35 Incorrect 1 ms 300 KB Output isn't correct
36 Incorrect 1 ms 212 KB Output isn't correct
37 Incorrect 1 ms 212 KB Output isn't correct
38 Incorrect 0 ms 212 KB Output isn't correct
39 Incorrect 1 ms 304 KB Output isn't correct
40 Incorrect 1 ms 212 KB Output isn't correct