結果
| 問題 | 
                            No.1187 皇帝ペンギン
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-06 20:23:44 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 83 ms / 1,000 ms | 
| コード長 | 388 bytes | 
| コンパイル時間 | 1,917 ms | 
| コンパイル使用メモリ | 192,260 KB | 
| 最終ジャッジ日時 | 2025-01-14 08:01:27 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 54 | 
コンパイルメッセージ
main.cpp: In function ‘bool ask(int)’:
main.cpp:10:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         char s[8]; scanf("%s",s);
      |                    ~~~~~^~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
bool ask(int x){
	printf("? %d\n",x);
	fflush(stdout);
	char s[8]; scanf("%s",s);
	return s[0]=='s';
}
int main(){
	int lo=0,hi=500;
	while(hi-lo>1){
		int mi=(lo+hi)/2;
		if(ask(2*mi) || ask(2*mi+1)) lo=mi; else hi=mi;
	}
	printf("! %d\n",ask(2*lo+1)?2*lo+1:2*lo);
	fflush(stdout);
	return 0;
}