# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
617974 |
2022-08-01T18:31:04 Z |
blue |
Scales (IOI15_scales) |
C++17 |
|
1 ms |
256 KB |
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
//7 QUERIES
using vi = vector<int>;
using vvi = vector<vi>;
#define sz(x) int(x.size())
void init(int T) {
/* ... */
}
void v_answer(vi z)
{
int W[] = {z[0], z[1], z[2], z[3], z[4], z[5]};
answer(W);
}
void orderCoins()
{
{
vi a{0}, b{0};
a.push_back(getLightest(1, 2, 3));
a.push_back(getMedian(1, 2, 3));
a.push_back(1+2+3 - a[1] - a[2]);
b.push_back(getLightest(4, 5, 6));
b.push_back(getMedian(4, 5, 6));
b.push_back(4+5+6 - b[1] - b[2]);
int M = getMedian(a[2], b[1], b[2]);
if(M == a[2])
{
vi res;
if(getMedian(b[1], a[1], a[2]) == a[1])
res = {b[1], a[1]};
else
res = {a[1], b[1]};
res.push_back(a[2]);
int z = getMedian(a[3], b[2], b[3]);
vi nw;
if(z == b[2])
nw = {a[3], b[2], b[3]};
else if(z == b[3])
nw = {b[2], b[3], a[3]};
else if(z == a[3])
nw = {b[2], a[3], b[3]};
for(int w : nw)
res.push_back(w);
v_answer(res);
return;
}
else if(M == b[1])
{
int z = getMedian(b[2], b[3], a[3]);
vi res;
if(z == b[3])
res = {a[1], a[2], b[1], b[2], b[3], a[3]};
else if(z == a[3])
res = {a[1], a[2], b[1], b[2], a[3], b[3]};
else
{
if(getHeaviest(a[2], b[1], a[3]) == a[3])
res = {a[1], a[2], b[1], a[3], b[2], b[3]};
else
res = {a[1], a[2], a[3], b[1], b[2], b[3]};
}
v_answer(res);
return;
}
else if(M == b[2])
{
vi p1, p2;
// cerr << a[1] << ' ' << a[2] << ' ' << a[3] << '\n';
// cerr << b[1] << ' ' << b[2] << ' ' << b[3] << '\n';
int u = getMedian(a[1], b[1], b[2]);
if(u == a[1])
p1 = {b[1], a[1], b[2]};
else if(u == b[1])
p1 = {a[1], b[1], b[2]};
else if(u == b[2])
p1 = {b[1], b[2], a[1]};
// cerr << p1[0] << ' ' << p1[1] << ' ' << p1[2] << '\n';
vi res;
int f = getMedian(b[3], p1[2], a[2]);
if(f == p1[2])
res = {p1[0], p1[1], b[3], p1[2], a[2], a[3]};
else if(f == b[3])
res = {p1[0], p1[1], p1[2], b[3], a[2], a[3]};
else if(f == a[2])
{
int mx = getHeaviest(b[3], a[3], a[1]);
int mn = a[3]+b[3] - mx;
res = {p1[0], p1[1], p1[2], a[2], mn, mx};
}
v_answer(res);
return;
}
}
while(1);
{
int l1 = getLightest(1, 2, 3);
int l2 = getLightest(4, 5, 6);
int k = 1;
while(k == l1 || k == l2)
k++;
int a = getLightest(l1, l2, k);
// cerr << "a = " << a << '\n';
vi rem;
for(int i = 1; i <= 6; i++)
if(i != a)
rem.push_back(i);
int b = getLightest(rem[0], rem[1], getLightest(rem[2], rem[3], rem[4]));
vi rem2;
for(int x : rem)
if(x != b)
rem2.push_back(x);
int c = getMedian(b, rem2[0], getLightest(rem2[1], rem2[2], rem2[3]));
vi rem3;
for(int x : rem2)
if(x != c)
rem3.push_back(x);
int d = getLightest(rem3[0], rem3[1], rem3[2]);
int e = getMedian(rem3[0], rem3[1], rem3[2]);
int f = rem3[0] + rem3[1] + rem3[2] - d - e;
int W[] = {a, b, c, d, e, f};
answer(W);
}
}
Compilation message
scales.cpp: In function 'void init(int)':
scales.cpp:11:15: warning: unused parameter 'T' [-Wunused-parameter]
11 | void init(int T) {
| ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:117:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
117 | while(1);
| ^~~~~
scales.cpp:119:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
119 | {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
2 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
3 |
Partially correct |
0 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 |
0 ms |
212 KB |
Output is partially correct |
7 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
8 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
9 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
10 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
11 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
12 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
13 |
Partially correct |
0 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 |
0 ms |
212 KB |
Output is partially correct |
17 |
Partially correct |
1 ms |
256 KB |
Output is partially correct |
18 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
19 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
20 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
21 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
22 |
Partially correct |
0 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 |
1 ms |
212 KB |
Output is partially correct |
26 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
27 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
28 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
29 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
30 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
31 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
32 |
Partially correct |
0 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 |
0 ms |
212 KB |
Output is partially correct |
37 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
38 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
39 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
40 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |