답안 #158112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
158112 2019-10-14T19:33:48 Z faremy Aliens (IOI07_aliens) C++14
100 / 100
4 ms 380 KB
#include <iostream>
#include <algorithm>
#include <string>


bool isblack(long long x, long long y, long long size)
{
	if (x < 1 || x > size || y < 1 || y > size)
		return false;
	std::cout << "examine " << x << ' ' << y << '\n';
	std::string ans; std::cin >> ans;

	if (ans == "true")
		return true;
	return false;
}

void center(long long x, long long y)
{
	std::cout << "solution " << x << ' ' << y << '\n';
}

int main()
{
	long long size, xb, yb;
	std::cin >> size >> xb >> yb;

	long long k = 0, xr = xb;
	while (isblack(xr + (1 << k), yb, size))
		k++;
	k--;

	for (; k > -1; k--)
		if (isblack(xr + (1 << k), yb, size))
			xr += (1 << k);

	k = 0; long long xl = xb;
	while (isblack(xl - (1 << k), yb, size))
		k++;
	k--;

	for (; k > -1; k--)
		if (isblack(xl - (1 << k), yb, size))
			xl -= (1 << k);

	k = 0; long long y = yb;
	while (isblack(xb, y + (1 << k), size))
		k++;
	k--;

	for (; k > -1; k--)
		if (isblack(xb, y + (1 << k), size))
			y += (1 << k);

	long long chksize = (xr - xl + 1);
	long long xc = (xl + xr) / 2;
	long long yc = y - chksize / 2;

	int l = isblack(xc - 2 * chksize, yc, size) + isblack(xc - 4 * chksize, yc, size);
	int r = isblack(xc + 2 * chksize, yc, size) + isblack(xc + 4 * chksize, yc, size);

	long long ax = xc;
	if ((l + r) % 2 == 1)
	{
		ax += chksize;
		l += 1;
	}

	ax += (r - l) * chksize;

	l = isblack(xc, yc - 2 * chksize, size) + isblack(xc, yc - 4 * chksize, size);
	r = isblack(xc, yc + 2 * chksize, size) + isblack(xc, yc + 4 * chksize, size);

	long long ay = yc;
	if ((l + r) % 2 == 1)
	{
		ay += chksize;
		l += 1;
	}

	ay += (r - l) * chksize;
	center(ax, ay);

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 248 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 4 ms 248 KB Output is correct
3 Correct 2 ms 268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 248 KB Output is correct