結果

問題 No.1429 Simple Dowsing
ユーザー さかぽんさかぽん
提出日時 2021-03-14 14:21:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 3,485 ms
コンパイル使用メモリ 105,436 KB
実行使用メモリ 38,888 KB
平均クエリ数 2.87
最終ジャッジ日時 2023-09-24 10:03:28
合計ジャッジ時間 5,889 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
36,368 KB
testcase_01 AC 83 ms
38,684 KB
testcase_02 AC 85 ms
36,484 KB
testcase_03 AC 85 ms
37,060 KB
testcase_04 AC 84 ms
36,824 KB
testcase_05 AC 85 ms
38,540 KB
testcase_06 AC 85 ms
37,096 KB
testcase_07 AC 83 ms
34,504 KB
testcase_08 AC 84 ms
38,656 KB
testcase_09 AC 83 ms
36,260 KB
testcase_10 AC 83 ms
36,420 KB
testcase_11 AC 82 ms
37,124 KB
testcase_12 AC 81 ms
36,992 KB
testcase_13 AC 83 ms
38,888 KB
testcase_14 AC 84 ms
36,640 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;

class A
{
	static int Query(int i, int j)
	{
		Console.WriteLine($"? {i} {j}");
		return int.Parse(Console.ReadLine());
	}
	static void Main() => Console.WriteLine($"! {Solve()}");
	static object Solve()
	{
		var d1 = Query(0, 0);
		if (d1 == 0) return $"{0} {0}";

		var options = new List<(int i, int j)>();
		for (int i = 0; i <= 100; i++)
		{
			for (int j = 0; j <= 100; j++)
			{
				if (i * i + j * j == d1)
					options.Add((i, j));
			}
		}

		var (x1, y1) = options[0];
		if (options.Count == 1) return $"{x1} {y1}";

		var d2 = Query(x1, y1);
		if (d2 == 0) return $"{x1} {y1}";

		foreach (var (x2, y2) in options)
		{
			var (i, j) = (x1 - x2, y1 - y2);
			if (i * i + j * j == d2)
				return $"{x2} {y2}";
		}

		throw new InvalidOperationException();
	}
}
0