結果

問題 No.355 数当てゲーム(2)
ユーザー honakehonake
提出日時 2016-10-19 20:00:33
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 11,592 KB
実行使用メモリ 31,668 KB
平均クエリ数 32.77
最終ジャッジ日時 2023-09-23 11:37:42
合計ジャッジ時間 13,934 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 105 ms
31,412 KB
testcase_05 AC 98 ms
31,312 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 100 ms
30,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 100 ms
31,300 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 99 ms
30,668 KB
testcase_26 WA -
testcase_27 AC 100 ms
30,776 KB
testcase_28 WA -
testcase_29 AC 102 ms
30,992 KB
testcase_30 AC 101 ms
31,320 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 102 ms
31,376 KB
testcase_34 WA -
testcase_35 AC 102 ms
31,080 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 103 ms
31,060 KB
testcase_50 WA -
testcase_51 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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