#include "bits/stdc++.h"
#include "scales.h"
using namespace std;
#define pb push_back
#ifndef ONPC
mt19937 rng(time(NULL));
#endif
void init(int T) {
}
int cnt = 0;
void order(vector<int> &a) {
cnt += 2;
int x = getLightest(a[0], a[1], a[2]);
int y = getMedian(a[0], a[1], a[2]);
a[2] = a[2] + a[1] + a[0] - x - y;
a[0] = x;
a[1] = y;
}
void add3(vector<int> &a, int x) {
++cnt;
int u = getMedian(a[1], a[2], x);
if (u == a[2]) {
a.push_back(x); return;
}
if (u == x) {
a.push_back(x);
swap(a[2], a[3]);
return;
}
u = getMedian(a[0], a[1], x);
++cnt;
a.push_back(x);
swap(a[2], a[3]);
swap(a[1], a[2]);
if (u == a[0]) swap(a[0], a[1]);
}
void add2(vector<int> &a, int x) {
int u = getMedian(a[0], a[1], x);
a.push_back(x);
if (u == a[1]) return;
swap(a[1], a[2]);
if (u == x) return;
swap(a[0], a[1]);
}
vector<int> cmp(vector<int> a, vector<int> b) {
vector<int> res;
int z = getNextLightest(a[0], a[1], a[2], b[1]);
++cnt;
int p;
if (z == a[0]) {
++cnt;
z = getMedian(a[0], b[1], a[2]);
if (z == a[0]) p = 0;
else p = 4;
} else if (z == a[1]) p = 1;
else p = 2;
if (p == 0) {
res.pb(b[0]);
res.pb(b[1]);
add3(a, b[2]);
for (auto x : a) res.pb(x);
return res;
} else if (p == 4) {
add3(a, b[0]);
for (auto x : a) res.pb(x);
res.pb(b[1]);
res.pb(b[2]);
return res;
}
vector<int> u, v;
if (p == 1) {
u = {a[0], b[1]};
v = {a[1], a[2]};
} else {
u = {a[0], a[1]};
v = {b[1], a[2]};
}
add2(u, b[0]); add2(v,b[2]);
for (auto x : v) u.pb(x);
return u;
}
void orderCoins() {
int ans[6];
vector<int> a(6);
iota(a.begin(), a.end(), 1);
#ifndef ONPC
shuffle(a.begin(), a.end(), rng);
#endif
vector<int> c = a;
vector<int> b;
b.pb(c.back());
c.pop_back();
b.pb(c.back());
c.pop_back();
b.pb(c.back());
c.pop_back();
order(b); order(c);
a = cmp(b, c);
for (int i = 0; i < 6; ++i)
ans[i] = a[i];
answer(ans);
}
Compilation message
scales.cpp: In function 'void init(int)':
scales.cpp:10:15: warning: unused parameter 'T' [-Wunused-parameter]
10 | void init(int T) {
| ~~~~^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
4 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
5 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
7 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
8 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
10 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
11 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
12 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
13 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
14 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
15 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
16 |
Partially correct |
1 ms |
260 KB |
Output is partially correct |
17 |
Partially correct |
1 ms |
304 KB |
Output is partially correct |
18 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
19 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
20 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
21 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
22 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
23 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
24 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
25 |
Partially correct |
0 ms |
300 KB |
Output is partially correct |
26 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
27 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
28 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
29 |
Partially correct |
0 ms |
300 KB |
Output is partially correct |
30 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
31 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
32 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
33 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
34 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
35 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
36 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
37 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
38 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
39 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
40 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |