Submission #801907

#TimeUsernameProblemLanguageResultExecution timeMemory
801907_martynasScales (IOI15_scales)C++11
38.46 / 100
1 ms304 KiB
#include "scales.h"
#include <bits/stdc++.h>

using namespace std;

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

void orderCoins() {
    /* ... */
    int first_half_light = getLightest(1, 2, 3);
    int first_half_heavy = getHeaviest(1, 2, 3);
    int first_half_mid = 1^2^3^first_half_light^first_half_heavy;
    int second_half_light = getLightest(4, 5, 6);
    int second_half_heavy = getHeaviest(4, 5, 6);
    int second_half_mid = 4^5^6^second_half_light^second_half_heavy;
    vector<char> order = {'L', 'L', 'L'}; // L - first half, R - second half
    vector<int> check = {4, 5, 6};
    auto insert_after = [](vector<char> &v, int cnt) {
        if(cnt == 3) {
            v.push_back('R');
        }
        else {
            for(int i = 0; i < v.size(); i++) {
                if(cnt == 0) {
                    v.insert(v.begin()+i, 'R');
                    return;
                }
                if(v[i] == 'L') cnt--;
            }
        }
    };
    for(int x : check) {
        int resp = getNextLightest(first_half_light, first_half_mid, first_half_heavy, x);
        if(resp == first_half_light) {
            int resp1 = getLightest(first_half_light, first_half_mid, x);
            if(resp1 == x) {
                insert_after(order, 0);
            }
            else {
                insert_after(order, 3);
            }
        }
        else {
            if(resp == first_half_mid) {
                insert_after(order, 1);
            }
            else {
                insert_after(order, 2);
            }
            getLightest(1, 2, 3); // do nothing function to have constant Q
        }
    }
    int W[6];
    vector<int> first_half = {first_half_light, first_half_mid, first_half_heavy};
    vector<int> second_half = {second_half_light, second_half_mid, second_half_heavy};
    for(int i = 0, first_it = 0, second_it = 0; i < 6; i++) {
        if(order[i] == 'L') {
            W[i] = first_half[first_it++];
        }
        else {
            W[i] = second_half[second_it++];
        }
    }
    answer(W);
}

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 lambda function:
scales.cpp:25:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for(int i = 0; i < v.size(); i++) {
      |                            ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...