Submission #668511

#TimeUsernameProblemLanguageResultExecution timeMemory
668511victor_gaoScales (IOI15_scales)C++17
55.56 / 100
1 ms212 KiB
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;

void init(int T) {
    /* ... */
}

deque<int>solve(int ql,int qr){
    int mn=getLightest(ql,ql+1,qr);
    int mid=getMedian(ql,ql+1,qr);
    deque<int>ans;
    ans.push_back(mn); ans.push_back(mid);
    for (int i=ql;i<=qr;i++)
        if (i!=mn&&i!=mid)
            ans.push_back(i);
    return ans;
}

void orderCoins() {
    /* ... */
    int W[] = {1, 2, 3, 4, 5, 6};
    deque<int>l,r,ans;
    l=solve(1,3);
    r=solve(4,6);
    int p1=0,p2=0;
    for (p1=0;p1<3;p1++){
        if (p1+p2>=3) break;
        while (p1+p2<3){
            int q1=l[p1],q2,q3;
            if (p1+1<3) q2=l[p1+1],q3=r[p2];
            else q2=r[p2+1],q3=r[p2];
            int mn=getLightest(q1,q2,q3);
            if (mn==q1){
                ans.push_back(q1);
                break;
            }
            else {
                ans.push_back(q3);
                p2++;
            }
        }
        if (p1+p2>=3) break;
    }
    vector<int>remain;
    if (p1>=3){
        for (;p2<3;p2++)
            ans.push_back(r[p2]);
    }
    else if (p2>=3){
        for (;p1<3;p1++)
            ans.push_back(l[p1]);
    }
    else {
        int q1=l[p1],q3=r[p2],q2;
        if (p1+1<3){
            q2=l[p1+1];
            int mid=getMedian(q1,q2,q3);
            if (mid==q1){
                ans.push_back(q3);
                ans.push_back(q1);
                ans.push_back(q2);
            }
            else if (mid==q3){
                ans.push_back(q1);
                ans.push_back(q3);
                ans.push_back(q2);
            }
            else {
                ans.push_back(q1);
                ans.push_back(q2);
                ans.push_back(q3);
            }
        } 
        else {
            q2=r[p2+1];
            int mid=getMedian(q1,q2,q3);
            if (mid==q1){
                ans.push_back(q3);
                ans.push_back(q1);
                ans.push_back(q2);
            }
            else if (mid==q3){
                ans.push_back(q1);
                ans.push_back(q3);
                ans.push_back(q2);
            }
            else {
                ans.push_back(q3);
                ans.push_back(q2);
                ans.push_back(q1);
            }
        }
    }
    for (int i=0;i<6;i++)
        W[i]=ans[i];
    answer(W);
}

Compilation message (stderr)

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