Submission #1033232

#TimeUsernameProblemLanguageResultExecution timeMemory
1033232vjudge1Colors (BOI20_colors)C++17
100 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define ar array #define ld long double const int N = 3e5 + 20; const int B = 400; const int M = 200; const int INF = 1e15; const int LOG = 24; const int MOD = 998244353; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt") bool query(int x){ cout<<"? "<<x<<endl; int res; cin>>res; return res; } signed main(){ios_base::sync_with_stdio(false);cin.tie(0); int n; cin>>n; int l = 0; int r = n; vector<int> v; while(l + 1 < r)v.push_back((l + r) / 2), l = (l + r) / 2; int pos = 1; reverse(v.begin(), v.end()); for(auto u: v){ if(pos + u <= n)pos += u; else pos -= u; } map<int,bool> vis; vis[pos] = 1; l = 0, r = n; query(pos); while(l +1 < r){ int mid = (l + r)/ 2; if(pos + mid <= n && !vis[pos + mid]){ pos += mid; }else pos -= mid; vis[pos] = 1; if(query(pos))r = mid; else l = mid; } cout<<"= "<<r<<endl; }
#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...