# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133845 | Runtime_error_ | Scales (IOI15_scales) | C++14 | 3 ms | 396 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;
int larger[8][8],tmp[] = {1,2,3},tmp2[] = {4,5,6};
void init(int T) {
memset(larger,-1,sizeof(larger));
}
void modify(int x,int y){
larger[x][y] = 0;
larger[y][x] = 1;
}
void modify(int a,int b,int c){
larger[c][b] = larger[c][a] = 1;
larger[b][c] = larger[a][c] = 0;
larger[b][a] = 1 , larger[a][b] = 0;
}
void ask(int x,int y,int z){
int a,b,c;
a = getLightest(x,y,z);
c = getHeaviest(x,y,z);
if( (a == x && c == z) || (c == x && a == z))
b = y;
else if( (a == y && c == z) || (a == z && c == y) )
b = x;
else
b = z;
modify(a,b,c);
}
bool cmp(int x,int y){
return larger[y][x];
}
void loop(int cur){
int md = getMedian(tmp[0],tmp[2],cur);
if(md == tmp[0])
modify(cur,tmp[0],tmp[2]);
else if(md == tmp[2])
modify(tmp[0],tmp[2],cur);
else
modify(tmp[0],cur,tmp[2]);
if(!larger[tmp[2]][cur]){
for(int i=0;i<3;i++)
modify(tmp[i],cur);
return ;
}
int x = getNextLightest(1,2,3,cur) , i;
for(i=0;i<3;i++){
if(tmp[i] == x)
break;
modify(tmp[i],cur);
}
for(;i<3;i++)
modify(cur,tmp[i]);
}
void orderCoins() {
int W [] = {1,2,3,4,5,6};
ask(1,2,3);
ask(4,5,6);
sort(tmp,tmp+3,cmp);
sort(tmp2,tmp2+3,cmp);
for(int i=4;i<=6;i++)
loop(i);
sort(W,W+6,cmp);
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |