#include "scales.h"
//#include "grader.cpp"
#include <set>
#include <vector>
#include <iostream>
using namespace std;
struct Query
{
int type;
set <int> args;
int ans;
Query(){}
Query(int type, set <int> args, int ans)
{
this->type = type;
this->args = args;
this->ans = ans;
}
};
struct QueryKeeper
{
vector <Query> v;
int get(int ind)
{
return v[ind].ans;
}
};
QueryKeeper welko;
int ask(int type, set <int> args)
{
int a, b, c, d;
auto it = args.begin();
a = *it;it++;
b = *it;it++;
c = *it;it++;
if(type==4) d = *it;
int res;
if(type==1) res = getHeaviest(a, b, c);
else if(type==2) res = getLightest(a, b, c);
else if(type==3) res = getMedian(a, b, c);
else if(type==4) res = getNextLightest(a, b, c, d);
welko.v.push_back(Query(type, args, res));
return res;
}
set <int> exclude(set <int> s, vector <int> v)
{
for(int x: v) s.erase(x);
return s;
}
set <int> include(set <int> s, vector <int> v)
{
for(int x: v) s.insert(x);
return s;
}
void init(int T) {
/* ... */
}
void solve4(set <int> s, int *W)
{
vector <int> v;
for(int x: s) v.push_back(x);
int b = ask(1, {v[0], v[1], v[2]});
W[1] = ask(2, exclude(s, {b}));
int med = ask(3, exclude(s, {W[1]}));
int c;
if(v[3]!=W[1]) c = v[3];
else c = *exclude(s, {b, W[1]}).begin();
int a = *exclude(s, {b, c, W[1]}).begin();
if(med==b) W[2] = a, W[3] = b, W[4] = c;
else if(med==a) W[2] = c, W[3] = a, W[4] = b;
else if(med==c) W[2] = a, W[3] = c, W[4] = b;
//cout << a << " " << b << " " << c << '\n';
}
void orderCoins() {
/* ... */
welko.v.clear();
int W[] = {-1, -1, -1, -1, -1, -1};
ask(1, {1, 2, 3});
ask(2, {4, 5, 6});
ask(1, include(exclude({4, 5, 6}, {welko.get(1)}), {welko.get(0)}));
ask(2, include(exclude({1, 2, 3}, {welko.get(0)}), {welko.get(1)}));
W[5] = welko.get(2);
W[0] = welko.get(3);
set <int> rem = exclude({1, 2, 3, 4, 5, 6}, {welko.get(2), welko.get(3)});
solve4(rem, W);
answer(W);
}
Compilation message
scales.cpp: In constructor 'Query::Query(int, std::set<int>, int)':
scales.cpp:19:5: warning: declaration of 'ans' shadows a member of 'Query' [-Wshadow]
19 | {
| ^
scales.cpp:15:9: note: shadowed declaration is here
15 | int ans;
| ^~~
scales.cpp:19:5: warning: declaration of 'args' shadows a member of 'Query' [-Wshadow]
19 | {
| ^
scales.cpp:13:15: note: shadowed declaration is here
13 | set <int> args;
| ^~~~
scales.cpp:19:5: warning: declaration of 'type' shadows a member of 'Query' [-Wshadow]
19 | {
| ^
scales.cpp:12:9: note: shadowed declaration is here
12 | int type;
| ^~~~
scales.cpp: In constructor 'Query::Query(int, std::set<int>, int)':
scales.cpp:24:5: warning: declaration of 'ans' shadows a member of 'Query' [-Wshadow]
24 | }
| ^
scales.cpp:15:9: note: shadowed declaration is here
15 | int ans;
| ^~~
scales.cpp:24:5: warning: declaration of 'args' shadows a member of 'Query' [-Wshadow]
24 | }
| ^
scales.cpp:13:15: note: shadowed declaration is here
13 | set <int> args;
| ^~~~
scales.cpp:24:5: warning: declaration of 'type' shadows a member of 'Query' [-Wshadow]
24 | }
| ^
scales.cpp:12:9: note: shadowed declaration is here
12 | int type;
| ^~~~
scales.cpp: In constructor 'Query::Query(int, std::set<int>, int)':
scales.cpp:24:5: warning: declaration of 'ans' shadows a member of 'Query' [-Wshadow]
24 | }
| ^
scales.cpp:15:9: note: shadowed declaration is here
15 | int ans;
| ^~~
scales.cpp:24:5: warning: declaration of 'args' shadows a member of 'Query' [-Wshadow]
24 | }
| ^
scales.cpp:13:15: note: shadowed declaration is here
13 | set <int> args;
| ^~~~
scales.cpp:24:5: warning: declaration of 'type' shadows a member of 'Query' [-Wshadow]
24 | }
| ^
scales.cpp:12:9: note: shadowed declaration is here
12 | int type;
| ^~~~
scales.cpp: In function 'void init(int)':
scales.cpp:70:15: warning: unused parameter 'T' [-Wunused-parameter]
70 | void init(int T) {
| ~~~~^
scales.cpp: In function 'int ask(int, std::set<int>)':
scales.cpp:23:19: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
23 | this->ans = ans;
| ~~~~~~~~~~^~~~~
scales.cpp:48:9: note: 'res' was declared here
48 | int res;
| ^~~
# |
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 |
288 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
5 |
Partially correct |
0 ms |
256 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
384 KB |
Output is partially correct |
7 |
Partially correct |
1 ms |
256 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 |
1 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 |
256 KB |
Output is partially correct |
18 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
19 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
20 |
Partially correct |
1 ms |
256 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 |
256 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 |
1 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 |
0 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 |
0 ms |
256 KB |
Output is partially correct |
36 |
Partially correct |
1 ms |
256 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 |
0 ms |
256 KB |
Output is partially correct |