답안 #111493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111493 2019-05-15T13:12:53 Z diamond_duke 코알라 (APIO17_koala) C++11
29 / 100
53 ms 504 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;
}
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 (bool)query(vec)[y];
		});
		for (int i = 0; i < n; i++)
			arr[seq[i]] = i + 1;
		return;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 256 KB Output is correct
2 Correct 22 ms 384 KB Output is correct
3 Correct 16 ms 256 KB Output is correct
4 Correct 14 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 24 ms 256 KB Output is correct
2 Correct 36 ms 400 KB Output is correct
3 Correct 38 ms 256 KB Output is correct
4 Correct 32 ms 384 KB Output is correct
5 Correct 36 ms 256 KB Output is correct
6 Correct 35 ms 376 KB Output is correct
7 Correct 33 ms 384 KB Output is correct
8 Correct 40 ms 384 KB Output is correct
9 Correct 53 ms 384 KB Output is correct
10 Correct 30 ms 384 KB Output is correct
11 Correct 35 ms 256 KB Output is correct
12 Correct 20 ms 256 KB Output is correct
13 Correct 36 ms 504 KB Output is correct
14 Correct 30 ms 384 KB Output is correct
15 Correct 33 ms 384 KB Output is correct
16 Correct 35 ms 400 KB Output is correct
17 Correct 30 ms 476 KB Output is correct
18 Correct 32 ms 384 KB Output is correct
19 Correct 29 ms 256 KB Output is correct
20 Correct 28 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -