結果

問題 No.253 ロウソクの長さ
ユーザー chocorusk
提出日時 2018-10-11 16:21:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 862 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 92,748 KB
実行使用メモリ 40,752 KB
最終ジャッジ日時 2024-07-16 16:14:16
合計ジャッジ時間 7,209 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int x1=10, x2=1e3;
	int ct=0;
	while(1){
		int x=(x1+x2)/2;
		printf("? %d\n", x-ct); fflush(stdout);
		ct++;
		int t;
		cin>>t;
		if(t==0){
			printf("! %d\n", x); fflush(stdout);
			return 0;
		}else if(t==1){
			x1=x+1;
		}else{
			x2=x-1;
		}
	}
	x1=1e3, x2=1e9;
	while(1){
		int x=(x1+x2)/2;
		printf("? %d\n", x-ct); fflush(stdout);
		ct++;
		int t;
		cin>>t;
		if(t==0){
			printf("! %d\n", x); fflush(stdout);
			return 0;
		}else if(t==1){
			x1=x+1;
		}else{
			x2=x-1;
		}
	}
	return 0;
}
0