답안 #408903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
408903 2021-05-19T19:13:50 Z rainboy Hotter Colder (IOI10_hottercolder) C
25 / 100
10000 ms 7956 KB
#include "grader.h"

int HC(int n) {
#if 0
	int lower_, lower, upper, g, x;

	if (n == 1)
		return 1;
	if (n == 2) {
		Guess(1);
		return Guess(2) < 0 ? 1 : 2;
	}
	if (n == 3) {
		Guess(1);
		if (Guess(2) < 0)
			return 1;
		if (Guess(3) < 0)
			return 2;
		return 3;
	}
	Guess(1);
	g = Guess(n / 2);
	if (g == 0)
		return (1 + n / 2) / 2;
	if (g < 0)
		return HC(n / 4);
	lower_ = (1 + n / 2) / 2 + 1;
	lower = n / 2, upper = n;
	while (lower < upper) {
		int mid = (lower + 1 + upper) / 2;

		g = Guess(mid);
		if (g == 0)
			return (lower + mid) / 2;
		if (g > 0)
			lower_ = (lower + mid) / 2 + 1, lower = mid;
		else {
			upper = (lower + mid - 1) / 2, lower = lower_, x = mid;
			while (lower < upper) {
				mid = (lower + upper) / 2;
				if (mid * 2 - x <= 0 || mid * 2 - x > n) {
					if (lower > 1)
						Guess(lower - 1), x = lower - 1;
					else
						Guess(upper + 1), x = upper + 1;
				}
				g = Guess(mid * 2 - x);
				if (g == 0)
					return mid;
				else if ((g > 0) == (x < mid * 2 - x))
					lower = mid + 1;
				else
					upper = mid - 1;
				x = mid * 2 - x;
			}
			return lower;
		}
	}
#else
	int i;
	for (i = 1; i <= n; i++)
		if (Guess(i) < 0)
			return i - 1;
	return n;
#endif
}
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 1252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 1228 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 87 ms 1244 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10037 ms 7956 KB Time limit exceeded