Submission #41049

# Submission time Handle Problem Language Result Execution time Memory
41049 2018-02-12T07:28:05 Z didwlvv Hotter Colder (IOI10_hottercolder) C++14
0 / 100
3259 ms 141328 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) {
		printf("%d\n", cnt++);
		int mid = (le + ri) / 2;
		int ok = Guess(mid);
		if (f) {
			if (ok == 1) {
				if (mid != 1) {
					int ook = Guess(mid - 1);
					g = mid - 1;
					if (ook == 1) {
						ri = mid - 1;

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

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

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

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

	}
	return le;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:9:6: warning: variable 'g' set but not used [-Wunused-but-set-variable]
  int g = N;
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 12024 KB 잘못된 접근입니다.
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 12024 KB 잘못된 접근입니다.
# Verdict Execution time Memory Grader output
1 Incorrect 151 ms 11980 KB 잘못된 접근입니다.
# Verdict Execution time Memory Grader output
1 Incorrect 3259 ms 141328 KB 잘못된 접근입니다.