結果

問題 No.355 数当てゲーム(2)
ユーザー simansiman
提出日時 2023-07-10 21:43:55
言語 Ruby
(3.3.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 545 ms
コンパイル使用メモリ 11,300 KB
実行使用メモリ 31,492 KB
平均クエリ数 30.48
最終ジャッジ日時 2023-10-10 01:24:38
合計ジャッジ時間 10,570 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
31,264 KB
testcase_01 AC 110 ms
31,212 KB
testcase_02 AC 112 ms
30,804 KB
testcase_03 AC 110 ms
30,900 KB
testcase_04 AC 110 ms
31,308 KB
testcase_05 AC 109 ms
30,904 KB
testcase_06 AC 114 ms
31,104 KB
testcase_07 AC 110 ms
30,804 KB
testcase_08 AC 110 ms
30,908 KB
testcase_09 AC 110 ms
31,196 KB
testcase_10 AC 108 ms
31,184 KB
testcase_11 AC 109 ms
31,320 KB
testcase_12 AC 111 ms
31,348 KB
testcase_13 AC 110 ms
31,280 KB
testcase_14 AC 110 ms
30,912 KB
testcase_15 AC 113 ms
30,956 KB
testcase_16 AC 109 ms
31,032 KB
testcase_17 AC 109 ms
31,096 KB
testcase_18 AC 109 ms
31,284 KB
testcase_19 AC 112 ms
31,216 KB
testcase_20 AC 115 ms
31,376 KB
testcase_21 AC 113 ms
31,304 KB
testcase_22 AC 112 ms
30,692 KB
testcase_23 AC 110 ms
30,800 KB
testcase_24 AC 110 ms
31,156 KB
testcase_25 AC 110 ms
31,232 KB
testcase_26 AC 113 ms
31,308 KB
testcase_27 AC 112 ms
30,940 KB
testcase_28 AC 112 ms
31,492 KB
testcase_29 AC 111 ms
30,864 KB
testcase_30 AC 110 ms
30,836 KB
testcase_31 AC 111 ms
30,888 KB
testcase_32 AC 111 ms
30,840 KB
testcase_33 AC 110 ms
31,220 KB
testcase_34 AC 111 ms
30,776 KB
testcase_35 AC 110 ms
31,268 KB
testcase_36 AC 111 ms
30,912 KB
testcase_37 AC 111 ms
30,772 KB
testcase_38 AC 112 ms
30,752 KB
testcase_39 AC 111 ms
30,940 KB
testcase_40 AC 110 ms
31,436 KB
testcase_41 AC 113 ms
30,592 KB
testcase_42 AC 111 ms
31,464 KB
testcase_43 AC 111 ms
30,708 KB
testcase_44 AC 108 ms
30,772 KB
testcase_45 AC 109 ms
31,364 KB
testcase_46 AC 110 ms
30,812 KB
testcase_47 AC 112 ms
30,932 KB
testcase_48 AC 111 ms
30,836 KB
testcase_49 AC 110 ms
31,176 KB
testcase_50 AC 110 ms
30,984 KB
testcase_51 AC 111 ms
31,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def send_query(nums)
  STDOUT.puts(nums.join(' '))
  STDOUT.flush
  a, b = gets.chomp.split.map(&:to_i)
  if a == 4
    exit 0
  end
  [a, b]
end

excepted_nums = []
nums = [*0..9]
nums.combination(4).to_a.shuffle.each do |list|
  a, b = send_query(list)

  if a + b == 0
    excepted_nums = list.dup
    break
  end
end

cand = []

10.times do |i|
  next if excepted_nums.include?(i)
  excepted_nums[3] = i
  a, b = send_query(excepted_nums)

  if a + b > 0
    cand << i
  end
end

cand.permutation(4).each do |n|
  send_query(n)
end
0