Submission #408897

# Submission time Handle Problem Language Result Execution time Memory
408897 2021-05-19T19:07:16 Z rainboy Hotter Colder (IOI10_hottercolder) C
0 / 100
610 ms 8160 KB
#include "grader.h"
#include <assert.h>

int HC(int n) {
	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;
				}
				assert(mid * 2 - x >= 1 && mid * 2 - x <= n);
				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;
		}
	}
	return n;
}
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1268 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1252 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1272 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 610 ms 8160 KB Output isn't correct - alpha = 0.000000000000