Submission #1246553

#TimeUsernameProblemLanguageResultExecution timeMemory
1246553countlessScales (IOI15_scales)C++20
55.56 / 100
1 ms328 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define sp <<" "<<
#define endl "\n"

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

void orderCoins() {
    /* ... */
    // merge sort thing
    vector<int> L = {1, 2, 3}, R = {4, 5, 6};
    auto sort3 = [&](vector<int> &X) -> void {
        cerr << "query1" sp X[0] sp X[1] sp X[2] << endl;
        int A = getLightest(X[0], X[1], X[2]);
        int B = getMedian(X[0], X[1], X[2]);
        int C;
        for (int i = 0; i < 3; i++) {
            if (X[i] == A or X[i] == B) continue;
            C = X[i];
        }
        X = {A, B, C};
    };
    sort3(L), sort3(R);
    vector<int> A;
    int l = 0, r = 0;
    while (l < 3 and r < 3 and l + r < 3) {
        int N = (l == 2 ? R[2] : L[2]);
        cerr << "query2" sp L[l] sp R[r] sp N << endl;
        int X = getLightest(L[l], R[r], N);
        if (X == L[l]) l++;
        else r++;
        A.push_back(X);
    }

    if (l == 3) {
        while (r < 3) {
            A.push_back(R[r]);
            r++;
        }
    } else if (r == 3) {
        while (l < 3) {
            A.push_back(L[l]);
            l++;
        }
    } else {
        if (l == 1) {
            int N = L[2];
            cerr << "query3" sp L[l] sp R[r] sp N << endl;
            int X = getMedian(L[l], R[r], N);
            if (X == L[l]) {
                A.push_back(R[r]);
                A.push_back(L[l]);
                A.push_back(N);
            } else if (X == N) {
                A.push_back(L[l]);
                A.push_back(N);
                A.push_back(R[r]);
            } else {
                A.push_back(L[l]);
                A.push_back(R[r]);
                A.push_back(N);
            }
        } else if (r == 1) {
            int N = R[2];
            cerr << "query3" sp L[l] sp R[r] sp N << endl;
            int X = getMedian(L[l], R[r], N);
            if (X == R[r]) {
                A.push_back(L[l]);
                A.push_back(R[r]);
                A.push_back(N);
            } else if (X == N) {
                A.push_back(R[r]);
                A.push_back(N);
                A.push_back(L[l]);
            } else {
                A.push_back(R[r]);
                A.push_back(L[l]);
                A.push_back(N);
            }
        }
    }

    int W[6];
    for (int i = 0; i < 6; i++) W[i] = A[i];
    answer(W);
}
#Verdict Execution timeMemoryGrader output
Fetching results...