# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
649647 | welleyth | Colors (BOI20_colors) | C++17 | 1 ms | 300 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 <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
constexpr int N = (int)2e5 + 111;
constexpr int md = (int)2e5 + 111;
mt19937 rnd(time(nullptr));
set<int> was_asked;
int ask(int x){
assert(!was_asked.count(x));
was_asked.insert(x);
cout << "? " << x << "\n";
cout.flush();
int answer;
cin >> answer;
return answer;
}
void solve(){
int n;
cin >> n;
ask(1);
int pr = 1;
int l = 2, r = n;
for(int it = 0; l <= r; it^=1){
if(it == 0){
int check = ask(r--);
if(!check){
cout << "= " << r - l + 3 << "\n";
return;
}
} else {
int check = ask(l++);
if(!check){
cout << "= " << r - l + 3 << "\n";
return;
}
}
}
return;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
// init();
int tests = 1;
// cin >> tests;
for(int test = 1; test <= tests; test++){
// cerr << "test = " << test << "\n";
solve();
}
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... |