Submission #41332

# Submission time Handle Problem Language Result Execution time Memory
41332 2018-02-16T13:00:08 Z ljk0411jg Hotter Colder (IOI10_hottercolder) C++14
51 / 100
795 ms 8184 KB
#include "grader.h"

int HC(int N) {
	int l, r, ret1, ret2, mid, result = 1;
	r = N;
	l = 1;
	while (l <= r)
	{
		if (l== r)
		{
			result = l;
			break;
		}
		if (r - l > 4)
		{
			ret1 = Guess(r);
			ret2 = Guess(l);
			mid = (l + r) / 2;
			if (ret2 == 0)
			{
				result = mid;
				break;
			}
			else if (ret2 == 1)
			{
				r = mid;
			}
			else
			{
				l = mid + 1;
			}
		}
		else
		{
			ret2 = Guess(l);
			for (int i = l + 1; i <= r; i++)
			{
				ret2 = Guess(i);
				if (ret2 == 0)
				{
					result = i;
					break;
				}
				else if (ret2 == -1)
				{
					result = i - 1;
					break;
				}
				else if (ret2 == 1 && i == r)
				{
					result = r;
					break;
				}
			}
			l = r + 1;
		}
	}
	return result;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:4:12: warning: variable 'ret1' set but not used [-Wunused-but-set-variable]
  int l, r, ret1, ret2, mid, result = 1;
            ^~~~
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 1272 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Partially correct 795 ms 8184 KB Output is partially correct - alpha = 0.034482758621