제출 #254779

#제출 시각아이디문제언어결과실행 시간메모리
254779model_codeColors (BOI20_colors)C++11
100 / 100
3 ms436 KiB
#include <iostream> using namespace std; long long n; long long last; long long plast; bool lastAnswer; int ask(long long x) { cout << "? " << x << endl; int v; cin >> v; return v; } void ask4(long long x) { plast = last; last = x; lastAnswer = ask(x); } void giveAnswer(long long x) { cout << "= " << x << endl; } long long mas[70]; int main() { cin >> n; int i = 0; mas[0] = n; if (mas[0] > 2) { while (mas[i] > 4) { i++; mas[i] = mas[i - 1] / 2 + mas[i - 1] % 2; } bool aug = true; long long f = 2; for (int j = i - 1; j >= 0; j--) { aug = !aug; if (!aug) { f = mas[j] + f - mas[j+1]; } } long long add2 = 0; ask4(f); for (int j = 0; j < i; j++) { long long g = mas[j] - mas[j+1] + add2; if (aug) { ask4(last + g); } else { ask4( last - g); } if (!lastAnswer) { add2 += mas[j] - mas[j+1]; } aug = !aug; } if (mas[i] == 3) { ask4(last + add2 + 1); if (!lastAnswer) { ask4(last - add2 - 2); if (lastAnswer) { giveAnswer(add2 + 2); } else { giveAnswer(add2 + 3); } } else { giveAnswer(add2+1); } } else if (mas[i] == 4) { ask4(last + add2 + 2); if (lastAnswer) { ask4(last - add2 - 1); if (lastAnswer) { giveAnswer(add2 + 1); } else { giveAnswer(add2 + 2); } } else { ask4(last - add2 - 3); if (lastAnswer) { giveAnswer(add2+3); } else { giveAnswer((add2 + 4)); } } } } else { ask4(1); ask4(2); if (lastAnswer) { giveAnswer(1); } else { giveAnswer(2); } } }
#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...