Submission #802080

#TimeUsernameProblemLanguageResultExecution timeMemory
802080KhizriScales (IOI15_scales)C++17
45.45 / 100
1 ms304 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
void init(int T) {
    /* ... */
}

void orderCoins() {
    vector<int>vt={1,2,3,4,5,6};
    random_shuffle(vt.begin(),vt.end());
    int mx=getHeaviest(vt[0],vt[1],vt[2]);
    int mx2=getHeaviest(vt[3],vt[4],vt[5]);
    set<int>st{{1,2,3,4,5,6}};
    st.erase(mx);
    st.erase(mx2);
    int x=*st.begin();
    int largest=getHeaviest(mx,mx2,x);
    int mn=getLightest(vt[0],vt[1],vt[2]);
    int mn2=getLightest(vt[3],vt[4],vt[5]);
    int m=vt[0]+vt[1]+vt[2]-mx-mn;
    int m2=vt[3]+vt[4]+vt[5]-mx2-mn2;
    deque<int>l={mn,m,mx};
    deque<int>r={mn2,m2,mx2};
    vector<int>ans;
    while(l.size()&&r.size()){
        int a=l[0],b=r[0];
        if(a==largest){
            while(r.size()){
                ans.pb(r[0]);
                r.pop_front();
            }
            ans.pb(a);
            l.pop_front();
        }
        else if(b==largest){
            while(l.size()){
                ans.pb(l[0]);
                l.pop_front();
            }
            ans.pb(b);
            r.pop_front();
        }
        else{
            int x=getLightest(a,b,largest);
            ans.pb(x);
            if(x==a){
                l.pop_front();
            }
            else{
                r.pop_front();
            }
        }
    }
    while(l.size()){
        ans.pb(l[0]);
        l.pop_front();
    }
    while(r.size()){
        ans.pb(r[0]);
        r.pop_front();
    }
    int W[]={0,0,0,0,0,0};
    for(int i=0;i<ans.size();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) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:45:17: warning: declaration of 'x' shadows a previous local [-Wshadow]
   45 |             int x=getLightest(a,b,largest);
      |                 ^
scales.cpp:17:9: note: shadowed declaration is here
   17 |     int x=*st.begin();
      |         ^
scales.cpp:64:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...