Submission #356774

# Submission time Handle Problem Language Result Execution time Memory
356774 2021-01-23T16:22:12 Z Mefarnis Hotter Colder (IOI10_hottercolder) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

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

void guessL() {
	guess = Guess(l);
	last = l;
	if(guess == 0)
		return mid;
	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)
		return mid;
	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;
	last = -1 , guess = -1;
	while(l < r) {
		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 l;
}

Compilation message

hottercolder.cpp: In function 'void guessL()':
hottercolder.cpp:12:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
   12 |   return mid;
      |          ^~~
hottercolder.cpp: In function 'void guessR()':
hottercolder.cpp:31:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
   31 |   return mid;
      |          ^~~