# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
357669 | mario05092929 | Colors (BOI20_colors) | C++11 | 1 ms | 384 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>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 1e16;
const long long mod = 1e9+7;
const long long hashmod = 100003;
const int MAXN = 100000;
const int MAXM = 1000000;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
int n,x,l,r;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
int val;
cout << "? 1" << endl;
cin >> val;
cout << "? " << (n+1)/2 << endl;
cin >> val;
if(val) {
l = 3, r = (n+1)/2-1;
int x = 2;
for(int len = (n+1)/2-2;len >= 1;len--) {
cout << "? " << x << endl;
cin >> val;
if(!val) {
cout << "= " << len+1 << endl;
return 0;
}
if(x-1 == r) x = l++;
else x = r--;
}
cout << "= 1" << endl;
return 0;
}
else {
cout << "? " << n << endl;
cin >> val;
if(val) {
cout << "= " << n-((n+1)/2) << endl;
return 0;
}
l = 3, r = n-1;
int x = 2;
for(int len = n-2;len >= n-((n+1)/2);len--) {
cout << "? " << x << endl;
cin >> val;
if(!val) {
cout << "= " << len+1 << endl;
return 0;
}
if(x-1 == r) x = l++;
else x = r--;
}
cout << "= " << n-((n+1)/2) << endl;
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... |