Submission #944559

# Submission time Handle Problem Language Result Execution time Memory
944559 2024-03-12T23:54:45 Z Lobo Scales (IOI15_scales) C++17
0 / 100
306 ms 604 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;
void init(int T) {
    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>> &disp, vector<int> &vec) {
    vector<vector<int>> ansp;

    for(auto p : disp) {
        bool ok = true;
        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;
            }
        }
        else 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;
            }
        }
        else 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;
            }
        }
        else 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);
        }
    }
    return ansp;
}

void orderCoins() {
    vector<vector<int>> perms = allp;
    while(true) {
        
        int mnqr = 800;
        vector<vector<int>> mns;
        for(auto qr : queries) {
            auto qr1 = qr;
            qr1.pb(0);
            int mx = 0;
            qr1.back() = qr[1];
            mx = max(mx,(int) postot(perms,qr1).size());
            qr1.back() = qr[2];
            mx = max(mx,(int) postot(perms,qr1).size());
            qr1.back() = qr[3];
            mx = max(mx,(int) postot(perms,qr1).size());

            if(mx < mnqr) {
                mnqr = mx;
                mns.clear();
                mns.pb(qr);
            }
            else if(mx == mnqr) {
                mns.pb(qr);
            }
        }

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

        auto qr = mns[0];

        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]));
        }

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

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


        perms = postot(perms,qr);
        // cout << perms.size() << endl;

        if(perms.size() == 1) break;
    }

    auto p = perms[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 Incorrect 286 ms 556 KB Hacked.
2 Incorrect 274 ms 560 KB Hacked.
3 Incorrect 274 ms 348 KB Hacked.
4 Incorrect 276 ms 348 KB Hacked.
5 Incorrect 278 ms 348 KB Hacked.
6 Incorrect 276 ms 344 KB Hacked.
7 Incorrect 273 ms 348 KB Hacked.
8 Incorrect 273 ms 348 KB Hacked.
9 Incorrect 274 ms 576 KB Hacked.
10 Incorrect 277 ms 596 KB Hacked.
11 Incorrect 278 ms 580 KB Hacked.
12 Incorrect 272 ms 560 KB Hacked.
13 Incorrect 275 ms 348 KB Hacked.
14 Incorrect 272 ms 348 KB Hacked.
15 Incorrect 276 ms 560 KB Hacked.
16 Incorrect 273 ms 568 KB Hacked.
17 Incorrect 291 ms 604 KB Hacked.
18 Incorrect 272 ms 568 KB Hacked.
19 Incorrect 284 ms 604 KB Hacked.
20 Incorrect 273 ms 580 KB Hacked.
21 Incorrect 275 ms 344 KB Hacked.
22 Incorrect 279 ms 592 KB Hacked.
23 Incorrect 276 ms 564 KB Hacked.
24 Incorrect 278 ms 348 KB Hacked.
25 Incorrect 273 ms 560 KB Hacked.
26 Incorrect 272 ms 568 KB Hacked.
27 Incorrect 288 ms 596 KB Hacked.
28 Incorrect 272 ms 564 KB Hacked.
29 Incorrect 301 ms 556 KB Hacked.
30 Incorrect 271 ms 556 KB Hacked.
31 Incorrect 273 ms 344 KB Hacked.
32 Incorrect 276 ms 596 KB Hacked.
33 Incorrect 278 ms 344 KB Hacked.
34 Incorrect 306 ms 572 KB Hacked.
35 Incorrect 274 ms 560 KB Hacked.
36 Incorrect 274 ms 344 KB Hacked.
37 Incorrect 275 ms 560 KB Hacked.
38 Incorrect 286 ms 560 KB Hacked.
39 Incorrect 273 ms 556 KB Hacked.
40 Incorrect 272 ms 560 KB Hacked.