Submission #1034312

#TimeUsernameProblemLanguageResultExecution timeMemory
1034312vjudge1Scales (IOI15_scales)C++17
55.56 / 100
1 ms440 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; void init(int T) { /* ... */ } int ans[6]; void orderCoins() { deque<int>g1{1,2,3},g2{4,5,6}; int min1=getLightest(1,2,3); for(int i=0;i<3;i++){ if(g1[i]==min1)swap(g1[i],g1[0]); } int min2=getLightest(4,5,6); for(int i=0;i<3;i++){ if(g2[i]==min2)swap(g2[i],g2[0]); } ans[0]=getLightest(g1[0],g2[0],g1[1]); int ind=1; if(g1[0]==ans[0])g1.pop_front(); else g2.pop_front(); while(g1.size()||g2.size()){ if(g2.size()<g1.size())swap(g1,g2); if(g2.size()==3){ if(!g1.size()){ ans[ind++]=g2.front(); g2.pop_front(); }else{ vector<int>toask; for(int i:g1)toask.push_back(i); for(int i=0;i<3&&toask.size()<3;i++){ toask.push_back(g2[i]); } int mini=getLightest(toask[0],toask[1],toask[2]); ans[ind++]=mini; if(mini==g1.front())g1.pop_front(); else if(mini==g1.back())g1.pop_back(); else g2.pop_front(); } }else if(g1.size()+g2.size()==4){ int mini=getLightest(g1[0],g1[1],g2[0]); bool b=mini!=g2[0]; if(b&&mini==g1[1])swap(g1[0],g1[1]); int minmin=getLightest(mini,mini==g1[0]?g1[1]:g1[0],g2[1]); ans[ind++]=minmin; if(b&&minmin!=mini)ans[ind++]=mini; for(int i=0;i<ind;i++){ if(g1[0]==ans[i]){ g1.pop_front(); break; } } for(int i=0;i<ind;i++){ if(g1[1]==ans[i]){ g1.pop_back(); break; } } for(int i=0;i<ind;i++){ if(g2[0]==ans[i]){ g2.pop_front(); break; } } for(int i=0;i<ind;i++){ if(g2[1]==ans[i]){ g2.pop_back(); break; } } }else if(g1.size()+g2.size()==3){ int mini=getLightest(g1[0],g2[0],g2[1]); ans[ind++]=mini; if(mini==g1[0])g1.clear(); if(mini==g2[0])g2.pop_front(); if(mini==g2[1])g2.pop_back(); }else{ vector<int>toask{ans[0]}; for(int i:g1)toask.push_back(i); for(int i:g2)toask.push_back(i); int maxi=getHeaviest(toask[0],toask[1],toask[2]); ans[ind++]=maxi==toask[1]?toask[2]:toask[1]; ans[ind++]=maxi; break; } } answer(ans); }

Compilation message (stderr)

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