#include "scales.h"
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
struct Query {
int type;
int a, b, c, d;
int res;
Query (int _type, int _a, int _b, int _c, int _d, int _res){
type = _type;
a = _a;
b = _b;
c = _c;
d = _d;
res = _res;
}
};
vector<Query> Asked;
int AskMin(int a, int b, int c){
int res = getLightest(a, b, c);
Query nw(0, a, b, c, -1, res);
Asked.push_back(nw);
return res;
}
int AskMax(int a, int b, int c){
int res = getHeaviest(a, b, c);
Query nw(1, a, b, c, -1, res);
Asked.push_back(nw);
return res;
}
int AskMedian(int a, int b, int c){
int res = getMedian(a, b, c);
Query nw(2, a, b, c, -1, res);
Asked.push_back(nw);
return res;
}
int AskNext(int a, int b, int c, int d){
int res = getNextLightest(a, b, c, d);
Query nw(3, a, b, c, d, res);
Asked.push_back(nw);
return res;
}
int Next(int a, int b, int c, int d){
vector<int> Arr = {a, b, c};
sort(all(Arr));
auto it = lower_bound(all(Arr), d);
if(it == Arr.end()) return Arr[0];
return *it;
}
void Solve(){
vector<int> per(7);
int W[] = {-1, -1, -1, -1, -1, -1};
iota(per.begin(), per.end(), 0);
int mn, mx, sm;
do {
bool flg = true;
for(auto X : Asked){
mn = min({per[X.a], per[X.b], per[X.c]});
mx = max({per[X.a], per[X.b], per[X.c]});
sm = per[X.a] + per[X.b] + per[X.c];
if(X.type == 0)
flg &= (per[X.res] == mn);
if(X.type == 1)
flg &= (per[X.res] == mx);
if(X.type == 2)
flg &= (per[X.res] == sm - mn - mx);
if(X.type == 3)
flg &= (per[X.res] == Next(per[X.a], per[X.b], per[X.c], per[X.d]));
}
if(!flg) continue;
for(int i = 1; i <= 6; i++)
W[per[i] - 1] = i;
answer(W);
return ;
} while(next_permutation(per.begin() + 1, per.end()));
assert(false);
return ;
}
void init(int T) {
assert(T != -1);
return ;
}
void orderCoins(){
Asked.clear();
int W[] = {1, 2, 3, 4, 5, 6};
int V[] = {1, 2, 3, 4, 5, 6};
int res = AskMax(1, 2, 3);
if(res == 2) swap(V[1], V[0]);
if(res == 3) swap(V[2], V[0]);
res = AskMedian(4, 5, 6);
if(res == 5) swap(V[4], V[3]);
if(res == 6) swap(V[5], V[3]);
int tmp;
tmp = AskNext(V[2], V[4], V[5], V[1]);
// Next(V[2], V[4], V[5], V[1]);
if(tmp == V[2]){ // 26
int a2 = 1, b2 = 4, c2 = 5;
int tmp2 = AskMin(V[a2], V[b2], V[c2]);
if(tmp2 == V[a2]){ // 8
int a3 = 3, b3 = 4, c3 = 5;
int tmp3 = AskNext(V[a3], V[b3], V[c3], V[0]);
if(tmp3 == V[a3]){ // 2
int a4 = 0, b4 = 4, c4 = 5;
int tmp4 = AskMin(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[b3]){ // 3
int a4 = 0, b4 = 3, c4 = 4;
int tmp4 = AskMax(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[c3]){ // 3
int a4 = 0, b4 = 4, c4 = 5;
int tmp4 = AskMax(V[a4], V[b4], V[c4]);
}
}
if(tmp2 == V[b2]){ // 9
int a3 = 1, b3 = 2, c3 = 3;
int tmp3 = AskMedian(V[a3], V[b3], V[c3]);
if(tmp3 == V[a3]){ // 3
int a4 = 0, b4 = 2, c4 = 5;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[b3]){ // 3
int a4 = 0, b4 = 3, c4 = 5;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[c3]){ // 3
int a4 = 0, b4 = 1, c4 = 5;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
}
if(tmp2 == V[c2]){ // 9
int a3 = 1, b3 = 2, c3 = 3;
int tmp3 = AskMedian(V[a3], V[b3], V[c3]);
if(tmp3 == V[a3]){ // 3
int a4 = 0, b4 = 1, c4 = 4;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[b3]){ // 3
int a4 = 0, b4 = 3, c4 = 4;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[c3]){ // 3
int a4 = 0, b4 = 1, c4 = 4;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
}
}
if(tmp == V[5]) swap(V[4], V[5]);
if(tmp == V[4]){ // 27
int a2 = 2, b2 = 4, c2 = 5;
int tmp2 = AskMin(V[a2], V[b2], V[c2]);
if(tmp2 == V[a2]){ // 9
int a3 = 0, b3 = 4, c3 = 5;
int tmp3 = AskMax(V[a3], V[b3], V[c3]);
if(tmp3 == V[a3]){ // 3
int a4 = 1, b4 = 3, c4 = 4;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[b3]){ // 3
int a4 = 0, b4 = 1, c4 = 3;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[c3]){ // 3
int a4 = 0, b4 = 3, c4 = 4;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
}
if(tmp2 == V[b2]){ // 9
int a3 = 1, b3 = 2, c3 = 3;
int tmp3 = AskMax(V[a3], V[b3], V[c3]);
if(tmp3 == V[a3]){ // 3
int a4 = 2, b4 = 3, c4 = 5;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[b3]){ // 3
int a4 = 0, b4 = 2, c4 = 5;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[c3]){ // 3
int a4 = 0, b4 = 3, c4 = 5;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
}
if(tmp2 == V[c2]){
int a3 = 1, b3 = 2, c3 = 5;
int tmp3 = AskNext(V[a3], V[b3], V[c3], V[3]);
if(tmp3 == V[a3]){ // 3
int a4 = 0, b4 = 2, c4 = 4;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[b3]){ // 3
int a4 = 0, b4 = 2, c4 = 4;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
if(tmp3 == V[c3]){ // 3
int a4 = 0, b4 = 3, c4 = 4;
int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
}
}
}
Solve();
return ;
}
Compilation message
scales.cpp: In function 'void orderCoins()':
scales.cpp:123:9: warning: unused variable 'tmp4' [-Wunused-variable]
123 | int tmp4 = AskMin(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:127:9: warning: unused variable 'tmp4' [-Wunused-variable]
127 | int tmp4 = AskMax(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:131:9: warning: unused variable 'tmp4' [-Wunused-variable]
131 | int tmp4 = AskMax(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:139:9: warning: unused variable 'tmp4' [-Wunused-variable]
139 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:143:9: warning: unused variable 'tmp4' [-Wunused-variable]
143 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:147:9: warning: unused variable 'tmp4' [-Wunused-variable]
147 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:155:9: warning: unused variable 'tmp4' [-Wunused-variable]
155 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:159:9: warning: unused variable 'tmp4' [-Wunused-variable]
159 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:163:9: warning: unused variable 'tmp4' [-Wunused-variable]
163 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:176:9: warning: unused variable 'tmp4' [-Wunused-variable]
176 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:180:9: warning: unused variable 'tmp4' [-Wunused-variable]
180 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:184:9: warning: unused variable 'tmp4' [-Wunused-variable]
184 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:193:9: warning: unused variable 'tmp4' [-Wunused-variable]
193 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:197:9: warning: unused variable 'tmp4' [-Wunused-variable]
197 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:201:9: warning: unused variable 'tmp4' [-Wunused-variable]
201 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:209:9: warning: unused variable 'tmp4' [-Wunused-variable]
209 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:213:9: warning: unused variable 'tmp4' [-Wunused-variable]
213 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:217:9: warning: unused variable 'tmp4' [-Wunused-variable]
217 | int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
| ^~~~
scales.cpp:99:6: warning: unused variable 'W' [-Wunused-variable]
99 | int W[] = {1, 2, 3, 4, 5, 6};
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
1 ms |
256 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
1 ms |
256 KB |
Output is correct |
20 |
Correct |
1 ms |
256 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
256 KB |
Output is correct |
23 |
Correct |
1 ms |
256 KB |
Output is correct |
24 |
Correct |
1 ms |
256 KB |
Output is correct |
25 |
Correct |
1 ms |
256 KB |
Output is correct |
26 |
Correct |
2 ms |
256 KB |
Output is correct |
27 |
Correct |
2 ms |
256 KB |
Output is correct |
28 |
Correct |
1 ms |
256 KB |
Output is correct |
29 |
Correct |
1 ms |
256 KB |
Output is correct |
30 |
Correct |
1 ms |
256 KB |
Output is correct |
31 |
Correct |
1 ms |
256 KB |
Output is correct |
32 |
Correct |
1 ms |
256 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
1 ms |
256 KB |
Output is correct |
35 |
Correct |
1 ms |
256 KB |
Output is correct |
36 |
Correct |
1 ms |
256 KB |
Output is correct |
37 |
Correct |
1 ms |
256 KB |
Output is correct |
38 |
Correct |
1 ms |
288 KB |
Output is correct |
39 |
Correct |
1 ms |
256 KB |
Output is correct |
40 |
Correct |
1 ms |
256 KB |
Output is correct |