제출 #295665

#제출 시각아이디문제언어결과실행 시간메모리
295665peti1234Scales (IOI15_scales)C++17
71.43 / 100
28 ms512 KiB
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;
const int cc=722, f=6;
vector<int> sz;
int ert[cc][f], inv[cc][f], pos, db, ki, t[3], re[f], q;
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]=inv[i][a], t[1]=inv[i][b], t[2]=inv[i][c];
        sort(t, t+3), q=ert[i][t[h]];
        if (a==q) x++;
        if (b==q) y++;
        if (c==q) 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]=inv[i][a], t[1]=inv[i][b], t[2]=inv[i][c];
        sort(t, t+3);
        if (ert[i][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<f; x++) for (int y=x+1; y<f; y++) for (int z=y+1; z<f; 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;
        }
        a++, b++, c++;
        if (h==0) ans=getLightest(a, b, c);
        if (h==1) ans=getMedian(a, b, c);
        if (h==2) ans=getHeaviest(a, b, c);
        a--, b--, c--, ans--;
        add(a, b, c, h, ans);
    }
    for (int i=0; i<pos; i++) if (v[i]) ki=i;
    for (int i=0; i<f; i++) re[i]=ert[ki][i]+1;
    answer(re);
}
void init(int w) {
    for (int i=0; i<f; i++) sz.push_back(i);
    do {
        for (int i=0; i<f; i++) inv[pos][i]=sz[i], ert[pos][sz[i]]=i;
        pos++;
    } while(next_permutation(sz.begin(), sz.end()));
}

컴파일 시 표준 에러 (stderr) 메시지

scales.cpp: In function 'void init(int)':
scales.cpp:46:15: warning: unused parameter 'w' [-Wunused-parameter]
   46 | void init(int w) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...