# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
765675 | boyliguanhan | Scales (IOI15_scales) | C++17 | 1 ms | 244 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 <algorithm>
#define X std::swap(w1,w2),std::swap(p1,p2)
void init(int T) {}
void orderCoins() {
int w[] = {0,0,0,0,0,0}, w1[] = {getLightest(1,2,3),getMedian(1,2,3),0}, w2[] = {getLightest(4,5,6),getMedian(4,5,6),0}, i;
w1[2] = 6-w1[0]-w1[1], w2[2] = 15-w2[0]-w2[1];
w[0] = getLightest(w1[0],w1[1],w2[0]);
int p1 = w[0]==w1[0], p2 = !p1;
if(p2) X;
while(p1<3&&p2<3) {
int x = getNextLightest(w1[0],w1[1],w1[2],w2[p2]);
if(x==w1[0]) {
while(p1<3)
w[p1+p2] = w1[p1], p1++;
while(p2<3)
w[p1+p2] = w2[p2], p2++;
break;
}
while(w1[p1]!=x)
w[p1+p2] = w1[p1], p1++;
w[p1+p2] = w2[p2], p2++;
X;
}
while(p1<3)
w[p1+p2] = w1[p1], p1++;
while(p2<3)
w[p1+p2] = w2[p2], p2++;
answer(w);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |