# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64428 | IvanC | Scales (IOI15_scales) | C++17 | 4 ms | 660 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;
typedef vector<int> vi;
void init(int T){
// printf("T %d casos de teste\n",T);
}
void orderCoins(){
// printf("Oi\n");
// Passo 1 : ordernar 1,2,3
vi P = {1,2,3,4,5,6};
random_shuffle(P.begin(),P.end());
vi W;
int r1 = getLightest(P[0],P[1],P[2]);
//printf("Meu primeiro resultado %d\n",r1);
int r2 = getMedian(P[0],P[1],P[2]);
//printf("Meu segundo resultado %d\n",r2);
W.push_back(r1);W.push_back(r2);W.push_back((P[0] + P[1] + P[2]) - (r1 + r2));
// Passo 2 : inserir o 4
int r3 = getMedian(W[0],W[1],P[3]);
if(r3 == W[0]){
vi A = {P[3],W[0],W[1],W[2]};
W = A;
}
else if(r3 == P[3]){
vi A = {W[0],P[3],W[1],W[2]};
W = A;
}
else{
int r4 = getHeaviest(W[0],W[2],P[3]);
if(r4 == P[3]){
W.push_back(P[3]);
}
else{
vi A = {W[0],W[1],P[3],W[2]};
W = A;
}
}
// Passo 3 : inserir o 5
int r5 = getMedian(W[0],W[1],P[4]);
if(r5 == W[0]){
vi A = {P[4],W[0],W[1],W[2],W[3]};
W = A;
}
else if(r5 == P[4]){
vi A = {W[0],P[4],W[1],W[2],W[3]};
W = A;
}
else{
int r6 = getMedian(W[2],W[3],P[4]);
if(r6 == W[2]){
vi A = {W[0],W[1],P[4],W[2],W[3]};
W = A;
}
else if(r6 == P[4]){
vi A = {W[0],W[1],W[2],P[4],W[3]};
W = A;
}
else{
W.push_back(P[4]);
}
}
// Passo 4 : inserir o 6
int r7 = getMedian(W[1],W[2],P[5]);
if(r7 == P[5]){
vi A = {W[0],W[1],P[5],W[2],W[3],W[4]};
W = A;
}
else if(r7 == W[1]){
int r8 = getLightest(W[0],W[1],P[5]);
if(r8 == P[5]){
vi A = {P[5],W[0],W[1],W[2],W[3],W[4]};
W = A;
}
else{
vi A = {W[0],P[5],W[1],W[2],W[3],W[4]};
W = A;
}
}
else{
int r8 = getMedian(W[3],W[4],P[5]);
if(r8 == P[5]){
vi A = {W[0],W[1],W[2],W[3],P[5],W[4]};
W = A;
}
else if(r8 == W[3]){
vi A = {W[0],W[1],W[2],P[5],W[3],W[4]};
W = A;
}
else{
W.push_back(P[5]);
}
}
int ANS[6];
for(int i = 0;i<6;i++) ANS[i] = W[i];
answer(ANS);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |