Author : Dipu Kumar Mohanto
CSE, Batch - 6
BRUR.
Problem Statement : An Obvious Interactive Problem
Source : Toph
Category : Interactive Problems
Algorithm : Interactive Problems, Binary Search
Verdict : Accepted
- #include "bits/stdc++.h"
-
- using namespace std;
-
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout << fixed << setprecision(2);
-
- int lo = 0;
- int hi = 1000000;
- while (lo <= hi)
- {
- int mid = lo + hi >> 1;
- cout << mid << endl;
- fflush(stdout);
- string s;
- cin >> s;
- if (s == "Bigger") lo = mid + 1;
- else if (s == "Smaller") hi = mid - 1;
- else break;
- }
- }
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.