結果

問題 No.513 宝探し2
ユーザー bal4ubal4u
提出日時 2019-07-16 07:05:15
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 27,824 KB
実行使用メモリ 24,324 KB
平均クエリ数 4.08
最終ジャッジ日時 2023-09-24 02:17:15
合計ジャッジ時間 1,702 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,060 KB
testcase_01 AC 24 ms
23,616 KB
testcase_02 AC 23 ms
24,024 KB
testcase_03 AC 23 ms
23,400 KB
testcase_04 AC 22 ms
23,400 KB
testcase_05 AC 23 ms
24,252 KB
testcase_06 AC 22 ms
24,060 KB
testcase_07 AC 23 ms
24,324 KB
testcase_08 AC 22 ms
23,556 KB
testcase_09 AC 23 ms
23,868 KB
testcase_10 AC 22 ms
23,964 KB
testcase_11 AC 22 ms
24,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.513 宝探し2
// 2019.7.16 bal4u

#include <stdio.h>
#include <stdlib.h>

#define MAX 100000

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

int main()
{
	int x, y, dl, dr;

	dl = ask(0,0), dr = ask(MAX, 0);
	if (dl == dr) x = MAX/2;
	if (dl > dr) x = ((dl-dr) + MAX) / 2;
	else x = (MAX-(dr-dl)) / 2;
	
	dl = ask(x, 0), dr = ask(x, MAX);
	if (dl == dr) y = MAX/2;
	if (dl > dr) y = ((dl-dr) + MAX) / 2;
	else y = (MAX-(dr-dl)) / 2;
	
	ask(x, y);
	return 0;
}
0