Submission #356777

# Submission time Handle Problem Language Result Execution time Memory
356777 2021-01-23T16:28:59 Z Mefarnis Hotter Colder (IOI10_hottercolder) C++14
79 / 100
2704 ms 8196 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

int l,r,mid;
int last,guess,ans;

void guessL() {
	guess = Guess(l);
	last = l;
	if(guess == 0) {
		ans = mid;
		return;
	}
	if((l+r)%2 == 0) {
		if(guess == 1)
			r = mid-1;
		else
			l = mid+1;
	}
	else {
		if(guess == 1)
			r = mid;
		else
			l = mid+1;
	}
}

void guessR() {
	guess = Guess(r);
	last = r;
	if(guess == 0) {
		ans = mid;
		return;
	}
	if((l+r)%2 == 0) {
		if(guess == -1)
			r = mid-1;
		else
			l = mid+1;
	}
	else {
		if(guess == -1)
			r = mid;
		else
			l = mid+1;
	}
}

int HC(int n) {
	srand(time(NULL));
	l = 1 , r = n;
	ans = -1 , last = -1 , guess = -1;
	while(l < r && ans == -1) {
		mid = (l+r) >> 1;
		if(guess == 1) {
			if(last == l)
				guessR();
			else
				guessL();
		}
		else {
			if(rand()%2 == 0) {
				Guess(l);
				guessR();
			}
			else {
				Guess(r);
				guessL();
			}
		}
	}
	return (ans == -1) ? l : ans;
}
# Verdict Execution time Memory Grader output
1 Correct 241 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 250 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 244 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 2704 ms 8196 KB Output is partially correct - alpha = 0.160000000000