結果

問題 No.253 ロウソクの長さ
コンテスト
ユーザー kyuridenamida
提出日時 2015-07-24 23:49:51
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 550 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,410 ms
コンパイル使用メモリ 175,112 KB
実行使用メモリ 28,976 KB
平均クエリ数 28.28
最終ジャッジ日時 2026-03-31 09:57:26
合計ジャッジ時間 3,692 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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