# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55480 | alenam0161 | Scales (IOI15_scales) | C++17 | 3 ms | 636 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;
vector<vector<int> > comb;
vector<vector<int> > Q;
struct node{
vector<vector<int> > q_and_ans;
vector<int> good;
int Ok=true;
int nxt;
int sz[4];
void init(){
q_and_ans.resize(0);
good.resize(0);
}
};
vector<node> cmp;
vector<int> ps;
int get_ans(vector<int> rng,vector<int> q){
ps.resize(6,0);
for(int i=0;i<6;++i)ps[rng[i]]=i;
int a1=ps[q[1]];
int a2=ps[q[2]];
int a3=ps[q[3]];
int a4=ps[q[4]];
vector<pair<int,int> > qw;
qw.push_back(make_pair(ps[q[1]],q[1]));
qw.push_back(make_pair(ps[q[2]],q[2]));
qw.push_back(make_pair(ps[q[3]],q[3]));
sort(qw.begin(),qw.end());
if(q[0]==0)return qw[0].second;
if(q[0]==1)return qw[1].second;
if(q[0]==2)return qw[2].second;
if(q[0]==3){
if(ps[q[4]]<qw[2].first&&ps[q[4]]>qw[1].first)return qw[2].second;
if(ps[q[4]]<qw[1].first&&ps[q[4]]>qw[0].first)return qw[1].second;
return qw[0].second;
}
}
int y=0;
void rec(int ps,int lv){
if(lv==6){
int hw=0;
cmp[ps].Ok=false;
for(int i=0;i<comb.size();++i){
bool ok=true;
for(int d=0;d<cmp[ps].q_and_ans.size();++d){
vector<int> qw=cmp[ps].q_and_ans[d];qw.pop_back();
if(cmp[ps].q_and_ans[d][5]!=get_ans(comb[i],qw)){
ok=false;break;
}
}
if(ok){
cmp[ps].good=comb[i];hw++;
}
}
if(hw!=1)cmp[ps].Ok=false;
return;
}
else{
for(int i=0;i<Q.size();++i){
vector<int> w=Q[i];w.push_back(0);
cmp.push_back(node());
int s1=cmp.size()-1;
cmp[s1].q_and_ans=cmp[ps].q_and_ans;
w[5]=w[1];
cmp[s1].q_and_ans.push_back(w);
rec(s1,lv+1);
bool o1=cmp[s1].Ok;
cmp.push_back(node());
int s2=cmp.size()-1;
cmp[s2].q_and_ans=cmp[ps].q_and_ans;
w[5]=w[2];
cmp[s2].q_and_ans.push_back(w);
rec(s2,lv+1);
bool o2=cmp[s2].Ok;
cmp.push_back(node());
int s3=cmp.size()-1;
cmp[s3].q_and_ans=cmp[ps].q_and_ans;
w[5]=w[3];
cmp[s3].q_and_ans.push_back(w);
rec(s3,lv+1);
bool o3=cmp[s3].Ok;
if(o1==true&&o2==true&&o3==true){
cmp[ps].Ok=true;
cmp[ps].nxt=i;
cmp[ps].sz[0]=s1;
cmp[ps].sz[1]=s2;
cmp[ps].sz[2]=s3;
goto en;
}
}
}
en:
y++;
}
void init(int T) {
}
void orderCoins() {
int W[6];
for(int i=0;i<6;++i){
W[i]=i;
}
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |