Submission #254192

#TimeUsernameProblemLanguageResultExecution timeMemory
254192eohomegrownappsScales (IOI15_scales)C++14
71.43 / 100
1 ms384 KiB
#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)

scales.cpp: In function 'void init(int)':
scales.cpp:30:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:83:13: warning: declaration of 'ptr' shadows a previous local [-Wshadow]
         int ptr = 4;
             ^~~
scales.cpp:40:9: note: shadowed declaration is here
     int ptr = 0;
         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...