#include #include #include constexpr int X = 1000; bool query(int n) { if (n > X) return false; static std::vector memo(X + 1, -1); if (memo[n] != -1) return memo[n]; std::cout << "? " << n << std::endl; std::string res; std::cin >> res; return memo[n] = (res == "safe" ? 1 : 0); } void answer(int n) { std::cout << "! " << n << std::endl; } void solve() { int ok = 0, ng = X; while (ng - ok > 1) { int mid = (ok + ng) / 2; if (query(mid)) { ok = mid; } else if (query(mid + 1)) { ok = mid + 1; } else { ng = mid; } } answer(ok); } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }