Submission #580421

#TimeUsernameProblemLanguageResultExecution timeMemory
580421alireza_kavianiScales (IOI15_scales)C++17
55.56 / 100
1 ms284 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;

void init(int T) {

}

int Sort3(int &A , int &B , int &C){
    int x = A , y = B , z = C;
    int res = getMedian(x , y , z);
    if(res == x){
        A = z; B = x; C = y;
        return 1;
    }
    if(res == y){
        A = x; B = y; C = z;
        return 2;
    }
    if(res == z){
        A = x; B = z; C = y;
        return 3;
    }
    return 0;
}

void orderCoins() {
    int ax = getLightest(1 , 2 , 3);
    int az = getHeaviest(1 , 2 , 3);
    int ay = 1 + 2 + 3 - ax - az;
    int bx = getLightest(4 , 5 , 6);
    int bz = getHeaviest(4 , 5 , 6);
    int by = 4 + 5 + 6 - bx - bz;

    int W[6] = {ax , ay , bx , by , bz , az};
    int x = Sort3(W[0] , W[1] , W[2]);
    int y = Sort3(W[3] , W[4] , W[5]);

    if(y != 2){
        Sort3(W[1] , W[2] , W[3]);
        answer(W);
        return;
    }

    if(x != 1){
        swap(W[3] , W[4]);
        swap(W[2] , W[4]);
        Sort3(W[2] , W[3] , W[4]);
        answer(W);
        return;
    }

    Sort3(W[1] , W[2] , W[3]);
    Sort3(W[2] , W[3] , W[4]);
    answer(W);
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
    5 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...