結果

問題 No.832 麻雀修行中
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-11-05 10:04:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 295 ms / 2,000 ms
コード長 1,427 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 8,700 KB
最終ジャッジ日時 2023-10-13 02:15:24
合計ジャッジ時間 5,827 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
8,640 KB
testcase_01 AC 126 ms
8,640 KB
testcase_02 AC 144 ms
8,692 KB
testcase_03 AC 103 ms
8,588 KB
testcase_04 AC 144 ms
8,588 KB
testcase_05 AC 134 ms
8,640 KB
testcase_06 AC 137 ms
8,588 KB
testcase_07 AC 158 ms
8,592 KB
testcase_08 AC 169 ms
8,560 KB
testcase_09 AC 123 ms
8,512 KB
testcase_10 AC 131 ms
8,520 KB
testcase_11 AC 94 ms
8,556 KB
testcase_12 AC 82 ms
8,592 KB
testcase_13 AC 186 ms
8,548 KB
testcase_14 AC 112 ms
8,584 KB
testcase_15 AC 166 ms
8,608 KB
testcase_16 AC 124 ms
8,644 KB
testcase_17 AC 140 ms
8,636 KB
testcase_18 AC 153 ms
8,552 KB
testcase_19 AC 112 ms
8,544 KB
testcase_20 AC 149 ms
8,588 KB
testcase_21 AC 123 ms
8,700 KB
testcase_22 AC 105 ms
8,596 KB
testcase_23 AC 110 ms
8,588 KB
testcase_24 AC 167 ms
8,596 KB
testcase_25 AC 223 ms
8,560 KB
testcase_26 AC 107 ms
8,592 KB
testcase_27 AC 295 ms
8,696 KB
testcase_28 AC 164 ms
8,648 KB
testcase_29 AC 98 ms
8,608 KB
testcase_30 AC 223 ms
8,608 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 mask in range(1 << 10):
            for d in range(1, 10):
                if (mask & (1 << (d - 1))) > 0:
                    if cntA[d] < 3:
                        break
            else:
                B = []
                for s, c in cntA.items():
                    if (mask & (1 << (s - 1))) > 0:
                        B += [s] * (c - 3)
                    else:
                        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