結果

問題 No.514 宝探し3
ユーザー GrenacheGrenache
提出日時 2017-05-05 22:57:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 3,071 ms
コンパイル使用メモリ 75,028 KB
実行使用メモリ 72,428 KB
平均クエリ数 2.75
最終ジャッジ日時 2023-09-23 13:28:15
合計ジャッジ時間 5,795 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
71,212 KB
testcase_01 AC 139 ms
71,972 KB
testcase_02 AC 133 ms
71,740 KB
testcase_03 AC 138 ms
71,948 KB
testcase_04 AC 137 ms
71,704 KB
testcase_05 AC 142 ms
71,772 KB
testcase_06 AC 143 ms
71,812 KB
testcase_07 AC 143 ms
72,312 KB
testcase_08 AC 143 ms
72,164 KB
testcase_09 AC 142 ms
71,248 KB
testcase_10 AC 152 ms
71,696 KB
testcase_11 AC 142 ms
72,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder514 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		query(0, 0);
		long a0 = sc.nextLong();
		if (a0 == 0) {
			return;
		}
		query(1_000_000_000, 0);
		long a1 = sc.nextLong();
		if (a1 == 0) {
			return;
		}

		int[] dx = {0, 1, 1, 0, -1, -1, -1, 0, 1};
		int[] dy = {0, 0, 1, 1, 1, 0, -1, -1, -1};

		long tmpx = (a0 - a1 + 1_000_000_000) / 2;
		long tmpy = (a0 + a1 - 1_000_000_000) / 2;

		for (int i = 0, size = dx.length; i < size; i++) {
			query(tmpx + dx[i], tmpy + dy[i]);
			long tmp = sc.nextLong();
			if (tmp == 0) {
				return;
			}
		}
	}

	private static void query(long x, long y) {
		pr.printf("%d %d\n", x, y);
		pr.flush();
		return;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0