結果

問題 No.253 ロウソクの長さ
ユーザー 沙耶花沙耶花
提出日時 2022-03-22 22:31:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 4,153 ms
コンパイル使用メモリ 259,868 KB
実行使用メモリ 24,324 KB
平均クエリ数 28.72
最終ジャッジ日時 2023-09-24 03:02:40
合計ジャッジ時間 7,207 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,892 KB
testcase_01 AC 26 ms
23,580 KB
testcase_02 AC 24 ms
23,688 KB
testcase_03 AC 26 ms
24,036 KB
testcase_04 AC 26 ms
23,604 KB
testcase_05 AC 26 ms
23,724 KB
testcase_06 AC 26 ms
24,120 KB
testcase_07 AC 26 ms
23,424 KB
testcase_08 AC 25 ms
23,688 KB
testcase_09 AC 25 ms
23,664 KB
testcase_10 AC 26 ms
23,424 KB
testcase_11 AC 26 ms
23,568 KB
testcase_12 AC 25 ms
24,024 KB
testcase_13 AC 25 ms
23,688 KB
testcase_14 AC 25 ms
24,072 KB
testcase_15 AC 25 ms
23,652 KB
testcase_16 AC 26 ms
24,060 KB
testcase_17 AC 25 ms
23,448 KB
testcase_18 AC 25 ms
23,472 KB
testcase_19 AC 25 ms
23,436 KB
testcase_20 AC 26 ms
24,060 KB
testcase_21 AC 24 ms
24,108 KB
testcase_22 AC 26 ms
23,592 KB
testcase_23 AC 25 ms
23,604 KB
testcase_24 AC 25 ms
24,324 KB
testcase_25 AC 25 ms
23,460 KB
testcase_26 AC 25 ms
23,580 KB
testcase_27 AC 25 ms
24,084 KB
testcase_28 AC 25 ms
24,084 KB
testcase_29 AC 25 ms
24,096 KB
testcase_30 AC 25 ms
24,048 KB
testcase_31 AC 26 ms
23,424 KB
testcase_32 AC 26 ms
23,580 KB
testcase_33 AC 26 ms
23,424 KB
testcase_34 AC 25 ms
23,580 KB
testcase_35 AC 26 ms
24,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001
int cnt = 0;

void answer(int n){
	cout<<"! "<<n<<endl;
	exit(0);
}

//is greater n?
bool query(int n){
	cout<<"? "<<n<<endl;
	int r;
	cin>>r;
	
	if(r==0){
		answer(n+cnt);
	}
	cnt++;
	if(r==1)return true;
	return false;
}

int main(){
	
	bool f = query(50);
	if(f){
		int ok = 50,ng = 1000000005;
		while(ng-ok>1){
			int mid = (ok+ng)/2;
			if(query(mid-cnt))ok = mid;
			else ng = mid;
		}
	}
	else{
		while(true)query(0);
	}
	
	return 0;
}
0