Submission #111494

# Submission time Handle Problem Language Result Execution time Memory
111494 2019-05-15T13:15:47 Z diamond_duke Koala Game (APIO17_koala) C++11
73 / 100
82 ms 512 KB
#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;
}
bool comp(int n, int x, int y)
{
	std::vector<int> vec(n);
	vec[x] = vec[y] = 4;
	auto res = query(vec);
	if (res[x] != res[y])
		return res[y];
	if (res[x])
	{
		vec[x] = vec[y] = 8;
		return query(vec)[y];
	}
	vec[x] = vec[y] = 2;
	res = query(vec);
	if (res[x] != res[y])
		return res[y];
	vec[x] = vec[y] = 1;
	return query(vec)[y];
}
int greaterValue(int n, int m)
{
	return comp(n, 0, 1);
}
void allValues(int n, int m, int *arr)
{
	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)
	{
		if (n == m)
			return comp(n, x, y);
		std::vector<int> vec(n, 0);
		vec[x] = vec[y] = n;
		return (bool)query(vec)[y];
	});
	for (int i = 0; i < n; i++)
		arr[seq[i]] = i + 1;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 8 ms 256 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 400 KB Output is correct
2 Correct 19 ms 384 KB Output is correct
3 Correct 19 ms 256 KB Output is correct
4 Correct 19 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 408 KB Output is correct
2 Correct 72 ms 440 KB Output is correct
3 Correct 58 ms 384 KB Output is correct
4 Correct 60 ms 412 KB Output is correct
5 Correct 82 ms 504 KB Output is correct
6 Correct 56 ms 508 KB Output is correct
7 Correct 75 ms 384 KB Output is correct
8 Correct 79 ms 384 KB Output is correct
9 Correct 68 ms 384 KB Output is correct
10 Correct 58 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 256 KB Output is correct
2 Correct 45 ms 368 KB Output is correct
3 Correct 34 ms 256 KB Output is correct
4 Correct 40 ms 384 KB Output is correct
5 Correct 33 ms 256 KB Output is correct
6 Correct 31 ms 364 KB Output is correct
7 Correct 37 ms 384 KB Output is correct
8 Correct 47 ms 384 KB Output is correct
9 Correct 36 ms 504 KB Output is correct
10 Correct 37 ms 256 KB Output is correct
11 Correct 32 ms 384 KB Output is correct
12 Correct 15 ms 256 KB Output is correct
13 Correct 33 ms 384 KB Output is correct
14 Correct 32 ms 512 KB Output is correct
15 Correct 31 ms 384 KB Output is correct
16 Correct 33 ms 400 KB Output is correct
17 Correct 28 ms 384 KB Output is correct
18 Correct 28 ms 256 KB Output is correct
19 Correct 30 ms 384 KB Output is correct
20 Correct 28 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 20 ms 256 KB Output is partially correct
2 Partially correct 32 ms 384 KB Output is partially correct
3 Partially correct 32 ms 384 KB Output is partially correct
4 Partially correct 31 ms 384 KB Output is partially correct
5 Partially correct 31 ms 384 KB Output is partially correct
6 Partially correct 32 ms 384 KB Output is partially correct
7 Partially correct 36 ms 256 KB Output is partially correct
8 Partially correct 28 ms 400 KB Output is partially correct
9 Partially correct 32 ms 376 KB Output is partially correct
10 Partially correct 28 ms 384 KB Output is partially correct
11 Partially correct 28 ms 256 KB Output is partially correct
12 Partially correct 13 ms 384 KB Output is partially correct
13 Partially correct 27 ms 384 KB Output is partially correct
14 Partially correct 31 ms 360 KB Output is partially correct
15 Partially correct 32 ms 504 KB Output is partially correct
16 Partially correct 35 ms 256 KB Output is partially correct
17 Partially correct 36 ms 384 KB Output is partially correct
18 Partially correct 35 ms 504 KB Output is partially correct
19 Partially correct 35 ms 364 KB Output is partially correct
20 Partially correct 37 ms 384 KB Output is partially correct
21 Partially correct 29 ms 256 KB Output is partially correct
22 Partially correct 41 ms 384 KB Output is partially correct
23 Partially correct 39 ms 384 KB Output is partially correct
24 Partially correct 32 ms 256 KB Output is partially correct
25 Partially correct 29 ms 256 KB Output is partially correct
26 Partially correct 28 ms 384 KB Output is partially correct
27 Partially correct 32 ms 384 KB Output is partially correct
28 Partially correct 31 ms 460 KB Output is partially correct
29 Partially correct 27 ms 256 KB Output is partially correct
30 Partially correct 36 ms 384 KB Output is partially correct
31 Partially correct 30 ms 364 KB Output is partially correct
32 Partially correct 28 ms 256 KB Output is partially correct
33 Partially correct 30 ms 256 KB Output is partially correct
34 Partially correct 27 ms 384 KB Output is partially correct
35 Partially correct 32 ms 404 KB Output is partially correct
36 Partially correct 31 ms 344 KB Output is partially correct
37 Partially correct 27 ms 256 KB Output is partially correct
38 Partially correct 26 ms 384 KB Output is partially correct
39 Partially correct 29 ms 384 KB Output is partially correct
40 Partially correct 30 ms 256 KB Output is partially correct