結果

問題 No.253 ロウソクの長さ
ユーザー not_522not_522
提出日時 2020-01-04 01:04:36
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 4,494 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 103,476 KB
実行使用メモリ 24,384 KB
平均クエリ数 22.75
最終ジャッジ日時 2023-09-24 02:23:42
合計ジャッジ時間 3,549 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,364 KB
testcase_01 AC 21 ms
23,364 KB
testcase_02 AC 23 ms
24,012 KB
testcase_03 AC 20 ms
23,352 KB
testcase_04 AC 21 ms
24,288 KB
testcase_05 AC 20 ms
23,412 KB
testcase_06 AC 22 ms
23,412 KB
testcase_07 AC 21 ms
24,276 KB
testcase_08 AC 20 ms
23,376 KB
testcase_09 AC 20 ms
23,376 KB
testcase_10 AC 21 ms
23,964 KB
testcase_11 AC 21 ms
23,568 KB
testcase_12 AC 21 ms
24,060 KB
testcase_13 AC 21 ms
23,664 KB
testcase_14 AC 20 ms
23,664 KB
testcase_15 AC 21 ms
23,652 KB
testcase_16 AC 24 ms
23,388 KB
testcase_17 AC 21 ms
24,372 KB
testcase_18 AC 25 ms
24,180 KB
testcase_19 AC 20 ms
23,652 KB
testcase_20 AC 21 ms
24,168 KB
testcase_21 AC 21 ms
24,384 KB
testcase_22 AC 20 ms
23,556 KB
testcase_23 AC 21 ms
23,556 KB
testcase_24 AC 21 ms
24,348 KB
testcase_25 AC 23 ms
23,868 KB
testcase_26 AC 22 ms
23,652 KB
testcase_27 AC 23 ms
23,640 KB
testcase_28 AC 22 ms
23,580 KB
testcase_29 AC 23 ms
24,360 KB
testcase_30 AC 22 ms
23,664 KB
testcase_31 AC 22 ms
24,276 KB
testcase_32 AC 26 ms
23,640 KB
testcase_33 AC 25 ms
24,012 KB
testcase_34 AC 21 ms
23,688 KB
testcase_35 AC 21 ms
23,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// This is free and unencumbered software released into the public domain.

// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.

// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

// For more information, please refer to <http://unlicense.org>

/****************/
/* template.hpp */
/****************/

#include <algorithm>
#include <cassert>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>

using std::cerr;
using std::cout;
using std::endl;
using std::max;
using std::min;
using std::swap;

struct BoolName : std::numpunct<char> {
  std::string t, f;
  BoolName(std::string t, std::string f) : t(t), f(f) {}
  std::string do_truename() const { return t; }
  std::string do_falsename() const { return f; }
};

void setBoolName(std::string t, std::string f) {
  cout.imbue(std::locale(cout.getloc(), new BoolName(t, f)));
}

struct Initializer {
  Initializer() {
    cout << std::fixed << std::setprecision(15) << std::boolalpha;
    setBoolName("Yes", "No");
  }
} initializer;

struct Input {
  bool eof;

  Input() : eof(false) {}

  operator char() {
    char v;
    while (!(this->eof = (std::scanf("%c", &v) != 1)) && std::isspace(v)) {
    }
    return v;
  }

  operator int() {
    int v;
    this->eof = (std::scanf("%d", &v) != 1);
    return v;
  }

  operator long() {
    long v;
    this->eof = (std::scanf("%ld", &v) != 1);
    return v;
  }

  operator long long() {
    long long v;
    this->eof = (std::scanf("%lld", &v) != 1);
    return v;
  }

  operator unsigned int() {
    unsigned int v;
    this->eof = (std::scanf("%u", &v) != 1);
    return v;
  }

  operator unsigned long() {
    unsigned long v;
    this->eof = (std::scanf("%lu", &v) != 1);
    return v;
  }

  operator unsigned long long() {
    unsigned long long v;
    this->eof = (std::scanf("%llu", &v) != 1);
    return v;
  }

  operator double() {
    double v;
    this->eof = (std::scanf("%lf", &v) != 1);
    return v;
  }

  operator long double() {
    long double v;
    this->eof = (std::scanf("%Lf", &v) != 1);
    return v;
  }

  void ignore() const { getchar(); }
} in;

template <typename T> T abs(T a) { return a >= 0 ? a : -a; }

template <typename T, typename S> bool chmin(T &a, const S &b) {
  return a > b ? a = b, true : false;
}

template <typename T, typename S> bool chmax(T &a, const S &b) {
  return a < b ? a = b, true : false;
}

template <typename T, typename S> std::function<S(T)> cast() {
  return [](const T &t) { return static_cast<S>(t); };
}

template <typename T> T copy(const T &a) { return T(a); }

class ZeroPadding {
public:
  ZeroPadding(int n) : n(n) {}

  int n;
};

std::ostream &operator<<(std::ostream &os, const ZeroPadding &z) {
  os << std::setw(z.n) << std::setfill('0');
  return os;
}

template <typename T> constexpr T inf() {
  return std::numeric_limits<T>::max() / 2 - 1;
}

/*********************/
/* binary_search.hpp */
/*********************/

int64_t binarySearch(std::function<bool(int64_t)> func, int64_t include,
                     int64_t exclude) {
  while (abs(exclude - include) > 1) {
    int64_t middle = (include + exclude) / 2;
    (func(middle) ? include : exclude) = middle;
  }
  return include;
}

/************/
/* main.cpp */
/************/

int main() {
  int cnt = 0;
  auto f = [&](int m) {
    cout << "? " << m - cnt << endl;
    ++cnt;
    return int(in) >= 0;
  };
  auto res = binarySearch(f, 10, f(100) ? 1e9 + 1 : 101);
  cout << "! " << res << endl;
}
0