Submission #295582

#TimeUsernameProblemLanguageResultExecution timeMemory
295582peti1234Scales (IOI15_scales)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;
const int cc=722;
vector<int> sz;
int ert[cc][6], pos, db, ki, t[3];
bool v[cc];
int ask(int a, int b, int c, int h) {
    int x=0, y=0, z=0;
    for (int i=0; i<pos; i++) if (v[i]) {
        t[0]=ert[i][a], t[1]=ert[i][b], t[2]=ert[i][c];
        sort(t, t+3);
        if (a==t[h]) x++;
        if (b==t[h]) y++;
        if (c==t[h]) z++;
    }
    return max({x, y, z});
}
void add(int a, int b, int c, int h, int ans) {
    for (int i=0; i<pos; i++) if (v[i]) {
        t[0]=ert[i][a], t[1]=ert[i][b], t[2]=ert[i][c];
        sort(t, t+3);
        if (t[h]!=ans) v[i]=0, db--;
    }
}
void orderCoins() {
    db=0, ki=0;
    for (int i=0; i<pos; i++) v[i]=1, db++;
    while(db>1) {
        int a=1, b=1, c=1, h=0, mini=db, ans=0;
        for (int x=0; x<6; x++) for (int y=x+1; y<6; y++) for (int z=y+1; z<6; z++) for (int e=0; e<3; e++) {
            int p=ask(x, y, z, e);
            if (p<mini) mini=p, a=x, b=y, c=z, h=e;
        }
        if (h==0) ans=getLightest(a, b, c);
        if (h==1) ans=getMedian(a, b, c);
        if (h==2) ans=getHeaviest(a, b, c);
        add(a, b, c, h, ans);

    }
    for (int i=0; i<pos; i++) if (v[i]) ki=i;
    vector<int> re;
    re.resize(6);
    for (int i=0; i<6; i++) re[ert[ki][i]]=i;
    answer(re);
}
void init(int t) {
    for (int i=0; i<6; i++) sz.push_back(i);
    do {
        for (int i=0; i<6; i++) ert[pos][i]=sz[i];
        pos++;
    } while(next_permutation(sz.begin(), sz.end()));
}

Compilation message (stderr)

scales.cpp: In function 'void orderCoins()':
scales.cpp:35:23: error: 'getLightest' was not declared in this scope
   35 |         if (h==0) ans=getLightest(a, b, c);
      |                       ^~~~~~~~~~~
scales.cpp:36:23: error: 'getMedian' was not declared in this scope
   36 |         if (h==1) ans=getMedian(a, b, c);
      |                       ^~~~~~~~~
scales.cpp:37:23: error: 'getHeaviest' was not declared in this scope
   37 |         if (h==2) ans=getHeaviest(a, b, c);
      |                       ^~~~~~~~~~~
scales.cpp:45:5: error: 'answer' was not declared in this scope
   45 |     answer(re);
      |     ^~~~~~
scales.cpp: In function 'void init(int)':
scales.cpp:47:16: warning: declaration of 't' shadows a global declaration [-Wshadow]
   47 | void init(int t) {
      |                ^
scales.cpp:6:30: note: shadowed declaration is here
    6 | int ert[cc][6], pos, db, ki, t[3];
      |                              ^
scales.cpp:47:15: warning: unused parameter 't' [-Wunused-parameter]
   47 | void init(int t) {
      |           ~~~~^