結果

問題 No.355 数当てゲーム(2)
ユーザー honake
提出日時 2016-10-19 20:00:33
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 29,152 KB
平均クエリ数 32.77
最終ジャッジ日時 2024-07-16 11:11:06
合計ジャッジ時間 15,206 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 41
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def out(arr)
  $stdout.puts arr.join(' ')
  $stdout.flush
  x,y = gets.split.map(&:to_i)
  exit 0 if x == 4
  [x,y]
end

fst = 0

[2, 4, 6, 8].each do |i|
  fst += out([0,1,i,i + 1]).reduce(:+)
end

if fst == 4
  sets = [[2, 3], [4, 5], [6, 7], [8, 9]]
elsif fst == 7
  sets = [[0, 1], [2, 3], [4, 5], [6, 7]]
elsif fst == 10
  sets = [[0, 0], [1, 1], [2, 3], [6, 7]]
end

nums = []

4.times do |i|
  arr = [sets[0][0], sets[1][0], sets[2][0], sets[3][0]]
  fb1 = out(arr).reduce(:+)
  arr[i] = sets[i][1]
  fb2 = out(arr).reduce(:+)
  if fb2 >= fb1
    nums.push(sets[i][1])
  else
    nums.push(sets[i][0])
  end
end

nums.permutation(4).each do |arr|
  out(arr)
end
0