Submission #936673

#TimeUsernameProblemLanguageResultExecution timeMemory
936673PagodePaivaScales (IOI15_scales)C++17
0 / 100
1 ms440 KiB
#include<bits/stdc++.h>
#include "scales.h"

using namespace std;

void init(int T) {
    /* ... */
}

void triple(vector <int> &v){
    int a = getHeaviest(v[0], v[1], v[2]);
    int b = getMedian(v[0], v[1], v[2]);
    int c;
    for(auto x : v){
        if(x == a) continue;
        if(x == b) continue;
        c = x;
        break;
    }
    v = {a, b, c};
    return;
}

void orderCoins() {
    vector <int> v1 = {1, 2, 3};
    vector <int> v2 = {4, 5, 6};
    triple(v1);
    triple(v2);
    int x = getLightest(v1[2], v2[2], v1[1]);
    vector <int> res;
    if(x == v1[2]){
        res.push_back(x);
        v1.pop_back();
    }
    else{
        res.push_back(x);
        v2.pop_back();
    }
    while(!v1.empty() and !v2.empty()){
        x = getMedian(res.back(), v1.back(), v2.back());
        if(x == v1.back()) v1.pop_back();
        else v2.pop_back();
        res.push_back(x);
    }
    while(!v1.empty()){
        res.push_back(v1.back());
        v1.pop_back();
    }
    while(!v2.empty()){
        res.push_back(v2.back());
        v2.pop_back();
    }
    int w[6];
    int i = 5;
    for(auto x : res){
        w[i] = x;
        i--;
    }
    answer(w);
    return;
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:6:15: warning: unused parameter 'T' [-Wunused-parameter]
    6 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:55:14: warning: declaration of 'x' shadows a previous local [-Wshadow]
   55 |     for(auto x : res){
      |              ^
scales.cpp:29:9: note: shadowed declaration is here
   29 |     int x = getLightest(v1[2], v2[2], v1[1]);
      |         ^
scales.cpp: In function 'void triple(std::vector<int>&)':
scales.cpp:20:7: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |     v = {a, b, c};
      |     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...