結果

問題 No.832 麻雀修行中
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-11-05 09:58:12
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 1,131 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 11,048 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-10-13 02:14:57
合計ジャッジ時間 1,998 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,528 KB
testcase_01 WA -
testcase_02 AC 20 ms
8,552 KB
testcase_03 AC 21 ms
8,548 KB
testcase_04 AC 21 ms
8,708 KB
testcase_05 AC 21 ms
8,640 KB
testcase_06 AC 21 ms
8,536 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 22 ms
8,648 KB
testcase_10 AC 21 ms
8,644 KB
testcase_11 AC 20 ms
8,524 KB
testcase_12 AC 21 ms
8,700 KB
testcase_13 WA -
testcase_14 AC 21 ms
8,548 KB
testcase_15 AC 21 ms
8,492 KB
testcase_16 AC 21 ms
8,628 KB
testcase_17 AC 21 ms
8,708 KB
testcase_18 AC 22 ms
8,696 KB
testcase_19 AC 20 ms
8,728 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 21 ms
8,712 KB
testcase_23 AC 21 ms
8,668 KB
testcase_24 AC 21 ms
8,532 KB
testcase_25 AC 22 ms
8,740 KB
testcase_26 AC 21 ms
8,568 KB
testcase_27 AC 21 ms
8,500 KB
testcase_28 AC 21 ms
8,532 KB
testcase_29 AC 19 ms
8,540 KB
testcase_30 AC 21 ms
8,704 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()
    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