結果
| 問題 | No.253 ロウソクの長さ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-24 23:21:38 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 715 bytes |
| 記録 | |
| コンパイル時間 | 277 ms |
| コンパイル使用メモリ | 40,532 KB |
| 実行使用メモリ | 28,976 KB |
| 平均クエリ数 | 27.33 |
| 最終ジャッジ日時 | 2026-01-04 17:29:43 |
| 合計ジャッジ時間 | 7,285 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 WA * 5 TLE * 1 -- * 2 |
ソースコード
#include <cstdio>
// cpp_binarysearch (C) @cielavenir under Boost Software License.
// type F should be something like std::function<bool(T)>.
template<typename T,typename F>
T binarysearch(T lo,T hi,T eps,const F &checker){
int c=0;
bool f=true;
for(;/*lo+eps<hi*/;c++){
T mi=(lo+hi)/2;
//if(f)mi=10;
int z=checker(mi);
if(z==0)return mi+c;
if(z==1)lo=mi-1,hi=hi-1;
if(z==-1)hi=mi-1,lo=lo-1;
if(lo<0)lo=0;
if(hi<0)hi=0;
}
}
template<typename T,typename F>
T binarysearch(T lo,T hi,const F &checker){return binarysearch(lo,hi,1,checker);}
int main(){
printf("! %d\n",binarysearch(1,1000000000,[&](int t){
printf("? %d\n",t);
fflush(stdout);
int f;
scanf("%d",&f);
return f;
}));
}