結果

問題 No.513 宝探し2
ユーザー くれちーくれちー
提出日時 2017-05-05 23:54:21
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,197 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 28,860 KB
実行使用メモリ 24,372 KB
平均クエリ数 25.75
最終ジャッジ日時 2023-09-24 01:09:25
合計ジャッジ時間 1,376 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,604 KB
testcase_01 AC 25 ms
24,060 KB
testcase_02 AC 24 ms
24,048 KB
testcase_03 AC 23 ms
24,300 KB
testcase_04 AC 22 ms
23,316 KB
testcase_05 AC 22 ms
24,252 KB
testcase_06 AC 23 ms
23,424 KB
testcase_07 AC 23 ms
23,736 KB
testcase_08 AC 24 ms
24,120 KB
testcase_09 AC 23 ms
24,072 KB
testcase_10 AC 24 ms
23,472 KB
testcase_11 AC 23 ms
24,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define RREP1(i, n) for (ll i = n; i >= 1; i--)
#define FOR(i, a, b, c) for (ll i = a; i <= b; i += c)
#define RFOR(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define INF 1145141919
typedef long long ll;

int ask(int x, int y) {
    printf("%d %d\n", x, y);
    fflush(stdout);
    int d;
    scanf("%d", &d);
    if (d == 0) exit(0);
    return d;
}

int main() {
    int ax, ay;
    int top = 0, tail = 100000;
    int d1, d2, asked = 0;
    while (true) {
        /*if (asked != 1)*/ d1 = ask(top, 0);
        /*if (asked != 2)*/ d2 = ask(tail, 0);
        if (d1 < d2) {
            tail = (top + tail) / 2;
            asked = 1;
        }
        else {
            top = (top + tail) / 2;
            asked = 2;
        }
        if (tail - top <= 1) {
            ax = d1 < d2 ? top : tail;
            break;
        }
    }
    ay = MIN(d1, d2);
    ask(ax, ay);
    return 1;
}
0