結果

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

ソースコード

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()
    if len(B) == 0:
        return True
    if len(B) == 3 and B[1] == B[0] + 1 and B[2] == B[0] + 2:
        return True
    if len(B) == 6 and all(B[i + 2] == B[i] + 1 and B[i + 4] == B[i] + 2 for i in range(2)):
        return True
    if len(B) == 6:
        for i in range(2):
            C = B[i * 3: (i + 1) * 3]
            if C[1] == C[0] + 1 and C[2] == C[0] + 2:
                continue
            break
        else:
            return True
    if len(B) == 9:
        for i in range(3):
            C = B[i * 3: (i + 1) * 3]
            if C[1] == C[0] + 1 and C[2] == C[0] + 2:
                continue
            break
        else:
            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