# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128388 | kingfran1907 | Scales (IOI15_scales) | C++14 | 2 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10;
int fir[maxn];
int sec[maxn];
void init(int T) {
/* ... */
}
void orderCoins() {
/* ... */
int w[] = {0, 0, 0, 0, 0, 0};
fir[0] = getLightest(1, 2, 3);
fir[1] = getMedian(1, 2, 3);
fir[2] = 1 + 2 + 3 - fir[0] - fir[1];
sec[0] = getLightest(4, 5, 6);
sec[1] = getMedian(4, 5, 6);
sec[2] = 4 + 5 + 6 - sec[0] - sec[1];
int ptr1 = 0, ptr2 = 0;
int ptr = 0;
//cout << "fir: "; for (int i = 0; i < 3; i++) //cout << fir[i] << " "; //cout << endl;
//cout << "sec: "; for (int i = 0; i < 3; i++) //cout << sec[i] << " "; //cout << endl;
while (ptr < 6) {
if (ptr1 == 3) {
for (int i = ptr2; i < 3; i++)
w[ptr++] = sec[i];
ptr2 = 3;
} else if (ptr2 == 3) {
for (int i = ptr1; i < 3; i++)
w[ptr++] = fir[i];
ptr1 = 3;
} else if (ptr == 5) {
if (ptr1 == 2) w[ptr] = fir[ptr1], ptr++, ptr1++;
else if (ptr2 == 2) w[ptr] = sec[ptr2], ptr++, ptr2++;
} else if (ptr1 == 2 && ptr2 == 2) {
w[ptr] = getMedian(fir[2], sec[2], w[0]);
w[ptr + 1] = fir[2] + sec[2] - w[ptr];
ptr += 2, ptr1++, ptr2++;
} else if (ptr1 < 2) {
//cout << "considering: " << fir[ptr1] << " " << fir[ptr1 + 1] << " " << sec[ptr2] << endl;
int x = getMedian(fir[ptr1], fir[ptr1 + 1], sec[ptr2]);
if (x == fir[ptr1 + 1]) {
w[ptr] = fir[ptr1];
w[ptr + 1] = fir[ptr1 + 1];
w[ptr + 2] = sec[ptr2];
ptr += 3, ptr1 += 2, ptr2++;
} else if (x == fir[ptr1]) {
w[ptr] = sec[ptr2];
w[ptr + 1] = fir[ptr1];
w[ptr + 2] = fir[ptr1 + 1];
ptr += 3, ptr1 += 2, ptr2++;
} else {
//cout << "kurac" << endl;
w[ptr] = fir[ptr1];
w[ptr + 1] = sec[ptr2];
//w[ptr + 2] = fir[ptr + 1];
ptr += 2, ptr1++, ptr2++;
}
//cout << "res: " << w[ptr - 3] << " " << w[ptr - 2] << " " << w[ptr - 1] << endl;
} else if (ptr2 < 2) {
//cout << "considering: " << sec[ptr2] << " " << sec[ptr2 + 1] << " " << fir[ptr1] << endl;
int x = getMedian(sec[ptr2], sec[ptr2 + 1], fir[ptr1]);
if (x == sec[ptr2 + 1]) {
w[ptr] = sec[ptr2];
w[ptr + 1] = sec[ptr2 + 1];
w[ptr + 2] = fir[ptr1];
ptr += 3, ptr2 += 2, ptr1++;
} else if (x == sec[ptr2]) {
w[ptr] = fir[ptr1];
w[ptr + 1] = sec[ptr2];
w[ptr + 2] = sec[ptr2 + 1];
ptr += 3, ptr2 += 2, ptr1++;
} else {
//cout << "kurac" << endl;
w[ptr] = sec[ptr2];
w[ptr + 1] = fir[ptr1];
//w[ptr + 2] = sec[ptr2 + 1];
ptr += 2, ptr2++, ptr1++;
}
//cout << "res: " << w[ptr - 3] << " " << w[ptr - 2] << " " << w[ptr - 1] << endl;
}
//cout << "w: ";
//for (int i = 0; i < 6; i++) //cout << w[i] << " ";
//cout << endl;
}
answer(w);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |