답안 #226575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
226575 2020-04-24T11:09:03 Z Blerargh Hotter Colder (IOI10_hottercolder) C++17
0 / 100
837 ms 101368 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
 
int HC(int N){
	if (N==1) return 1;
	
	int nextguess, prevguess;
	int l=1, r=N;
	
	int mid = (l+r)/2;
	int chk = Guess(mid);
	chk = Guess(mid+1);
	if (chk == -1){
		r = mid;
	} else if (chk == 1){
		l = mid+1;
	}
	prevguess = mid+1;
	
	while (l<r){
		nextguess = l - prevguess + r;
		if (nextguess > prevguess) nextguess = min(nextguess, N);
		else if (nextguess < prevguess) nextguess = max(1, nextguess);
		chk = Guess(nextguess);
		
		if (chk == -1){
			if (nextguess > prevguess) {
				mid = (nextguess + prevguess)/2;
                if (mid - prevguess == nextguess - mid) r = mid-1;
                else r = mid;
			} else {
				mid = (nextguess + prevguess)/2;
                l = mid+1;
			}
		} else if (chk == 1){
			if (nextguess > prevguess) {
				mid = (nextguess + prevguess)/2;
                l = mid+1;
			} else {
				mid = (nextguess + prevguess)/2;
                if (mid - prevguess == nextguess-mid) r = mid-1;
                else r = mid;
			}
		} else if (chk == 0){
			return (prevguess+nextguess)/2;
		}
		prevguess = nextguess;
	}
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 12536 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 12540 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 12536 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 837 ms 101368 KB Output isn't correct - alpha = 0.000000000000