結果

問題 No.513 宝探し2
ユーザー vvataarnevvataarne
提出日時 2017-05-05 23:01:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,828 bytes
コンパイル時間 1,468 ms
コンパイル使用メモリ 165,308 KB
実行使用メモリ 24,024 KB
平均クエリ数 58.67
最終ジャッジ日時 2023-09-24 01:06:19
合計ジャッジ時間 2,720 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,316 KB
testcase_01 AC 26 ms
23,616 KB
testcase_02 AC 27 ms
23,580 KB
testcase_03 AC 27 ms
23,724 KB
testcase_04 AC 27 ms
24,024 KB
testcase_05 AC 25 ms
23,952 KB
testcase_06 AC 26 ms
23,520 KB
testcase_07 AC 24 ms
23,628 KB
testcase_08 AC 25 ms
23,964 KB
testcase_09 AC 24 ms
23,328 KB
testcase_10 AC 27 ms
23,304 KB
testcase_11 AC 27 ms
23,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>

using namespace std;

// clang-format on

main {
  int x1 = 0, x2 = 100000, y1 = 0, y2 = 100000;
  int x;
  while (true) {
    int t, s;
    cout << x1 << ' ' << 0 << endl;
    cin >> t;
    cout << x2 << ' ' << 0 << endl;
    cin >> s;
    if (x2 - x1 == 1) {
      x = t < s ? x1 : x2;
      break;
    }
    if (t == s) {
      x = x1 + (x2 - x1) / 2;
      break;
    }
    if (t < s) {
      x2 = x1 + (x2 - x1 + 1) / 2;
      continue;
    }
    if (t > s) {
      x1 = x1 + (x2 - x1) / 2;
      continue;
    }
  }
  int y;
  while (true) {
    int t, s;
    cout << 0 << ' ' << y1 << endl;
    cin >> t;
    cout << 0 << ' ' << y2 << endl;
    cin >> s;
    if (y2 - y1 == 1) {
      y = t < s ? y1 : y2;
      break;
    }
    if (t == s) {
      y = y1 + (y2 - y1) / 2;
      break;
    }
    if (t < s) {
      y2 = y1 + (y2 - y1 + 1) / 2;
      continue;
    }
    if (t > s) {
      y1 = y1 + (y2 - y1) / 2;
      continue;
    }
  }
  cout << x << ' ' << y << endl;
  bye;
}
0