# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
254192 | eohomegrownapps | Scales (IOI15_scales) | C++14 | 1 ms | 384 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;
/*
void answer(int W[]);
int igetMedian(int A, int B, int C);
int igetHeaviest(int A, int B, int C);
int igetLightest(int A, int B, int C);
int igetNextLightest(int A, int B, int C, int D);
*/
int igetMedian(int A, int B, int C){
//cout<<"m "<<A<<" "<<B<<" "<<C<<'\n';
return getMedian(A+1, B+1, C+1)-1;
}
int igetHeaviest(int A, int B, int C){
//cout<<"h "<<A<<" "<<B<<" "<<C<<'\n';
return getHeaviest(A+1, B+1, C+1)-1;
}
int igetLightest(int A, int B, int C){
//cout<<"l "<<A<<" "<<B<<" "<<C<<'\n';
return getLightest(A+1, B+1, C+1)-1;
}
int igetNextLightest(int A, int B, int C, int D){
//cout<<"nl "<<A<<" "<<B<<" "<<C<<" "<<D<<'\n';
return getNextLightest(A+1, B+1, C+1, D+1)-1;
}
void init(int T) {
/* ... */
}
void orderCoins() {
int arr[6] = {0,1,2,3,4,5};
int l012 = igetLightest(0,1,2);
int h345 = igetHeaviest(3,4,5);
int l01[2];
int ptr = 0;
for (int i = 0; i<3; i++){
if (i==l012){continue;}
l01[ptr]=i;ptr++;
}
int h01[2];
ptr = 0;
for (int i = 3; i<6; i++){
if (i==h345){continue;}
h01[ptr]=i;ptr++;
}
int h012345 = igetHeaviest(l01[0],l01[1],h345);
int l012345 = igetLightest(h01[0],h01[1],l012);
arr[0]=l012345;arr[5]=h012345;
//cout<<arr[0]<<' '<<arr[5]<<'\n';
int v1234[4];ptr=0;
for (int i = 0; i<6; i++){
if (i==h012345||i==l012345){continue;}
v1234[ptr]=i;ptr++;
}
int l123 = igetLightest(v1234[0],v1234[1],v1234[2]);
int v234[3];ptr=0;
for (int i = 0; i<4; i++){
if (v1234[i]==l123){continue;}
v234[ptr]=v1234[i];ptr++;
}
int h234 = igetHeaviest(v234[0],v234[1],v234[2]);
//if e
if (h234==v1234[3]){
arr[1]=l123;
arr[4]=h234;
arr[2]=igetLightest(v234[0],v234[1],v234[2]);
arr[3]=(arr[2]==v234[0])?v234[1]:v234[0];
} else {
v1234[0]=l123;
v1234[1]=v234[0];
v1234[2]=v234[1];
if (h234==v1234[1]){swap(v1234[1],v1234[2]);}
int eafter = igetNextLightest(v1234[0],v1234[1],v1234[2],v1234[3]);
int ptr = 4;
for (int i = 2; i>=0; i--){
arr[ptr]=v1234[i];
ptr--;
if (v1234[i]==eafter){
arr[ptr]=v1234[3];
ptr--;
}
}
}
for (int i = 0; i<6; i++){
arr[i]++;
}
answer(arr);
return;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |