# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261541 | amiratou | Scales (IOI15_scales) | C++14 | 1 ms | 384 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;
#define pb push_back
vector<int> g[5]={{5,4,3,2,1},{3,2,1,4,5},{2,3,1,4,5},{3,4,2,5,1},{3,5,2,1,4}};
map<vector<int>,vector<int> > code;
vector<int> vec={1,2,3,4,5};
int pos[5];
int nxt(int a,int b,int c,int d){
vector<int> GG={a,b,c};
sort(GG.begin(),GG.end());
a=GG[0],b=GG[1],c=GG[2];
if(d>c)return vec[a];
if(d<a)return vec[a];
if(d<b)return vec[b];
if(d<c)return vec[c];
}
int light(int a,int b,int c){
return vec[min(a,min(b,c))];
}
int mid(int a,int b,int c){
vector<int> GG={a,b,c};
sort(GG.begin(),GG.end());
return vec[GG[1]];
}
int heavy(int a,int b,int c){
return vec[max(a,max(b,c))];
}
void init(int T) {
do{
for (int i = 0; i < 5; ++i)
pos[vec[i]]=i;
vector<int> id;
id.pb(light(pos[g[0][0]],pos[g[0][1]],pos[g[0][2]]));
id.pb(heavy(pos[g[1][0]],pos[g[1][1]],pos[g[1][2]]));
id.pb(nxt(pos[g[2][0]],pos[g[2][1]],pos[g[2][2]],pos[g[2][3]]));
id.pb(nxt(pos[g[3][0]],pos[g[3][1]],pos[g[3][2]],pos[g[3][3]]));
id.pb(nxt(pos[g[4][0]],pos[g[4][1]],pos[g[4][2]],pos[g[4][3]]));
code[id]=vec;
}while(next_permutation(vec.begin(),vec.end()));
}
void orderCoins() {
vector<int> ans;
int a,b;
vector<int> ID;
ID.pb(getLightest(g[0][0],g[0][1],g[0][2]));
ID.pb(getHeaviest(g[1][0],g[1][1],g[1][2]));
ID.pb(getNextLightest(g[2][0],g[2][1],g[2][2],g[2][3]));
ID.pb(getNextLightest(g[3][0],g[3][1],g[3][2],g[3][3]));
ID.pb(getNextLightest(g[4][0],g[4][1],g[4][2],g[4][3]));
ans=code[ID];
a=getNextLightest(ans[0],ans[2],ans[4],6);
if(a==ans[2]){
b=getMedian(6,ans[1],ans[2]);
if(b==6)ans.insert(ans.begin()+2,6);
else ans.insert(ans.begin()+1,6);
}
else if(a==ans[4]){
b=getMedian(6,ans[3],ans[4]);
if(b==6)ans.insert(ans.begin()+4,6);
else ans.insert(ans.begin()+3,6);
}
else{
b=getLightest(6,ans[0],ans[1]);
if(b==6)ans.insert(ans.begin(),6);
else ans.pb(6);
}
int W[6];
for (int i = 0; i < 6; ++i)
W[i]=ans[i];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |