답안 #41047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41047 2018-02-12T07:18:20 Z didwlvv Hotter Colder (IOI10_hottercolder) C++14
0 / 100
795 ms 21624 KB
#include "grader.h"
#include<cstdio>
#include<cmath>
int HC(int N){
	Guess(N);
	int cnt = 1;
	int le = 1;
	int ri = N;
	int g = N;
	bool f = true;
	while (le < ri) {
		int mid = (le + ri) / 2;
		int ok = Guess(mid);
		if (f) {
			if (ok == 1) {
				int ook = Guess(mid - 1);
				g = mid - 1;
				if (ook == 1) {
					ri = mid-1;

				}
				else if (ook == -1) {
					le = mid;
					f = 0;
				}

			}
			else if (ok == -1) {
				g = mid;
				le = mid + (ri - mid) / 2;
			}
			else {
				return mid + (g - mid) / 2;
			}
		}
		else{
			if (ok == 1) {
				int ook = Guess(mid + 1);
				g = mid + 1;
				if (ook == 1) {
					le = mid + 1;

				}
				else if (ook == -1) {
					ri = mid;
					f = 1;
				}

			}
			else if (ok == -1) {
				g = mid;
				ri = mid + (mid - le) / 2;
			}
			else {
				return mid + (g - mid) / 2;
			}
		}

	}
	return le;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:6:6: warning: unused variable 'cnt' [-Wunused-variable]
  int cnt = 1;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 2936 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 2936 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 2936 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 795 ms 21624 KB Output isn't correct - alpha = 0.000000000000