結果
| 問題 | No.355 数当てゲーム(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-19 20:39:16 |
| 言語 | Ruby (3.4.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 772 bytes |
| コンパイル時間 | 207 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 29,384 KB |
| 平均クエリ数 | 16.83 |
| 最終ジャッジ日時 | 2024-07-16 11:15:35 |
| 合計ジャッジ時間 | 13,479 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 31 RE * 2 |
コンパイルメッセージ
Main.rb:47: warning: statement not reached Syntax OK
ソースコード
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 = [2, 4, 6, 8]
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)
if res == [4, 0]
break
exit 0
end
end