結果

問題 No.832 麻雀修行中
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-11-05 09:58:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,131 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-14 23:59:13
合計ジャッジ時間 2,190 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 19 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from itertools import product

S = list(map(int, list(input())))
cntS = Counter(S)
ans = set()

def isOk(B):
    B.sort()
    cntB = Counter(B)
    for i in range(1, 10):
        while cntB[i] > 0:
            for j in range(i, i + 3):
                if cntB[j] == 0:
                    return False
                cntB[j] -= 1
    if all(c == 0 for c in cntB.values()):
        return True
    return False


for add in range(1, 10):
    if cntS[add] == 4:
        continue

    T = S + [add]
    cntT = Counter(T)

    if all(c == 2 for c in cntT.values()):
        ans.add(add)
        continue

    for (h1, h2) in product(range(14), repeat=2):
        if h1 == h2 or T[h1] != T[h2]:
            continue

        A = [t for i, t in enumerate(T) if i != h1 and i != h2]
        cntA = Counter(A)
        for a in A:
            if cntA[a] >= 3:
                cntA[a] -= 3

        B = []
        for s, c in cntA.items():
            B += [s] * c

        if isOk(B):
            ans.add(add)
            break

ans = list(ans)
ans.sort()
for a in ans:
    if cntS[a] <= 3:
        print(a)
0