Submission #201532

# Submission time Handle Problem Language Result Execution time Memory
201532 2020-02-10T23:01:58 Z luciocf Hotter Colder (IOI10_hottercolder) C++14
78 / 100
1028 ms 8184 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

int vez;

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

	int ini = 1, fim = n;
	int ant = 0, lado = 0;

	while (ini < fim)
	{
		if (fim-ini == 1)
		{
			Guess(ini);
			int g = Guess(fim);
 
			return (g == -1 ? ini : fim);
		}

		int g;

		if (lado == 0 || (lado == 1 && ant == 2) || (lado == 2 && ant == 1))
		{
			int toss = rand()%2;

			if (toss == 0)
			{
				Guess(ini);
				g = Guess(fim);
				ant = 2;
			}
			else
			{
				Guess(fim);
				g = Guess(ini);
				ant = 1;
			}
		}
		else if (lado == 1)
		{
			g = Guess(fim);
			ant = 2;
		}
		else
		{
			g = Guess(ini);
			ant = 1;
		}

		if (g == 0) return (ini+fim)/2;
		else if (g == 1)
		{
			if (ant == 2) ini = (ini+fim)/2 + 1, lado = 2;
			else
			{
				int ant = fim;

				fim = (ini+fim)/2;
				if ((ini+ant)%2 == 0) fim--;

				lado = 1;
			}
		}
		else
		{
			if (ant == 1) ini = (ini+fim)/2 + 1, lado = 2;
			else
			{
				int ant = fim;

				fim = (ini+fim)/2;
				if ((ini+ant)%2 == 0) fim--;

				lado = 1;
			}
		}
	}

	return ini;
}
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1028 ms 8184 KB Output is partially correct - alpha = 0.137931034483