結果
| 問題 |
No.1429 Simple Dowsing
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-14 14:21:03 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 2,000 ms |
| コード長 | 820 bytes |
| コンパイル時間 | 2,443 ms |
| コンパイル使用メモリ | 113,384 KB |
| 実行使用メモリ | 42,432 KB |
| 平均クエリ数 | 2.87 |
| 最終ジャッジ日時 | 2024-07-17 10:50:20 |
| 合計ジャッジ時間 | 4,214 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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();
}
}