結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 103 ms
30,992 KB
testcase_05 AC 105 ms
30,932 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 108 ms
31,328 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 104 ms
31,340 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 100 ms
30,916 KB
testcase_26 WA -
testcase_27 AC 101 ms
30,952 KB
testcase_28 WA -
testcase_29 AC 104 ms
30,860 KB
testcase_30 AC 104 ms
30,812 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 100 ms
31,136 KB
testcase_34 WA -
testcase_35 RE -
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 104 ms
31,328 KB
testcase_50 WA -
testcase_51 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

fst = 0

[2, 4, 6, 8].each do |i|
  fst += try([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 = try(arr).reduce(:+)
  arr[i] = sets[i][1]
  fb2 = try(arr).reduce(:+)
  if fb2 > fb1
    nums.push(sets[i][1])
  else
    nums.push(sets[i][0])
  end
end

nums.permutation(4).each do |arr|
  res = try(arr)
  break if res == [4,0]
end
0