結果
問題 |
No.355 数当てゲーム(2)
|
ユーザー |
|
提出日時 | 2016-06-01 14:30:40 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 682 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 29,392 KB |
平均クエリ数 | 12.25 |
最終ジャッジ日時 | 2024-07-16 10:15:49 |
合計ジャッジ時間 | 15,489 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 49 |
コンパイルメッセージ
Main.rb:23: warning: assigned but unused variable - x Syntax OK
ソースコード
def query(q) puts q*" ";STDOUT.flush x,y=gets.split(" ").map(&:to_i) exit if x==4 return [x,y] end ng=[] mem=[] ymax=0 (0..9).to_a.combination(4){|ce| next if ng.inject(false){|s,e|s=s||ce.include?(e)} flg=false mem.each{|e| flg =flg|| (ce&e).size < ymax # 一致数 } next if flg ce.permutation(4){|pe| x,y=query(pe) if pe==ce if y==0 ce.each{|e| ng.push(e)} elsif y>ymax ymax=y mem.clear mem.push(ce) else mem.push(ce) end break if y!=4 end } } puts "fin"