結果

問題 No.253 ロウソクの長さ
ユーザー kyuridenamida
提出日時 2015-07-24 23:49:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 1,498 ms
コンパイル使用メモリ 158,688 KB
実行使用メモリ 25,220 KB
平均クエリ数 28.28
最終ジャッジ日時 2024-07-16 20:49:33
合計ジャッジ時間 4,086 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int Q(int n){
	cout << "? " << n << endl;
	string s1;
	int ans;
	cin >> ans;
	return ans;
}

int D(int a){
	cout << "! " << a << endl;
	exit(0);
}

int main(){
	int T = 0;
	T++;
	if( Q(100) == -1 ){
		for(int i = 0 ; i < 100 ; i++ ){
			int t = Q(i);
			if( t == -1 ){
				D(i+T-1);
			}else if( t == 0 ) D(i+T);
			T++;
		}
	}else{
		int l = 0 , r = 1e9;
		while( l != r ){
			int m = (l+r+1) / 2;
			if( Q(m-T) == -1 ){ // Y < (?)
				r = m-1;
			}else{
				l = m;
			}
			T++;
		}
		D(l);
		
	}
	
	
}
0