Submission #201508

# Submission time Handle Problem Language Result Execution time Memory
201508 2020-02-10T21:17:01 Z luciocf Hotter Colder (IOI10_hottercolder) C++14
77 / 100
791 ms 8184 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

int HC(int n)
{
	if (n == 1) return 1;

	int ini = 1, fim = n;

	while (ini < fim)
	{
		if (fim-ini == 1)
		{
			Guess(ini);
			int g = Guess(fim);

			return (g == -1 ? ini : fim);
		}

		int delta = (fim-ini+1)/3;

		int mid1 = ini + delta - 1;
		int mid2 = fim - delta + 1;

		Guess(mid1);
		int g = Guess(mid2);

		if (g == 0) return (mid1+mid2)/2;
		else if (g == 1)
		{
			if (fim-ini == 2) return fim;

			ini = (mid1+mid2)/2 + 1;
		}
		else
		{
			if (fim-ini == 2) return ini;

			fim = (mid1+mid2)/2;
			if ((mid1+mid2)%2 == 0) fim--;
		}
	}

	return ini;
}
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1144 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 Correct 28 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 791 ms 8184 KB Output is partially correct - alpha = 0.068965517241