제출 #1331820

#제출 시각아이디문제언어결과실행 시간메모리
1331820orgiloogiiScales (IOI15_scales)C++20
0 / 100
1 ms344 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
void init(int T) {}

vector <int> order4 (int a, int b, int c, int d) {
    int a1, b1, c1, d1;
    int vis[7] = {};
    for (int i = 1;i < 7;i++) {
        if (i != a && i != b && i != c && i != d) {
            vis[i] = -1;
        }
        else {
            vis[i] = 0;
        }
    }
    a1 = getLightest(a, b, c);
    vis[a1] = true;
    if (a1 == a) {
        b1 = getLightest(b, c, d);
    }
    else if (a1 == b) {
        b1 = getLightest(a, c, d);
    }
    else if (a1 == c) {
        b1 = getLightest(a, b, d);
    }
    vis[b1] = true;
    if (b1 == d) {
        vector <int> losers;
        for (int x : {a, b, c}) {
            if (x != a1) losers.push_back(x);
        }
        int idk = losers[0];
        
        int k = getLightest(a1, b1, idk);
        if (k == b1) swap(a1, b1);
    }

    for (int i = 1;i < 7;i++) {
        if (vis[i] == 0) {
            c1 = i;
            vis[i] = 1;
            break;
        }
    }
    for (int i = 1;i < 7;i++) {
        if (vis[i] == 0) {
            d1 = i;
            vis[i] = 1;
            break;
        }
    }
    int temp = getHeaviest(b1, c1, d1);
    if (temp == b1) {
        swap(b1, d1);
        int light = getLightest(b1, c1, a1);
        if (light == c1) swap(b1, c1);
    } else if (temp == c1) {
        swap(c1, d1);
    }
    // cout << a1 << " " << b1 << " " << c1 << ' ' << d1 << endl;
    return {a1, b1, c1, d1};
}

void orderCoins() {
    int W[] = {1, 2, 3, 4, 5, 6};
    vector <vector <int>> ans(7);
    vector <int> temp;
    temp = order4(1, 2, 3, 4);
    ans[temp[3]].push_back(temp[2]);
    ans[temp[3]].push_back(temp[1]);
    ans[temp[3]].push_back(temp[0]);
    ans[temp[2]].push_back(temp[1]);
    ans[temp[2]].push_back(temp[0]);
    ans[temp[1]].push_back(temp[0]);
    temp = order4(1, 2, 5, 6);
    ans[temp[3]].push_back(temp[2]);
    ans[temp[3]].push_back(temp[1]);
    ans[temp[3]].push_back(temp[0]);
    ans[temp[2]].push_back(temp[1]);
    ans[temp[2]].push_back(temp[0]);
    ans[temp[1]].push_back(temp[0]);
    temp = order4(3, 4, 5, 6);
    ans[temp[3]].push_back(temp[2]);
    ans[temp[3]].push_back(temp[1]);
    ans[temp[3]].push_back(temp[0]);
    ans[temp[2]].push_back(temp[1]);
    ans[temp[2]].push_back(temp[0]);
    ans[temp[1]].push_back(temp[0]);
    vector <pair <int, int>> res;
    for (int i = 1;i < 7;i++) {
        res.push_back({ans[i].size(), i});
    }
    sort(res.begin(), res.end());
    for (int i = 0;i < 6;i++) {
        W[i] = res[i].second;
        // cout << W[i] << " ";
    }
    answer(W); 
}
#Verdict Execution timeMemoryGrader output
Fetching results...