#include "koala.h"
#include <algorithm>
#include <vector>
std::vector<bool> query(const std::vector<int> &vec)
{
static int B[105], R[105];
int n = vec.size();
for (int i = 0; i < n; i++)
B[i] = vec[i];
playRound(B, R);
std::vector<bool> res(n);
for (int i = 0; i < n; i++)
res[i] = R[i] > B[i];
return res;
}
int minValue(int n, int m)
{
std::vector<int> vec(n);
vec[0] = 1;
auto res = query(vec);
for (int i = 0; i < n; i++)
{
if (!res[i])
return i;
}
return -1;
}
int maxValue(int n, int m)
{
std::vector<bool> in(n, true);
int cnt = n;
while (cnt > 1)
{
int w = m / cnt;
std::vector<int> vec(n);
for (int i = 0; i < n; i++)
vec[i] = in[i] ? w : 0;
auto res = query(vec);
cnt = 0;
for (int i = 0; i < n; i++)
{
in[i] = in[i] & res[i];
cnt += in[i];
}
}
for (int i = 0; i < n; i++)
{
if (in[i])
return i;
}
return -1;
}
int greaterValue(int n, int m)
{
return 0;
}
void allValues(int n, int m, int *arr)
{
if (m == n * 2)
{
std::vector<int> seq(n);
for (int i = 0; i < n; i++)
seq[i] = i;
std::stable_sort(seq.begin(), seq.end(), [&] (int x, int y)
{
std::vector<int> vec(n, 0);
vec[x] = vec[y] = n;
return query(vec)[y] > n;
});
for (int i = 0; i < n; i++)
arr[seq[i]] = i + 1;
return;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
384 KB |
Output is correct |
2 |
Correct |
9 ms |
384 KB |
Output is correct |
3 |
Correct |
8 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
384 KB |
Output is correct |
2 |
Correct |
14 ms |
384 KB |
Output is correct |
3 |
Correct |
18 ms |
384 KB |
Output is correct |
4 |
Correct |
15 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
256 KB |
Output is correct |
2 |
Incorrect |
24 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |