Submission #944498

# Submission time Handle Problem Language Result Execution time Memory
944498 2024-03-12T19:29:16 Z Lobo Scales (IOI15_scales) C++17
0 / 100
1000 ms 600 KB
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = -1;
vector<vector<int>> allp, queries, muito;
void init(int T) {
    muito.resize(800,vector<int>(7,0));
    vector<int> p = {0,1,2,3,4,5,6};
    while(p[0] == 0) {
        allp.pb(p);
        next_permutation(all(p));
    }

    for(int a = 1; a <= 6; a++) {
        for(int b = a+1; b <= 6; b++) {
            for(int c = b+1; c <= 6; c++) {
                queries.pb(vector<int>{0,a,b,c});
                queries.pb(vector<int>{1,a,b,c});
                queries.pb(vector<int>{2,a,b,c});
                for(int d = 1; d <= 6; d++) {
                    if(d == a or d == b or d == c) continue;
                    queries.pb(vector<int>{3,a,b,c,d});
                }
            }
        }
    }
    /* ... */
}

// 0 L
// 1 M
// 2 H
// 3 S
// ABC(3->D)
// resp
vector<vector<int>> postot(vector<vector<int>> qrs) {
    vector<vector<int>> ansp;

    for(auto p : allp) {
        bool ok = true;
        vector<int> pos(7);
        for(int i = 1; i <= 6; i++) pos[p[i]] = i;

        for(auto vec : qrs) {
            int tp = vec[0];
            int res = vec.back();
            if(tp == 0) {
                int a = vec[1];
                int b = vec[2];
                int c = vec[3];

                if(min({p[a],p[b],p[c]}) != p[res]) ok = false;
            }
            if(tp == 1) {
                int a = vec[1];
                int b = vec[2];
                int c = vec[3];

                if(p[a]+p[b]+p[c] - min({p[a],p[b],p[c]}) - max({p[a],p[b],p[c]}) != p[res]) ok = false;
            }
            if(tp == 2) {
                int a = vec[1];
                int b = vec[2];
                int c = vec[3];
                if(max({p[a],p[b],p[c]}) != p[res]) ok = false;
            }
            if(tp == 3) {
                int a = vec[1];
                int b = vec[2];
                int c = vec[3];
                int d = vec[4];

                if(p[d] > max({p[a],p[b],p[c]})) {
                    if(p[res] != min({p[a],p[b],p[c]})) ok = false;
                }
                else {
                    int anshere = 7;
                    if(p[a] > p[d]) anshere = min(anshere,p[a]);
                    if(p[b] > p[d]) anshere = min(anshere,p[b]);
                    if(p[c] > p[d]) anshere = min(anshere,p[c]);
                    if(anshere != p[res]) ok = false;
                }
            }
        }

        if(ok) {
            ansp.pb(p);
        }
    }
    // if(ansp.size() == 0) {
    //     return muito;
    // }
    return ansp;
}

void orderCoins() {
    vector<vector<int>> qrsofar;

    while(true) {
        pair<int,vector<int>> mnqr;
        mnqr.fr = 800;

        for(auto qr : queries) {
            qrsofar.pb(qr);
            qrsofar.back().pb(0);

            int mx = 0;
            qrsofar.back().back() = qr[1];
            mx = max(mx,(int) postot(qrsofar).size());
            qrsofar.back().back() = qr[2];
            mx = max(mx,(int) postot(qrsofar).size());
            qrsofar.back().back() = qr[3];
            mx = max(mx,(int) postot(qrsofar).size());

            qrsofar.pop_back();
            mnqr = min(mnqr,mp(mx,qr));
        }

        // cout << "   " << mnqr.fr << endl;

        auto qr = mnqr.sc;

        if(qr[0] == 0) {
            qr.pb(getLightest(qr[1],qr[2],qr[3]));
        }
        if(qr[0] == 1) {
            qr.pb(getMedian(qr[1],qr[2],qr[3]));
        }
        if(qr[0] == 2) {
            qr.pb(getHeaviest(qr[1],qr[2],qr[3]));
        }
        if(qr[0] == 3) {
            qr.pb(getNextLightest(qr[1],qr[2],qr[3],qr[4]));
        }

        // for(auto x : qr) cout << x << endl;
        // cout << endl;
        // cout << mnqr.fr << endl;

        qrsofar.pb(qr);
        // cout << " " << postot(qrsofar).size() << endl;
        // auto p = postot(qrsofar)[0];
        // for(int i = 1; i <= 6; i++) cout << p[i] << " "; cout << endl;
        // p = postot(qrsofar)[1];
        // for(int i = 1; i <= 6; i++) cout << p[i] << " "; cout << endl;

        // break;

        if(postot(qrsofar).size() == 1) break;
    }

    auto p = postot(qrsofar)[0];
    vector<int> pos(7);
    for(int i = 1; i <= 6; i++) pos[p[i]] = i;


    auto ansvec = pos;
    int ANS[] = {ansvec[1],ansvec[2],ansvec[3],ansvec[4],ansvec[5],ansvec[6]};

    answer(ANS);

    // /* ... */
    // int W[] = {1, 2, 3, 4, 5, 6};
    // answer(W);
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:12:15: warning: unused parameter 'T' [-Wunused-parameter]
   12 | void init(int T) {
      |           ~~~~^
# Verdict Execution time Memory Grader output
1 Execution timed out 1034 ms 348 KB Time limit exceeded
2 Execution timed out 1068 ms 348 KB Time limit exceeded
3 Execution timed out 1067 ms 348 KB Time limit exceeded
4 Execution timed out 1052 ms 348 KB Time limit exceeded
5 Execution timed out 1038 ms 348 KB Time limit exceeded
6 Execution timed out 1016 ms 344 KB Time limit exceeded
7 Execution timed out 1053 ms 348 KB Time limit exceeded
8 Execution timed out 1086 ms 344 KB Time limit exceeded
9 Execution timed out 1050 ms 348 KB Time limit exceeded
10 Execution timed out 1058 ms 348 KB Time limit exceeded
11 Execution timed out 1026 ms 344 KB Time limit exceeded
12 Execution timed out 1031 ms 344 KB Time limit exceeded
13 Execution timed out 1055 ms 348 KB Time limit exceeded
14 Execution timed out 1040 ms 348 KB Time limit exceeded
15 Execution timed out 1065 ms 348 KB Time limit exceeded
16 Execution timed out 1071 ms 348 KB Time limit exceeded
17 Execution timed out 1069 ms 348 KB Time limit exceeded
18 Execution timed out 1067 ms 348 KB Time limit exceeded
19 Execution timed out 1043 ms 600 KB Time limit exceeded
20 Execution timed out 1062 ms 348 KB Time limit exceeded
21 Execution timed out 1055 ms 348 KB Time limit exceeded
22 Execution timed out 1069 ms 348 KB Time limit exceeded
23 Execution timed out 1016 ms 348 KB Time limit exceeded
24 Execution timed out 1032 ms 344 KB Time limit exceeded
25 Execution timed out 1060 ms 348 KB Time limit exceeded
26 Execution timed out 1010 ms 344 KB Time limit exceeded
27 Execution timed out 1063 ms 348 KB Time limit exceeded
28 Execution timed out 1074 ms 348 KB Time limit exceeded
29 Execution timed out 1031 ms 432 KB Time limit exceeded
30 Execution timed out 1050 ms 348 KB Time limit exceeded
31 Execution timed out 1068 ms 348 KB Time limit exceeded
32 Execution timed out 1055 ms 348 KB Time limit exceeded
33 Execution timed out 1055 ms 348 KB Time limit exceeded
34 Execution timed out 1018 ms 344 KB Time limit exceeded
35 Execution timed out 1018 ms 344 KB Time limit exceeded
36 Execution timed out 1043 ms 344 KB Time limit exceeded
37 Execution timed out 1024 ms 344 KB Time limit exceeded
38 Execution timed out 1064 ms 348 KB Time limit exceeded
39 Execution timed out 1028 ms 344 KB Time limit exceeded
40 Execution timed out 1069 ms 348 KB Time limit exceeded