結果

問題 No.253 ロウソクの長さ
ユーザー koba-e964
提出日時 2021-08-17 14:51:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 74,320 KB
最終ジャッジ日時 2025-01-23 22:43:28
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;

ll query(ll lo, ll hi, int &nq) {
  while (hi - lo >= 2) {
    ll mid = (hi + lo) / 2;
    cout << "? " << mid - nq << endl;
    int res;
    cin >> res;
    nq++;
    if (res == 0) {
      return mid;
    }
    if (res > 0) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  return lo;
}

int main(void){
  cin.sync_with_stdio(false);
  int nq = 0;
  ll res = query(10, 200, nq);
  if (res <= 98) {
    cout << "! " << res << endl;
    return 0;
  }
  cout << "! " << query(98, 1e9 + 1, nq) << endl;
}
0