# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
290824 | kshitij_sodani | Scales (IOI15_scales) | C++14 | 1 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
void init(int T) {
/* ... */
}
void orderCoins() {
/* ... */
vector<int> cur;
int aa=1;
int bb=2;
int cc=3;
cur.pb(getLightest(aa,bb,cc));
cur.pb(getMedian(aa,bb,cc));
for(int i=1;i<=3;i++){
if(i!=cur[0] and i!=cur[1]){
cur.pb(i);
}
}
for(int i=4;i<=6;i++){
vector<pair<int,int>> ss;
if(i==4){
ss.pb({0,1});
ss.pb({1,2});
}
else if(i==5){
ss.pb({0,1});
ss.pb({2,3});
}
else{
int xx=getMedian(cur[1],cur[3],i);
if(xx==cur[1]){
ss.pb({0,1});
}
else if(xx==i){
ss.pb({2,3});
}
else{
ss.pb({3,4});
}
for(auto j:ss){
int x=getMedian(cur[j.a],cur[j.b],i);
if(x==i){
int jj=j.a+1;
vector<int> cur2;
for(int ii=0;ii<jj;ii++){
cur2.pb(cur[ii]);
}
cur2.pb(i);
for(int ii=jj;ii<cur.size();ii++){
cur2.pb(cur[ii]);
}
cur=cur2;
break;
}
else if(x==cur[j.a]){
int jj=j.a;
vector<int> cur2;
for(int ii=0;ii<jj;ii++){
cur2.pb(cur[ii]);
}
cur2.pb(i);
for(int ii=jj;ii<cur.size();ii++){
cur2.pb(cur[ii]);
}
cur=cur2;
break;
}
else{
int jj=j.a+2;
vector<int> cur2;
for(int ii=0;ii<jj;ii++){
cur2.pb(cur[ii]);
}
cur2.pb(i);
for(int ii=jj;ii<cur.size();ii++){
cur2.pb(cur[ii]);
}
cur=cur2;
break;
}
}
continue;
}
int st=0;
for(auto j:ss){
int x=getMedian(cur[j.a],cur[j.b],i);
if(x==i){
st=1;
int jj=j.a+1;
vector<int> cur2;
for(int ii=0;ii<jj;ii++){
cur2.pb(cur[ii]);
}
cur2.pb(i);
for(int ii=jj;ii<cur.size();ii++){
cur2.pb(cur[ii]);
}
cur=cur2;
break;
}
else if(x==cur[j.a]){
st=1;
int jj=j.a;
vector<int> cur2;
for(int ii=0;ii<jj;ii++){
cur2.pb(cur[ii]);
}
cur2.pb(i);
for(int ii=jj;ii<cur.size();ii++){
cur2.pb(cur[ii]);
}
cur=cur2;
break;
}
}
if(st==0){
cur.pb(i);
}
}
int ww[6];
for(int i=0;i<6;i++){
ww[i]=cur[i];
}
answer(ww);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |