#include using namespace std; typedef long long i64; const int Nmax = 1005, Kmax = 15, Inf = 0x3f3f3f3f; int Dp[Nmax][Kmax], Next[Nmax][Kmax]; int main() { /*#ifndef ONLINE_JUDGE freopen("input", "r", stdin); freopen("output", "w", stdout); #endif // ONLINE_JUDGE*/ ios::sync_with_stdio(false); int N, K; cin >> N >> K; for (int i = 2; i <= N; ++i) { Dp[i][0] = Inf; for (int j = 1; j <= K; ++j) { Dp[i][j] = Inf; for (int k = 1; k <= i; ++k) { int cost = 1 + max(Dp[k][j - 1], Dp[i - k][j]); if (cost < Dp[i][j]) { Dp[i][j] = cost; Next[i][j] = k; } } } } int left = 1, right = N, k = K; while (left < right) { int x = left + Next[right - left + 1][k] - 1; cout << "query " << x << endl; string state; cin >> state; if (state == "broke") { right = x; --k; } else { left = x + 1; } } cout << "answer " << left << endl; string s; cin >> s; }