結果

問題 No.832 麻雀修行中
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-11-05 09:49:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,533 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 8,900 KB
最終ジャッジ日時 2023-10-13 02:14:55
合計ジャッジ時間 3,062 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 21 ms
8,844 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 21 ms
8,676 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 20 ms
8,704 KB
testcase_17 AC 20 ms
8,780 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 21 ms
8,704 KB
testcase_23 WA -
testcase_24 AC 21 ms
8,756 KB
testcase_25 AC 22 ms
8,820 KB
testcase_26 AC 20 ms
8,764 KB
testcase_27 AC 21 ms
8,832 KB
testcase_28 AC 21 ms
8,836 KB
testcase_29 AC 20 ms
8,676 KB
testcase_30 AC 21 ms
8,792 KB
権限があれば一括ダウンロードができます

ソースコード

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