結果

問題 No.253 ロウソクの長さ
ユーザー tossytossy
提出日時 2017-05-14 13:13:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,372 bytes
コンパイル時間 1,310 ms
コンパイル使用メモリ 165,260 KB
実行使用メモリ 24,528 KB
平均クエリ数 18.50
最終ジャッジ日時 2023-09-23 14:02:30
合計ジャッジ時間 7,017 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 23 ms
24,300 KB
testcase_02 AC 24 ms
24,360 KB
testcase_03 AC 23 ms
23,628 KB
testcase_04 AC 22 ms
24,012 KB
testcase_05 AC 24 ms
23,436 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 24 ms
23,700 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 23 ms
23,484 KB
testcase_15 AC 24 ms
23,628 KB
testcase_16 AC 24 ms
23,532 KB
testcase_17 AC 22 ms
24,252 KB
testcase_18 WA -
testcase_19 AC 23 ms
24,408 KB
testcase_20 WA -
testcase_21 AC 25 ms
24,036 KB
testcase_22 AC 24 ms
23,424 KB
testcase_23 WA -
testcase_24 AC 25 ms
23,388 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 22 ms
23,628 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int ask(int n){
  cout << "? " << n << endl;
  int r;
  cin>>r;
  return r;
}

int main(){
  int ret = ask(100);

  if(ret==0){
    cout << "! 100" << endl;
  } else if(ret==-1){
    int cnt = 0;
    do {
      ret = ask(9);
      cnt++;
    } while(ret != 0);
    cout << "! " << 9 + cnt << endl;
  } else {
    // にぶたん
    int l=100, r=200;//r=INF/2;
    int cnt = 1;
    while(r-l>1){
      int m = (l+r)/2;
      ret = ask(m-cnt);
      if(ret==0){
        cout << "! " << m <<endl;
        return 0;
      }

      if(ret == -1) r = m;
      else l = m;

      cnt++;
    }

    ret = ask(l-cnt);
    if(ret==0) cout << "! " << l << endl;
    else if(ret==1) cout << "! " << r << endl;
    else assert(false);
  }

  return 0;
}
0