제출 #1329757

#제출 시각아이디문제언어결과실행 시간메모리
1329757SulAScales (IOI15_scales)C++20
0 / 100
1 ms344 KiB
#include "scales.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

void init(int t) {}

// int getLightest(int a, int b, int c) {
//     cout << "MIN " << a << " " << b << " " << c << endl;
//     cin >> a;
//     return a;
// }

// int getMedian(int a, int b, int c) {
//     cout << "MED " << a << " " << b << " " << c << endl;
//     cin >> a;
//     return a;
// }

int theoryGetMedian(int coins[6], int a, int b, int c) {
    int cnt = 0;
    for (int i = 0; i < 6; i++) {
        if (coins[i] == a || coins[i] == b || coins[i] == c)
            cnt++;
        if (cnt == 2)
            return coins[i];
    }
    return -1;
}

void orderCoins() {
    vector<int> rem = {1, 2, 3, 4, 5, 6};
    int coins[6];
    int A[3], B[3];
    A[0] = getLightest(1, 2, 3);
    A[1] = getMedian(1, 2, 3);
    A[2] = A[0] ^ A[1];
    B[0] = getLightest(4, 5, 6);
    B[1] = getMedian(4, 5, 6);
    B[2] = B[0] ^ B[1] ^ 4 ^ 5 ^ 6;
    vector<int> qu[] = {
            {A[0], A[1], B[0]},
            {A[2], B[0], B[1]},
            {A[0], A[2], B[0]},
            {A[1], B[0], B[2]}
    };
    int ans[4];
    for (int i = 0; i < 4; i++)
        ans[i] = getMedian(qu[i][0], qu[i][1], qu[i][2]);
    for (int i = 0; i < 6; i++) {
        for (int j = i+1; j < 6; j++) {
            for (int k = j+1; k < 6; k++) {
                fill(coins, coins + 6, 0);
                coins[i] = A[0];
                coins[j] = A[1];
                coins[k] = A[2];
                for (int l = 0, p = 0; l < 6; l++)
                    if (coins[l] == 0)
                        coins[l] = B[p++];
                bool good = true;
                for (int l = 0; l < 4; l++) {
                    good &= ans[l] == theoryGetMedian(coins, qu[l][0], qu[l][1], qu[l][2]);
                }
                if (good) {
                    // for (int x : coins) cout << x << " ";
                    // cout << "\n";
                    answer(coins);
                }
            }
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...