# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
533096 | kabika | Colors (BOI20_colors) | C++17 | 1 ms | 200 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1e18;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
vector<bool> vis(n + 1, 0);
cout << "? 1\n";
vis[1] = 1;
bool resp;
cin >> resp;
bool flag = 1;
ll l = 1, u = n;
ll diff = (l + u) / 2;
ll qr = l + diff;
while (l < u)
{
cout << "? " << qr << endl;
vis[qr] = 1;
cin >> resp;
if (resp)
{
u = diff;
}
else
{
l = diff + 1;
}
diff = (l + u) / 2;
if (qr - diff >= 1 && !vis[qr - diff])
{
qr -= diff;
continue;
}
if (qr + diff <= n && !vis[qr + diff])
{
qr += diff;
continue;
}
break;
}
cout << "= " << l << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |