Need help with solving interactive problems!

Revision en2, by Wonsei, 2020-08-07 22:07:12
#include <iostream>
#include <cstring>

using namespace std;

int main() {
	int ll = 1, rr = 1000000;
	int ans;
	while (ll <= rr) {
		int mid = (ll + rr) / 2;
		cout << mid;
		fflush(stdout);
		string s;
		cin >> s;
		if (s == ">=") {
			ans = mid;
			ll = mid + 1;
		}
		else {
			rr = mid - 1;
		}
	}
	cout << "! " << ans;
	fflush(stdout);
	return 0;
}

This is an easy interactive question that guesses the number 1 to 1000000 by binary search. However, I am new to the concept of interactive problems, and I am getting an idleness TLE on this problem. Can someone tell me what is causing the Idleness on my code? Thanks in advance.

Problem statement : https://mirror.codeforces.com/gym/101021/problem/1

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Wonsei 2020-08-07 22:07:12 2959
en1 English Wonsei 2020-08-07 21:57:44 3720 Initial revision (published)