Submission #1030352

#TimeUsernameProblemLanguageResultExecution timeMemory
103035212345678Colors (BOI20_colors)C++17
9 / 100
1 ms344 KiB
#include <bits/stdc++.h> using namespace std; const int nx=100; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...