Submission #41038

# Submission time Handle Problem Language Result Execution time Memory
41038 2018-02-12T06:49:12 Z hsb154 Hotter Colder (IOI10_hottercolder) C++14
50 / 100
745 ms 8288 KB
#include "grader.h"

int HC(int N){
	int left = 1;
	int right = N;
	Guess(1);
	
	int temp = Guess(N); 
	

	bool flag = false;
	//false:right
	//true : left
	while(1){
		if (left == right)
			return left;
		if (temp == 1) {
			if (!flag) {//이전에 right수정
				left = (left + right) / 2+1;
				if (left != right) {
					temp = Guess(left);
				}
				flag = true;
			}
			else {//이전에 left수정
				right = (left + right) / 2;
				if (left != right) {
					temp = Guess(right);
				}
				flag = false;
			}
		}
		else if (temp == -1) {
			if (!flag) {//이전에 right 수정
				right = (left + right) / 2;
				if (left != right) {
					temp = Guess(left);
					temp = Guess(right);
				}
				flag = false;
			}
			else {//이전에 left 수정
				left = (left + right) / 2 + 1;
				if (left != right) {
					temp = Guess(right);
					temp = Guess(left);
				}
				flag = true;
			}
		}
		else {
			return (left + right) / 2;
		}
	}


		

	/*for (int i = 1; i <= N; i++) {
		int temp = Guess(i);
		if (temp == -1) {
			return i - 1;
		}
	}
	return N;*/
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1272 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 745 ms 8288 KB Output isn't correct - alpha = 0.000000000000