Submission #596810

#TimeUsernameProblemLanguageResultExecution timeMemory
596810chirathnirodhaScales (IOI15_scales)C++17
56.08 / 100
1 ms340 KiB
#include "scales.h" #include<bits/stdc++.h> using namespace std; #define PB push_back void init(int T) { /* ... */ } void orderCoins() { /* ... */ int W[] = {1, 2, 3, 4, 5, 6}; vector<int> v1,v2; vector<int> ans; bool got[7];memset(got,false,sizeof(got)); v1.PB(getLightest(1,2,3)); v1.PB(getMedian(1,2,3)); got[v1[0]]=true;got[v1[1]]=true; for(int i=1;i<=3;i++)if(got[i]==false)v1.PB(i); v2.PB(getLightest(4,5,6)); v2.PB(getMedian(4,5,6)); got[v2[0]]=true;got[v2[1]]=true; for(int i=4;i<=6;i++)if(got[i]==false)v2.PB(i); while(true){ if(v1.size()==0 || v2.size()==0){ while(!v1.empty()){ ans.PB(v1.back()); v1.pop_back(); } while(!v2.empty()){ ans.PB(v2.back()); v2.pop_back(); } break; } int x1=-1,x2=-1,y1=-1,y2=-1,z; x1=v1.back();y1=v2.back(); if(v1.size()>1)x2=v1[v1.size()-2]; if(v2.size()>1)y2=v2[v2.size()-2]; if(x2==-1 && y2==-1){ z=getMedian(x1,y1,ans[0]); if(z==x1){ans.PB(x1);ans.PB(y1);} else {ans.PB(y1);ans.PB(x1);} break; } if(x2!=-1){ z=getMedian(x1,x2,y1); if(z==x1){ans.PB(y1);v2.pop_back();} else if(z==y1){ ans.PB(x1);v1.pop_back(); ans.PB(y1);v2.pop_back(); } else { ans.PB(x1);v1.pop_back(); ans.PB(x2);v1.pop_back(); } } else{ z=getMedian(x1,y1,y2); if(z==x1){ ans.PB(y1);v2.pop_back(); ans.PB(x1);v1.pop_back(); } else if(z==y1){ans.PB(x1);v1.pop_back();} else { ans.PB(y1);v2.pop_back(); ans.PB(y2);v2.pop_back(); } } } reverse(ans.begin(),ans.end()); 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...