# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091840 | MMihalev | Scales (IOI15_scales) | C++14 | 1 ms | 424 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<deque>
#include<stack>
using namespace std;
void init(int T)
{
/* ... */
}
deque<int>q;
void fr(int x,int num)
{
stack<int>s;
while(x--){s.push(q.front());q.pop_front();}
q.push_front(num);
while(s.size()){q.push_front(s.top());s.pop();}
}
void bk(int x,int num)
{
stack<int>s;
while(x--){s.push(q.back());q.pop_back();}
q.push_back(num);
while(s.size()){q.push_back(s.top());s.pop();}
}
void orderCoins()
{
int W[6];
int a=1;
int c=getNextLightest(2,3,4,1);
int b=2;
if(c==2)b=3;
int d=((4^a)^(b^c));
int mid=getMedian(a,b,c);
if(mid==a)
{
//b a c
int mid2=getMedian(a,b,d);
if(mid2==b)
{
q.push_back(d);q.push_back(b);q.push_back(a);q.push_back(c);
}
else if(mid2==d)
{
q.push_back(b);q.push_back(d);q.push_back(a);q.push_back(c);
}
else
{
q.push_back(b);q.push_back(a);q.push_back(c);q.push_back(d);
}
}
else if(mid==c)
{
//a c b
int mid2=getMedian(a,b,d);
if(mid2==a)
{
q.push_back(d);q.push_back(a);q.push_back(c);q.push_back(b);
}
else if(mid2==d)
{
q.push_back(a);q.push_back(c);q.push_back(d);q.push_back(b);
}
else
{
q.push_back(a);q.push_back(c);q.push_back(b);q.push_back(d);
}
}
else
{
//c b a
int lig=getLightest(a,b,d);
if(lig==b)
{
q.push_back(c);q.push_back(b);q.push_back(d);q.push_back(a);
}
else q.push_back(c);q.push_back(d);q.push_back(b);q.push_back(a);
}
for(int cur=5;cur<=6;cur++)
{
mid=getMedian(q[1],q[q.size()-2],cur);
if(mid==cur)
{
if(cur==5)fr(2,cur);
else
{
int mid2=getMedian(q[1],q[2],cur);
if(mid2==cur)fr(2,cur);
else fr(3,cur);
}
}
else if(mid==q[1])
{
int mid2=getMedian(q[0],q[1],cur);
if(mid2==cur)fr(1,cur);
else fr(0,cur);
}
else
{
int mid2=getMedian(q[q.size()-1],q[q.size()-2],cur);
if(mid2==cur)bk(1,cur);
else bk(0,cur);
}
}
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |