# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
640368 | Benmath | Scales (IOI15_scales) | C++14 | 2 ms | 212 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;
int t1;
void init(int T) {
t1=T;
}
void orderCoins() {
int min1,mid1,max1,min2,mid2,max2;
vector<pair<int,int> >v;
min1=getLightest(1,2,3);
max1=getHeaviest(1,2,3);
mid1=6-min1-max1;
min2=getLightest(4,5,6);
max2=getHeaviest(4,5,6);
mid2=15-min2-max2;
v.push_back({min1,mid1});
v.push_back({mid1,max1});
v.push_back({min2,mid2});
v.push_back({mid2,max2});
int ro1=min1;
int ro2=max1;
int t1=0;
int c=getMedian(ro1,ro2,min2);
if(c==ro1){
v.push_back({min2,ro1});
}else if(c==ro2){
v.push_back({ro2,min2});
t1++;
}else{
if(ro1==min1){
int c1=getMedian(ro1,min2,mid1);
if(c1==min2){
v.push_back({ro1,min2});
v.push_back({min2,mid1});
}else{
v.push_back({mid1,min2});
v.push_back({min2,ro2});
}
ro1=mid1;
}else{
v.push_back({ro1,min2});
v.push_back({min2,ro2});
}
}
if(t1==0){
c=getMedian(ro1,ro2,mid2);
if(c==ro1){
v.push_back({mid2,ro1});
}else if(c==ro2){
v.push_back({ro2,mid2});
t1++;
}else{
if(ro1==min1){
int c1=getMedian(ro1,mid2,mid1);
if(c1==mid2){
v.push_back({ro1,mid2});
v.push_back({mid2,mid1});
}else{
v.push_back({mid1,mid2});
v.push_back({mid2,ro2});
}
ro1=mid1;
}else{
v.push_back({ro1,mid2});
v.push_back({mid2,ro2});
}
}
}
if(t1==0){
c=getMedian(ro1,ro2,max2);
if(c==ro1){
v.push_back({max2,ro1});
}else if(c==ro2){
v.push_back({ro2,max2});
t1++;
}else{
if(ro1==min1){
int c1=getMedian(ro1,max2,mid1);
if(c1==max2){
v.push_back({ro1,max2});
v.push_back({max2,mid1});
}else{
v.push_back({mid1,max2});
v.push_back({max2,ro2});
}
ro1=mid1;
}else{
v.push_back({ro1,max2});
v.push_back({max2,ro2});
}
}
}
/* ... */
int W[] = {1, 2, 3, 4, 5, 6};
int t2=0;
for(int i=0;i<v.size();i++){
int m1=-1;
int m2=-1;
for(int j=0;j<6;j++){
if(W[j]==v[i].first){
m1=j;
}
if(W[j]==v[i].second){
m2=j;
}
}
if(m1>m2){
t2++;
}
}
if(t2==0){
answer(W);
}
while(next_permutation(W,W+6)){
t2=0;
for(int i=0;i<v.size();i++){
int m1=-1;
int m2=-1;
for(int j=0;j<6;j++){
if(W[j]==v[i].first){
m1=j;
}
if(W[j]==v[i].second){
m2=j;
}
}
if(m1>m2){
t2++;
}
}
if(t2==0){
answer(W);
}
}
//answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |