#include "scales.h"
#include<bits/stdc++.h>
using namespace std ;
int Te ;
void init(int T) {
Te = T ;
/* ... */
}
void orderCoins() {
int W[6] = {0,0,0,0,0,0} ;
int it = 0 ;
int cnt = 0 ;
vector<int> perm[2] ;
perm[0] = { getLightest(1 , 2 , 3) , getMedian(1 , 2, 3) } ;
perm[0].push_back(6 - perm[0][0] - perm[0][1]) ;
perm[1] = { getLightest(4 , 5 , 6) , getMedian(4 , 5, 6) } ;
perm[1].push_back(15 - perm[1][0] - perm[1][1]) ;
int answer1 = getNextLightest(perm[0][0] , perm[0][1] , perm[1][1] , perm[1][0] ) ;
if(answer1 == perm[1][1]){
int ele = getMedian(perm[0][0], perm[0][1], perm[1][0]) ;
if(ele == perm[0][0]){
W[0] = perm[1][0] ;
W[1] = perm[1][1] ;
int mn1 = getLightest(perm[0][0] , perm[0][1] , perm[1][2]) ;
if(mn1 == perm[0][0]){
W[2] = perm[0][0] ;
int md = getMedian(perm[0][1] , perm[0][2] , perm[1][2]) ;
if(md == perm[0][1]){
W[3] = perm[1][2] ;
W[4] = perm[0][1] ;
W[5] = perm[0][2] ;
}else if( md == perm[0][2]){
W[3] = perm[0][1] ;
W[4] = perm[0][2] ;
W[5] = perm[1][2] ;
}else{
W[3] = perm[0][1] ;
W[4] = perm[1][2] ;
W[5] = perm[0][2] ;
}
}else{
W[2] = mn1 ;
W[3] = perm[0][0] ;
W[4] = perm[0][1] ;
W[5] = perm[0][2] ;
}
}else if(perm[0][1] == ele){
W[0] = perm[0][0] ;
W[1] = perm[0][1] ;
int mn1 = getLightest(perm[0][2] , perm[1][0] , perm[1][1]) ;
W[2] = mn1 ;
if(mn1 == perm[0][2]){
W[3] = perm[1][0] ;
W[4] = perm[1][1] ;
W[5] = perm[1][2] ;
}else{
int md1 = getMedian(perm[0][2] , perm[1][1], perm[1][2]) ;
if(md1 == perm[0][2]){
W[3] = perm[1][1] ;
W[4] = md1 ;
W[5] = perm[1][2] ;
}else if(perm[1][1] == md1){
W[3] = perm[0][2] ;
W[4] = md1 ;
W[5] = perm[1][2] ;
}else{
W[3] = perm[1][1] ;
W[4] = md1 ;
W[5] = perm[0][2] ;
}
}
}else if(perm[1][0] == ele){
W[0] = perm[0][0] ;
W[1] = perm[1][0] ;
int gmd = getMedian(perm[0][2] , perm[1][1] , perm[1][2]) ;
if(gmd == perm[0][2]){
W[5] = perm[1][2] ;
int gmd2 = getMedian(perm[0][1] , perm[0][2] , perm[1][1]) ;
if(gmd2 == perm[0][1]){
W[2] = perm[1][1] ;
W[3] = perm[0][1] ;
W[4] = perm[0][2] ;
}else if(gmd2 == perm[0][2]){
W[2] = perm[0][1] ;
W[3] = perm[0][2] ;
W[4] = perm[1][1] ;
}else{
W[2] = perm[0][1] ;
W[3] = perm[1][1] ;
W[4] = perm[0][2] ;
}
}else if(gmd == perm[1][2]){
W[5] = perm[0][2] ;
int gmd2 = getMedian(perm[0][1] , perm[1][2] , perm[1][1]) ;
if(gmd2 == perm[0][1]){
W[2] = perm[1][1] ;
W[3] = perm[0][1] ;
W[4] = perm[1][2] ;
}else if(gmd2 == perm[1][1]){
W[2] = perm[0][1] ;
W[3] = perm[1][1] ;
W[4] = perm[1][2] ;
}else{
W[2] = perm[1][1] ;
W[3] = perm[1][2] ;
W[4] = perm[0][1] ;
}
}else{
W[2] = perm[0][1] ;
W[3] = perm[0][2] ;
W[4] = perm[1][1] ;
W[5] = perm[1][2] ;
}
}
}
else if(answer1 == perm[0][1]){
W[0] = perm[0][0] ;
W[1] = perm[1][0] ;
W[2] = perm[0][1] ;
int md = getMedian(perm[0][2] , perm[1][1], perm[1][2]) ;
W[4] = md ;
if(md == perm[0][2]){
W[3] = perm[1][1] ;
W[5] = perm[1][2] ;
}else if(md == perm[1][1]){
W[3] = perm[0][2] ;
W[5] = perm[1][2] ;
}else{
W[3] = perm[1][1] ;
W[5] = perm[0][2] ;
}
}else if(answer1 == perm[0][0]){
W[0] = perm[1][0] ;
W[1] = perm[0][0] ;
int gmd = getMedian(perm[0][2] , perm[1][1] , perm[1][2]) ;
if(gmd == perm[0][2]){
W[5] = perm[1][2] ;
int gmd2 = getMedian(perm[0][1] , perm[0][2] , perm[1][1]) ;
if(gmd2 == perm[0][1]){
W[2] = perm[1][1] ;
W[3] = perm[0][1] ;
W[4] = perm[0][2] ;
}else if(gmd2 == perm[0][2]){
W[2] = perm[0][1] ;
W[3] = perm[0][2] ;
W[4] = perm[1][1] ;
}else{
W[2] = perm[0][1] ;
W[3] = perm[1][1] ;
W[4] = perm[0][2] ;
}
}else if(gmd == perm[1][2]){
W[5] = perm[0][2] ;
int gmd2 = getMedian(perm[0][1] , perm[1][2] , perm[1][1]) ;
if(gmd2 == perm[0][1]){
W[2] = perm[1][1] ;
W[3] = perm[0][1] ;
W[4] = perm[1][2] ;
}else if(gmd2 == perm[1][1]){
W[2] = perm[0][1] ;
W[3] = perm[1][1] ;
W[4] = perm[1][2] ;
}else{
W[2] = perm[1][1] ;
W[3] = perm[1][2] ;
W[4] = perm[0][1] ;
}
}else{
W[2] = perm[0][1] ;
W[3] = perm[0][2] ;
W[4] = perm[1][1] ;
W[5] = perm[1][2] ;
}
}
answer(W);
}
Compilation message
scales.cpp: In function 'void orderCoins()':
scales.cpp:17:13: warning: unused variable 'it' [-Wunused-variable]
17 | int it = 0 ;
| ^~
scales.cpp:18:13: warning: unused variable 'cnt' [-Wunused-variable]
18 | int cnt = 0 ;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
7 |
Partially correct |
1 ms |
384 KB |
Output is partially correct |
8 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
10 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
11 |
Partially correct |
0 ms |
256 KB |
Output is partially correct |
12 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
13 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
14 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
15 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
16 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
17 |
Partially correct |
1 ms |
384 KB |
Output is partially correct |
18 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
19 |
Partially correct |
1 ms |
384 KB |
Output is partially correct |
20 |
Partially correct |
1 ms |
384 KB |
Output is partially correct |
21 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
22 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
23 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
24 |
Partially correct |
1 ms |
384 KB |
Output is partially correct |
25 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
26 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
27 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
28 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
29 |
Partially correct |
0 ms |
256 KB |
Output is partially correct |
30 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
31 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
32 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
33 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
34 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
35 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
36 |
Partially correct |
1 ms |
384 KB |
Output is partially correct |
37 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
38 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
39 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
40 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |