# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134573 | StevenH | Scales (IOI15_scales) | C++14 | 2 ms | 380 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 <cstring>
#include <array>
using namespace std;
void init(int T) {
/* ... */
}
array<int,6> W;
void orderCoins() {
int s[10];
int a[4],b[4];
memset(s,0,sizeof(s));
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
a[1]=getLightest(1,2,4);
s[a[1]]=1;
a[3]=getHeaviest(1,2,4);
s[a[3]]=1;
if(s[1]==0)a[2]=1;
else if(s[2]==0)a[2]=2;
else if(s[4]==0)a[2]=4;
b[1]=getLightest(3,5,6);
s[b[1]]=1;
b[3]=getHeaviest(3,5,6);
s[b[3]]=1;
if(s[3]==0)b[2]=3;
else if(s[5]==0)b[2]=5;
else if(s[6]==0)b[2]=6;
int id1,id2;
//int w[6]={0,0,0,0,0,0},W=w;
int res=getMedian(a[1],a[2],b[1]);
if(res==a[1])id1=3;
else if(res==a[2])id1=1;
else if(res==b[1])id1=2;
res=getMedian(a[3],b[2],b[3]);
if(res==a[3])id2=3;
else if(res==b[2])id2=1;
else if(res==b[3])id2=2;
int ans[6];
if(id1==1 && id2==1)
{
int res=getMedian(a[2],b[1],a[3]);
if(res==a[3])array<int,6> w={1,2,4,3,5,6},W=w;
else if(res==b[1])array<int,6> w={1,2,3,4,5,6},W=w;
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
if(id1==1 && id2==2)
{
array<int,6> w={1,2,3,5,4,6},W=w;
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
if(id1==1 && id2==3)
{
array<int,6> w={1,2,3,5,6,4},W=w;
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
if(id1==2 && id2==1)
{
array<int,6> w={1,3,2,4,5,6},W=w;
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
if(id1==2 && id2==2)
{
res=getMedian(a[2],b[1],b[2]);
if(res==b[2])array<int,6> w={1,3,5,2,4,6},W=w;
else if(res==a[2])array<int,6> w={1,3,2,5,4,6},W=w;
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
if(id1==2 && id2==3)
{
res=getMedian(a[2],b[2],b[3]);
if(res==a[2])array<int,6> w={1,3,5,2,6,4},W=w;
else if(res==b[2])array<int,6> w={1,3,2,5,6,4},W=w;
else if(res==b[3])array<int,6> w={1,3,5,6,2,4},W=w;
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
if(id1==3 && id2==1)
{
array<int,6> w={3,1,2,4,5,6},W=w;
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
if(id1==3 && id2==2)
{
int k[6];
res=getMedian(a[1],a[2],b[2]);
if(res==a[1])array<int,6> w={3,5,1,2,4,6},W=w;
else if(res==a[2])array<int,6> w={3,1,2,5,4,6},W=w;
else if(res==b[2])array<int,6> w={3,1,5,2,4,6},W=w;
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
if(id1==3 && id2==3)
{
//res=getNextLightest(a[1],b[1],b[2],a[2]);
//if(res==b[2])array<int,6> w={3,1,2,5,6,4},W=w;
//else if(res==)
array<int,6> w={3,1,2,5,6,4},W=w;
//printf("%d %d %d %d %d %d %d\n",a[1],a[2],a[3],b[1],b[2],b[3],res);
for(int i=0;i<6;i++)
{
//printf("%d/",W[i]);
int res;
if(W[i]==1)res=a[1];
if(W[i]==2)res=a[2];
if(W[i]==3)res=a[3];
if(W[i]==4)res=b[1];
if(W[i]==5)res=b[2];
if(W[i]==6)res=b[3];
ans[i]=res;
}
}
answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |