I tried to solve the following interactive problem: Problem link
~~~~~ bool testcase = 0 ; void solve() {
int hi = 1000000, lo = 1, mid; string s; while(lo+1<hi) { mid = (lo+hi)/2; cout << mid << "\n"; fflush(stdout); cin >> s; if(s[0]=='<') { hi = mid-1; } else { lo = mid; } } cout << hi << "\n"; fflush(stdout); cin >> s; if(s[0]=='>') cout << "! " << hi << "\n"; else cout << "! " << lo << "\n"; }
int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; if(testcase == true) { cin >> t; } while(t--) { solve(); } } ~~~~~
When I ran the above piece of code in Visual Studio code terminal it didn't produce any output. Then I deleted the commented out lines in the main function. //ios_base::sync_with_stdio(0); //cin.tie(0);
Then it ran nicely producing desired output. Why it didn't work with those 2 lines of code?
Any insight will help a lot. Thanks for your patience.