# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73066 | MKopchev | Scales (IOI15_scales) | C++14 | 4 ms | 676 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<bits/stdc++.h>
#include "scales.h"
using namespace std;
vector< vector<int> > possible,help;
vector<int> all;
void init(int T)
{
srand(time(0));
for(int i=0;i<6;i++)
all.push_back(i+1);
}
int big(int a1,int a2,int a3)
{
return (a1>a2)+(a1>a3);
}
void orderCoins()
{
possible={};
help={};
do
{
possible.push_back(all);
}
while(next_permutation(all.begin(),all.end()));
while(possible.size()>1)
{
int a=rand()%6,b=rand()%6,c=rand()%6;
if(a==b||b==c||c==a)continue;
int which=rand()%3;
if(which==0)
{
int ans=getHeaviest(a+1,b+1,c+1);
ans--;
help={};
for(auto k:possible)
{
if(ans==a&&big(k[a],k[b],k[c])==2)help.push_back(k);
if(ans==b&&big(k[b],k[c],k[a])==2)help.push_back(k);
if(ans==c&&big(k[c],k[a],k[b])==2)help.push_back(k);
}
possible=help;
}
else if(which==2)
{
int ans=getLightest(a+1,b+1,c+1);
ans--;
help={};
for(auto k:possible)
{
if(ans==a&&big(k[a],k[b],k[c])==0)help.push_back(k);
if(ans==b&&big(k[b],k[c],k[a])==0)help.push_back(k);
if(ans==c&&big(k[c],k[a],k[b])==0)help.push_back(k);
}
possible=help;
}
else
{
int ans=getMedian(a+1,b+1,c+1);
ans--;
help={};
for(auto k:possible)
{
if(ans==a&&big(k[a],k[b],k[c])==1)help.push_back(k);
if(ans==b&&big(k[b],k[c],k[a])==1)help.push_back(k);
if(ans==c&&big(k[c],k[a],k[b])==1)help.push_back(k);
}
possible=help;
}
}
assert(possible.size()==1);
int W[6]={possible[0][0],possible[0][1],possible[0][2],possible[0][3],possible[0][4],possible[0][5]};
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |