#include <bits/stdc++.h>
#include "scales.h"
using namespace std;
#define ll long long
void init(int t) {}
void orderCoins() {
vector<int> x(6, 0);
int a = getLightest(1, 2, 3);
int b = getLightest(4, 5, 6);
int c = (a == 1) ? 3 : (a == 2) ? 1 : 2; // Asegurar que c es una moneda válida
int d = getLightest(a, b, c);
int a1 = getHeaviest(1, 2, 3);
int b1 = getHeaviest(4, 5, 6);
int c1 = (a1 == 1) ? 3 : (a1 == 2) ? 1 : 2;
int d1 = getHeaviest(a1, b1, c1);
if (d >= 1 && d <= 6) x[d - 1] = 1;
if (d1 >= 1 && d1 <= 6) x[d1 - 1] = 2;
vector<int> remaining;
for (int i = 1; i <= 6; i++) {
if (x[i - 1] == 0) remaining.push_back(i);
}
int W[6] = {d, -1, -1, -1, -1, d1};
int q1 = getLightest(remaining[0], remaining[1], remaining[2]);
int q2 = getLightest(remaining[1], remaining[2], remaining[3]);
if (q1 == q2) {
W[1] = q1;
x[q1 - 1] = 3;
remaining.clear();
for (int i = 1; i <= 6; i++) {
if (x[i - 1] == 0) remaining.push_back(i);
}
int f3 = getLightest(remaining[0], remaining[1], remaining[2]);
int f5 = getHeaviest(remaining[0], remaining[1], remaining[2]);
int f4 = getMedian(remaining[0], remaining[1], remaining[2]);
W[2] = f3;
W[3] = f4;
W[4] = f5;
} else {
int q3 = getLightest(remaining[0], remaining[3], d1);
W[1] = q3;
x[q3 - 1] = 3;
remaining.clear();
for (int i = 1; i <= 6; i++) {
if (x[i - 1] == 0) remaining.push_back(i);
}
int f3 = getLightest(remaining[0], remaining[1], remaining[2]);
int f5 = getHeaviest(remaining[0], remaining[1], remaining[2]);
int f4 = getMedian(remaining[0], remaining[1], remaining[2]);
W[2] = f3;
W[3] = f4;
W[4] = f5;
}
answer(W);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |