結果

問題 No.355 数当てゲーム(2)
ユーザー honakehonake
提出日時 2016-10-19 20:29:16
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 787 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 31,840 KB
平均クエリ数 16.83
最終ジャッジ日時 2023-09-23 11:41:38
合計ジャッジ時間 12,327 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 102 ms
31,304 KB
testcase_05 AC 102 ms
30,788 KB
testcase_06 AC 100 ms
30,968 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 98 ms
30,800 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 101 ms
30,956 KB
testcase_14 AC 101 ms
31,384 KB
testcase_15 WA -
testcase_16 AC 100 ms
31,012 KB
testcase_17 AC 102 ms
31,072 KB
testcase_18 WA -
testcase_19 AC 104 ms
31,292 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 103 ms
31,196 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 104 ms
30,952 KB
testcase_26 WA -
testcase_27 AC 103 ms
31,328 KB
testcase_28 WA -
testcase_29 AC 104 ms
30,864 KB
testcase_30 AC 103 ms
31,388 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 103 ms
31,344 KB
testcase_34 AC 103 ms
31,068 KB
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 AC 103 ms
31,436 KB
testcase_46 WA -
testcase_47 AC 101 ms
31,248 KB
testcase_48 WA -
testcase_49 AC 104 ms
30,880 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
  nums = []
elsif fst == 7
  nums = []
  fb1 = try([0, 2, 3, 4]).reduce(:+)
  fb2 = try([1, 2, 3, 4]).reduce(:+)
  if fb2 > fb1
    nums.push(1)
  elsif fb2 < fb1
    nums.push(0)
  end
elsif fst == 10
  nums = [0, 1]
end

sets = [[2, 3], [4, 5], [6, 7], [8, 9]]

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])
  elsif fb2 < fb1
    nums.push(sets[i][0])
  end
end

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