Submission #763742

#TimeUsernameProblemLanguageResultExecution timeMemory
763742aaron_dcoderColors (BOI20_colors)C++17
0 / 100
0 ms208 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; bool did_archie_notice(ll col) { int ans; cout << "? " << col << endl; cin >> ans; cout.flush(); return (ans == 1); } int offset(ll N) { ll minimum_possible_value_C = 1ll; ll curren_hair_color = N/3ll; ll next_direc = 1ll; ll next_check; do { ll to_check = (N+minimum_possible_value_C)/2ll; ll oldhaircolor = curren_hair_color; next_check= curren_hair_color + next_direc*to_check; curren_hair_color = next_check; minimum_possible_value_C = abs(oldhaircolor-curren_hair_color)+1ll; next_direc *= -1ll; } while (next_check>1); return 1-next_check; } int main() { ll N; cin >> N; cout.flush(); set<ll> used_up; ll curren_hair_color = N/3ll +offset(N); did_archie_notice(curren_hair_color); ll maximum_possible_value_C = N; ll minimum_possible_value_C = 1ll; ll next_direc = 1ll; while (maximum_possible_value_C!=minimum_possible_value_C) { //cout << "max pv:" << maximum_possible_value_C << ",min pv:" << minimum_possible_value_C << " ,haircol:" << curren_hair_color << "\n"; ll to_check = (maximum_possible_value_C+minimum_possible_value_C)/2ll; ll oldhaircolor = curren_hair_color; bool hasnoticed = true; for (ll chk_disp = 0; ; chk_disp++) { ll next_check= curren_hair_color + next_direc*(to_check-chk_disp); if ((to_check-chk_disp) >= maximum_possible_value_C || (to_check-chk_disp) < minimum_possible_value_C) { throw exception(); } if (used_up.count(next_check)==0) { used_up.insert(next_check); hasnoticed = did_archie_notice(next_check); curren_hair_color = next_check; break; } next_check= curren_hair_color + next_direc*(to_check+chk_disp); if ((to_check+chk_disp) >= maximum_possible_value_C || (to_check+chk_disp) < minimum_possible_value_C) { throw exception(); } if (used_up.count(next_check)==0) { used_up.insert(next_check); hasnoticed = did_archie_notice(next_check); curren_hair_color = next_check; break; } } if (hasnoticed) { maximum_possible_value_C = abs(oldhaircolor-curren_hair_color); } else { minimum_possible_value_C = abs(oldhaircolor-curren_hair_color)+1ll; } next_direc *= -1ll; } cout << "= " << maximum_possible_value_C << 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...