제출 #295586

#제출 시각아이디문제언어결과실행 시간메모리
295586peti1234저울 (IOI15_scales)C++17
0 / 100
3 ms512 KiB
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;
const int cc=722;
vector<int> sz;
int ert[cc][6], pos, db, ki, t[3], re[6];
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;
    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()));
}

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

scales.cpp: In function 'void init(int)':
scales.cpp:44:16: warning: declaration of 't' shadows a global declaration [-Wshadow]
   44 | void init(int t) {
      |                ^
scales.cpp:6:30: note: shadowed declaration is here
    6 | int ert[cc][6], pos, db, ki, t[3], re[6];
      |                              ^
scales.cpp:44:15: warning: unused parameter 't' [-Wunused-parameter]
   44 | void init(int t) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...