제출 #1329758

#제출 시각아이디문제언어결과실행 시간메모리
1329758SulAScales (IOI15_scales)C++20
38.46 / 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 real_coins[6];

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

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[1], A[2], B[1]},
            {A[0], A[2], B[2]},
            {B[0], B[1], A[0]},
            {B[1], B[2], A[1]},
            {B[0], B[2], A[2]}
    };
    const int Q = sizeof(qu)/sizeof(qu[0]);
    int ans[Q];
    for (int i = 0; i < Q; i++) {
        ans[i] = getMedian(qu[i][0], qu[i][1], qu[i][2]);
    }
    int c = 0;
    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 < Q; 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";
//                    return;
//                    c++;
                    answer(coins);
                }
            }
        }
    }
}


// int main() {
    // iota(real_coins, real_coins + 6, 1);
    // do {
        // orderCoins();
    // } while (next_permutation(real_coins, real_coins + 6));
// }
#Verdict Execution timeMemoryGrader output
Fetching results...