# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
16551 | gs13068 | Scales (IOI15_scales) | C++98 | 0 ms | 1128 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 <cstdio>
#include <algorithm>
void init(int T){}
int p[777];
int t[7];
int testMed(int a,int b,int c)
{
int i,j,k,r=0;
for(i=0;i<720;i++)if(p[i])
{
for(j=1;j<=6;j++)t[j]=j;
k=i;
for(j=1;j<=6;j++)
{
std::swap(t[j],t[k%j+1]);
k/=j;
}
if((t[a]<t[b]&&t[b]<t[c])||(t[a]>t[b]&&t[b]>t[c]))r++;
}
return r;
}
void orderCoins()
{
int i,j,k,a,b,c,r=0;
a=getLightest(1,2,3);
b=getNextLightest(4,5,6,a);
for(i=0;i<720;i++)
{
for(j=1;j<=6;j++)t[j]=j;
k=i;
for(j=1;j<=6;j++)
{
std::swap(t[j],t[k%j+1]);
k/=j;
}
p[i]=0;
k=0;
for(j=1;j<=3;j++)if(!k||t[j]<t[k])k=j;
if(k!=a)continue;
k=0;
for(j=4;j<=6;j++)if(t[j]>t[a]&&(!k||t[j]<t[k]))k=j;
if(!k)for(j=4;j<=6;j++)if(!k||t[j]<t[k])k=j;
if(k!=b)continue;
p[i]=1;
r++;
}
printf("%d %d\n",a,b);
for(;r>1;)
{
for(i=1;i<=6;i++)
{
for(j=1;j<i;j++)
{
for(k=1;k<j;k++)if(testMed(i,j,k)<=(r+2)/3&&testMed(j,k,i)<=(r+2)/3&&testMed(k,i,j)<=(r+2)/3)printf("%d %d %d\n",i,j,k);
if(k<j)break;
}
if(j<i)break;
}
if(r==80)i=2,j=5,k=6;
printf("!!!! %d %d %d\n",testMed(i,j,k),testMed(j,k,i),testMed(k,i,j));
b=getMedian(i,j,k);
if(b==i)a=j,c=k;
if(b==j)a=i,c=k;
if(b==k)a=i,c=j;
r=0;
for(i=0;i<720;i++)if(p[i])
{
for(j=1;j<=6;j++)t[j]=j;
k=i;
for(j=1;j<=6;j++)
{
std::swap(t[j],t[k%j+1]);
k/=j;
}
p[i]=0;
if((t[a]<t[b]&&t[b]<t[c])||(t[a]>t[b]&&t[b]>t[c]))
{
p[i]=1;
r++;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |