結果

問題 No.93 ペガサス
ユーザー mikoto_kannagimikoto_kannagi
提出日時 2017-01-01 01:07:23
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 607 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 20,640 KB
最終ジャッジ日時 2024-05-09 14:39:44
合計ジャッジ時間 7,233 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,160 KB
testcase_01 AC 81 ms
12,416 KB
testcase_02 AC 92 ms
12,416 KB
testcase_03 AC 206 ms
13,696 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = Integer(STDIN.gets.chomp)
next_pattern = (0...n).map{|x| 1 << x}
pattern = {}
(0...n).map{|x| 1 << x}.each do |x|
    next_pattern.each do |y|
        if x & y == 0
            pattern[[x, y, x | y]] = 1
        end
    end
end
(3..n).each do |i|
    new_pattern = {}
    new_pattern.default = 0
    pattern.each do |k, v|
        next_pattern.each do |x|
            if k[2] & x == 0 && k[0] & (x << 1 | x >> 1) == 0
                y = [k[1], x, k[2] | x]
                new_pattern[y] = new_pattern[y] + v
            end
        end
    end
    pattern = new_pattern
end
puts pattern.each_value.sum
0