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 <bits/stdc++.h>
using namespace std;
const int nx=150;
int n, tmp, l, r, t, lst, x, dp[nx], mn=INT_MAX;
int query(int x)
{
cout<<"? "<<x<<endl;
cin>>tmp;
return tmp;
}
int main()
{
cin>>n;
int md=n/2;
for (int i=1; i+md<=n; i++) if (max(i-1, n-i-md)<mn) mn=max(i-1, n-i-md), l=i, r=i+md;
if (l-1<=n-r) lst=1, query(r), dp[md]=query(l);
else lst=0, query(l), dp[md]=query(r);
if (dp[md])
{
while (r-l-1>0)
{
if (lst) r--, lst=0, dp[r-l]=query(r);
else l++, lst=1, dp[r-l]=query(l);
}
}
else
{
while (r-l+1<n)
{
if (lst) r++, lst=0, dp[r-l]=query(r);
else l--, lst=1, dp[r-l]=query(l);
}
}
for (int i=1; i<=n; i++) if (dp[i]) return cout<<"= "<<i, 0;
cout<<"= "<<n;
}
# | 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... |