# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1077999 | mariza | Scales (IOI15_scales) | C++14 | 1 ms | 436 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;
typedef long long ll;
map<tuple<ll,ll,ll>,ll> m;
ll ask(ll a, ll b, ll c){
if(m.find({a,b,c})==m.end()) m[{a,b,c}]=getLightest(a,b,c);
return m[{a,b,c}];
}
void init(int T) {
}
void orderCoins() {
m.clear();
set<ll> x;
for(ll i=1; i<=6; i++){
x.insert(i);
}
int ans[6];
ll z=0;
for(ll i=0; i<3; i++){
set<ll> y;
for(ll j=1; j<=6; j++){
if(x.find(j)!=x.end()) y.insert(j);
}
while(y.size()>1){
if(y.size()==2) y.insert(z);
ll a=*y.begin(); y.erase(a);
ll b=*y.begin(); y.erase(b);
ll c=*y.begin(); y.erase(c);
// cout<<i<<" "<<y.size()<<" "<<z<<endl;
y.insert(ask(a,b,c));
if(a!=*y.begin()) z=a;
else z=b;
}
ans[i]=*y.begin();
x.erase(*y.begin());
}
ll a=*x.begin(); x.erase(a);
ll b=*x.begin(); x.erase(b);
ll c=*x.begin(); x.erase(c);
ans[3]=ask(a,b,c);
ans[4]=getMedian(a,b,c);
if(min(ans[3],ans[4])==b) ans[5]=a;
else if(max(ans[3],ans[4])==b) ans[5]=c;
else ans[5]=b;
answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |