제출 #1131619

#제출 시각아이디문제언어결과실행 시간메모리
1131619alterioColors (BOI20_colors)C++20
100 / 100
1 ms668 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define all(x) (x).begin(), (x).end() ll ask(ll x) { cout << "? " << x << endl; ll val; cin >> val; return val; } int main() { ll n; cin >> n; ll l = 0, r = n; ll pos = 1; vector<ll> v; while (l + 1 < r) { v.push_back((l + r) / 2); l = (l + r) / 2; } reverse(all(v)); for (auto x : v) { if (pos + x <= n) pos += x; else pos -= x; } ask(pos); unordered_set<ll> used; used.insert(pos); l = 0, r = n; while (l + 1 < r) { ll mid = (l + r) / 2; if (pos + mid <= n && !used.count(pos + mid)) pos += mid; else pos -= mid; used.insert(pos); ll x = ask(pos); if (x) 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...