結果

問題 No.832 麻雀修行中
ユーザー letrangerjpletrangerjp
提出日時 2019-05-24 22:48:04
言語 Ruby
(3.3.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 16,060 KB
最終ジャッジ日時 2023-10-17 13:02:33
合計ジャッジ時間 3,718 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
16,060 KB
testcase_01 AC 89 ms
16,060 KB
testcase_02 AC 85 ms
16,060 KB
testcase_03 AC 86 ms
16,060 KB
testcase_04 AC 85 ms
16,060 KB
testcase_05 AC 84 ms
16,060 KB
testcase_06 AC 85 ms
16,060 KB
testcase_07 AC 84 ms
16,060 KB
testcase_08 AC 82 ms
16,060 KB
testcase_09 AC 82 ms
16,060 KB
testcase_10 AC 82 ms
16,060 KB
testcase_11 AC 83 ms
16,060 KB
testcase_12 AC 84 ms
16,060 KB
testcase_13 AC 83 ms
16,060 KB
testcase_14 AC 84 ms
16,060 KB
testcase_15 AC 83 ms
16,060 KB
testcase_16 AC 83 ms
16,060 KB
testcase_17 AC 83 ms
16,060 KB
testcase_18 AC 82 ms
16,060 KB
testcase_19 AC 83 ms
16,060 KB
testcase_20 AC 84 ms
16,060 KB
testcase_21 AC 89 ms
16,060 KB
testcase_22 AC 86 ms
16,060 KB
testcase_23 AC 84 ms
16,060 KB
testcase_24 AC 82 ms
16,060 KB
testcase_25 AC 82 ms
16,060 KB
testcase_26 AC 82 ms
16,060 KB
testcase_27 AC 82 ms
16,060 KB
testcase_28 AC 83 ms
16,060 KB
testcase_29 AC 85 ms
16,060 KB
testcase_30 AC 83 ms
16,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: `*' interpreted as argument prefix
Syntax OK

ソースコード

diff #

S = gets.chomp.chars.map &:to_i
p *(1..9).select{|i|
  a = S + [i]
  h = a.group_by(&:itself).map{|k, v| [k, v.size] }.to_h
  h.default = 0
  next if (1..9).any?{|j| h[j] > 4 }
  # 七対子
  if h.all?{|k, v| v == 2 }
    true
  else
    (1..9).any?{|j|
      next if h[j] < 2
      g = h.dup
      g[j] -= 2
      f = ->n{
        return g.all?{|k, v| v == 0 } if n > 9
        if g[n] == 0
          f[n+1]
        else
          (if n <= 7 && g[n] > 0 && g[n+1] > 0 && g[n+2] > 0
            g[n] -= 1
            g[n+1] -= 1
            g[n+2] -= 1
            f[n].tap{
              g[n] += 1
              g[n+1] += 1
              g[n+2] += 1
            }
          end) ||
          (if g[n] >= 3
            g[n] -= 3
            f[n].tap{ g[n] += 3 }
          end)
        end
      }
      f[1]
    }
  end
}
0