Submission #763705

#TimeUsernameProblemLanguageResultExecution timeMemory
763705aaron_dcoderColors (BOI20_colors)C++17
0 / 100
0 ms300 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; return (ans == 1); } int main() { ll N; cin >> N; set<ll> used_up; ll curren_hair_color = N/3 + 1; did_archie_notice(curren_hair_color); ll maximum_possible_value_C = N; ll minimum_possible_value_C = 1; ll next_direc = 1; 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)/2; ll oldhaircolor = curren_hair_color; bool hasnoticed; for (ll chk_disp = 0; chk_disp<N; 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)+1; } next_direc *= -1; } cout << "= " << maximum_possible_value_C; }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:52:9: warning: 'hasnoticed' may be used uninitialized in this function [-Wmaybe-uninitialized]
   52 |         if (hasnoticed) {
      |         ^~
#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...