結果

問題 No.355 数当てゲーム(2)
ユーザー maimai
提出日時 2017-04-30 12:56:10
言語 Ruby
(3.3.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 11,440 KB
実行使用メモリ 31,932 KB
平均クエリ数 5.56
最終ジャッジ日時 2023-09-24 01:00:49
合計ジャッジ時間 8,152 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
31,380 KB
testcase_01 AC 106 ms
31,624 KB
testcase_02 AC 94 ms
31,384 KB
testcase_03 AC 100 ms
31,644 KB
testcase_04 AC 99 ms
31,504 KB
testcase_05 AC 95 ms
31,348 KB
testcase_06 AC 94 ms
31,588 KB
testcase_07 AC 95 ms
31,232 KB
testcase_08 AC 94 ms
31,312 KB
testcase_09 AC 95 ms
31,916 KB
testcase_10 AC 95 ms
31,084 KB
testcase_11 AC 95 ms
31,264 KB
testcase_12 AC 93 ms
31,632 KB
testcase_13 AC 93 ms
31,256 KB
testcase_14 AC 93 ms
31,448 KB
testcase_15 AC 97 ms
31,888 KB
testcase_16 AC 95 ms
31,644 KB
testcase_17 AC 96 ms
31,588 KB
testcase_18 AC 97 ms
31,444 KB
testcase_19 AC 97 ms
31,576 KB
testcase_20 AC 96 ms
31,232 KB
testcase_21 AC 96 ms
31,588 KB
testcase_22 AC 96 ms
31,828 KB
testcase_23 AC 97 ms
31,428 KB
testcase_24 AC 95 ms
31,204 KB
testcase_25 AC 95 ms
31,192 KB
testcase_26 AC 98 ms
31,172 KB
testcase_27 AC 93 ms
31,464 KB
testcase_28 AC 96 ms
31,552 KB
testcase_29 AC 94 ms
31,436 KB
testcase_30 AC 96 ms
31,388 KB
testcase_31 AC 97 ms
31,160 KB
testcase_32 AC 97 ms
31,344 KB
testcase_33 AC 98 ms
31,412 KB
testcase_34 AC 96 ms
31,216 KB
testcase_35 AC 94 ms
31,292 KB
testcase_36 AC 94 ms
31,932 KB
testcase_37 AC 95 ms
31,796 KB
testcase_38 AC 95 ms
31,412 KB
testcase_39 AC 102 ms
31,388 KB
testcase_40 AC 93 ms
31,424 KB
testcase_41 AC 95 ms
31,248 KB
testcase_42 AC 94 ms
31,816 KB
testcase_43 AC 94 ms
31,696 KB
testcase_44 AC 96 ms
31,740 KB
testcase_45 AC 96 ms
31,184 KB
testcase_46 AC 95 ms
31,156 KB
testcase_47 AC 97 ms
31,728 KB
testcase_48 AC 97 ms
31,660 KB
testcase_49 AC 97 ms
31,472 KB
testcase_50 AC 94 ms
31,388 KB
testcase_51 AC 94 ms
31,480 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

answer = []
(0..9).to_a.combination(4){|_v|
    _v.permutation{|v|
        answer << v
    }
}

def simulate(answer,query)
    x=y=0
    4.times{|i|
        if answer[i] == query[i]
            x+=1
        elsif answer.include?(query[i])
            y+=1
        end
    }
    return [x,y]
end

def send(v)
    puts v*" " ; STDOUT.flush
    return gets.split.map(&:to_i)
end

while answer.size > 1
    v = answer.sample
    res = send(v)
    exit 0 if res == [4,0]
    answer.delete_if{|e| simulate(e,v) != res}
end

abort if answer.size == 0

puts answer[0]*" " ; STDOUT.flush
0