結果

問題 No.253 ロウソクの長さ
ユーザー koba-e964koba-e964
提出日時 2021-08-17 14:51:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 77,676 KB
実行使用メモリ 25,476 KB
平均クエリ数 26.92
最終ジャッジ日時 2024-04-18 18:22:58
合計ジャッジ時間 5,471 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 20 ms
24,952 KB
testcase_02 AC 18 ms
25,220 KB
testcase_03 AC 18 ms
25,124 KB
testcase_04 AC 19 ms
24,964 KB
testcase_05 AC 19 ms
24,964 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 20 ms
25,220 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 19 ms
25,220 KB
testcase_15 AC 20 ms
25,220 KB
testcase_16 AC 20 ms
24,836 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 20 ms
24,836 KB
testcase_20 WA -
testcase_21 AC 21 ms
24,836 KB
testcase_22 AC 19 ms
25,220 KB
testcase_23 WA -
testcase_24 AC 20 ms
24,580 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 23 ms
24,832 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

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