Submission #404682

#TimeUsernameProblemLanguageResultExecution timeMemory
404682DaktoScales (IOI15_scales)C++17
0 / 100
1 ms332 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;

void init(int T) {
}

bool contains(vector<int>& v, int x){
    return find(v.begin(),v.end(), x)!=v.end();
}

vector<int> addany(vector<int> s, vector<int> p){
    set<int> st(begin(s),end(s));
    for(auto i:p){
        st.insert(i);
        if(st.size()>=3) break;
    }
    return vector<int>(st.begin(),st.end());
}

void orderCoins() {
    vector<int> res,p={1,2,3,4,5,6};
    int m1=getLightest(1,2,3);
    int m2=getLightest(4,5,6);
    auto a=addany({m1,m2},p);
    int m=getLightest(a[0],a[1],a[2]);
    res.push_back(m);
    p.erase(find(p.begin(),p.end(),m));


    if(m==m1){
        int r=getLightest(p[0],p[1],m2);
        res.push_back(r);
        p.erase(find(p.begin(),p.end(),r));
    }
    else{
        int r=getLightest(p[3],p[4],m1);
        res.push_back(r);
        p.erase(find(p.begin(),p.end(),r));
    }


    int x1=getLightest(p[0],p[1],p[2]);
    int x2=getLightest(p[1],p[2],p[3]);
    if(x1==x2){
        res.push_back(x1);
        p.erase(find(p.begin(),p.end(),x2));
        auto x=getHeaviest(p[0],p[1],res[2]);
        auto y=getMedian(p[0],p[1],res[2]);
        p.erase(find(p.begin(),p.end(),x));
        p.erase(find(p.begin(),p.end(),y));
        res.push_back(p[0]);
        res.push_back(y);
        res.push_back(x);
    }
    else{
        auto a=addany({x1,x2},p);
        int r=getLightest(a[0],a[1],a[2]);
        res.push_back(r);
        p.erase(find(p.begin(),p.end(),r));
        if(r==x1){
            res.push_back(x2);
            p.erase(find(p.begin(),p.end(),x2));
        }
        else{
            res.push_back(x1);
            p.erase(find(p.begin(),p.end(),x1));
        }
        r=getHeaviest(p[0],p[1],res[0]);
        p.erase(find(p.begin(),p.end(),r));
        res.push_back(p[0]);
        res.push_back(r);
    }



    int out[6];
    for(int i=0; i<6; i++) out[i]=res[i];
    answer(out);
}

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) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:57:14: warning: declaration of 'a' shadows a previous local [-Wshadow]
   57 |         auto a=addany({x1,x2},p);
      |              ^
scales.cpp:25:10: note: shadowed declaration is here
   25 |     auto a=addany({m1,m2},p);
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...