제출 #752520

#제출 시각아이디문제언어결과실행 시간메모리
752520phoebe저울 (IOI15_scales)C++17
55.56 / 100
1 ms212 KiB
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;

void init(int t){
    // wat why do we need this?
}

void orderCoins(){
    // int h[6] = {0};
    // answer(h); return;
    vector<int> x = {1, 2, 3, 4, 5, 6};
    int total = 1 + 2 + 3;
    // sort first half
    int mn = getLightest(1, 2, 3);
    int mx = getHeaviest(1, 2, 3);
    int med = total - mn - mx;
    x[0] = mn; x[1] = med; x[2] = mx;
    // sort second half
    total = 4 + 5 + 6;
    mn = getLightest(4, 5, 6);
    mx = getHeaviest(4, 5, 6);
    med = total - mn - mx;
    x[3] = mn; x[4] = med; x[5] = mx;
    vector<int> re;
    if (getLightest(x[0], x[3], x[5]) != x[3]){
        swap(x[0], x[3]); swap(x[1], x[4]); swap(x[2], x[5]);
    }
    // x[0] > x[3]
    int cur = 3;
    for (int i = 0; i < 3; i++){
        int med = getNextLightest(x[3], x[4], x[5], x[i]);
        if (med == x[3]){ // all smaller than x[i]
            while (cur < 6) re.push_back(x[cur++]);
            for (int j = i; j < 3; j++) re.push_back(x[j]);
            break;
        }
        else{
            while (x[cur] != med) re.push_back(x[cur++]);
        }
        re.push_back(x[i]);
    }
    while (cur < 6) re.push_back(x[cur++]);
    int w[6]; for (int i = 0; i < 6; i++) w[i] = re[i];
    answer(w);
}

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

scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 't' [-Wunused-parameter]
    5 | void init(int t){
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:32:13: warning: declaration of 'med' shadows a previous local [-Wshadow]
   32 |         int med = getNextLightest(x[3], x[4], x[5], x[i]);
      |             ^~~
scales.cpp:17:9: note: shadowed declaration is here
   17 |     int med = total - mn - mx;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...