Submission #231129

# Submission time Handle Problem Language Result Execution time Memory
231129 2020-05-12T20:24:15 Z Dilshod_Imomov Hotter Colder (IOI10_hottercolder) C++17
53 / 100
741 ms 9112 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
int HC(int N){
	if ( N == 1 ) {
		return 1;
	}
	if ( N == 2 ) {
		Guess(1);
		if ( Guess(2) == 1 ) {
			return 2;
		}
		else {
			return 1;
		}
	}
	int l = 1, r = N;
	int ans = 1, cnt = 0, ok = 0;
	// cout << "N\n";
	while ( l + 1 < r ) {
		int md = (l + r) / 2;
		// cout << l << ' ' << md << ' ' << r << "\n";
		if ( md == l + 1 && md == r - 1 ) {
			Guess(l);
			ans = md;
			break;
		}
		if ( ok && ans == md ) {
			int rr = md - 1;
			int y = Guess(rr - 1);
			ans = rr - 1;
			ok = 0;
			if ( y == 1 ) {
				r = md;
			}
			else if ( y == -1 ) {
				l = md;
			}
			else {
				return md - 1;
			}
			continue;
		}

		Guess((l + md) / 2);
		cnt++;
		int y = Guess((md + r) / 2);
		ok = 1;
		ans = (md + r) / 2;
		cnt++;
		if ( y == 1 ) {
			l = md;
		}
		else if ( y == -1 ) {
			r = md;
		}
		else {
			return md;
		}
	}
	if ( l + 1 == r ) {
		if ( Guess(l) == 1 ) {
			return l;
		}
		else {
			return r;
		}
	}
	ans = (l + r) / 2;
	// cout << l << ' ' << ans << ' ' << r << endl;
	int x = Guess(r);
	if ( x == 1 ) {
		return r;
	}
	else if ( x == -1 ) {
		return l;
	}
	else {
		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1280 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Partially correct 741 ms 9112 KB Output is partially correct - alpha = 0.111111111111