Submission #41035

# Submission time Handle Problem Language Result Execution time Memory
41035 2018-02-12T06:34:49 Z 969 Hotter Colder (IOI10_hottercolder) C++14
0 / 100
10000 ms 8056 KB
#include "grader.h"
#define HOTTER 1
#define COLDER -1
#define SAME 0

int HC(int N) {
	int lo = 1, hi = N;
	int g = Guess(lo);
	int h = Guess(hi);
	int mid = (lo + hi) / 2;
	int ans = (1 + N) / 2;
	int before = hi;

	while (1) {
		if (lo == hi) {
			ans = lo;
			break;
		}
		if (h == SAME) {
			break;
		}
		g = h;
		if (h == HOTTER) {
			if (before == hi) {
				lo = mid - 1;
				h = Guess(lo);
				before = lo;
			}
			else {
				hi = mid + 1;
				h = Guess(hi);
				before = hi;
			}
		}
		else if (h == COLDER) {
			if (before == hi) {
				hi = mid;
				h = Guess(hi);
				before = hi;
			}
			else {
				lo = mid;
				h = Guess(lo);
				before = lo;
			}
		}
		mid = (lo + hi) / 2;
		ans = mid;
	}

	return ans;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:8:6: warning: variable 'g' set but not used [-Wunused-but-set-variable]
  int g = Guess(lo);
      ^
# Verdict Execution time Memory Grader output
1 Execution timed out 10025 ms 1272 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 10030 ms 1272 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 10036 ms 1272 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 10061 ms 8056 KB Time limit exceeded