結果

問題 No.1429 Simple Dowsing
ユーザー materialmaterial
提出日時 2021-03-14 16:22:51
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 11,344 KB
実行使用メモリ 31,584 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-24 10:08:14
合計ジャッジ時間 3,064 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
30,656 KB
testcase_01 AC 108 ms
31,016 KB
testcase_02 AC 108 ms
31,128 KB
testcase_03 AC 106 ms
31,176 KB
testcase_04 WA -
testcase_05 AC 108 ms
30,780 KB
testcase_06 AC 107 ms
30,804 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 108 ms
31,060 KB
testcase_10 AC 106 ms
30,820 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 107 ms
31,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def candidate(p, q, d)
  ts = []
  (0..100).each do |y|
    (0..100).each do |x|
      if ((p - x) ** 2 + (q - y) ** 2) == d then
        ts.push([x, y])
      end
    end
  end
  return ts
end

def intersection(s, t)
  u = []
  s.each do |x|
    u.push(x) if t.include?(x)
  end
  return u
end

def main(argv)
  p = 0
  q = 0

  puts "? #{p} #{q}"
  STDOUT.flush
  d = gets.chomp.to_i

  ts = candidate(p, q, d)

  p = 100
  q = 0

  puts "? #{p} #{q}"
  STDOUT.flush
  d = gets.chomp.to_i

  ts = candidate(p, q, d)

  p = ts[0][0]
  q = ts[0][1]

  puts "! #{p} #{q}"
  STDOUT.flush
end

main(ARGV) if self.to_s == 'main'
0