結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
8,652 KB
testcase_01 AC 123 ms
8,644 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 143 ms
8,592 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 155 ms
8,556 KB
testcase_08 AC 167 ms
8,580 KB
testcase_09 AC 121 ms
8,596 KB
testcase_10 WA -
testcase_11 AC 95 ms
8,552 KB
testcase_12 AC 82 ms
8,644 KB
testcase_13 AC 181 ms
8,652 KB
testcase_14 WA -
testcase_15 AC 165 ms
8,732 KB
testcase_16 AC 125 ms
8,592 KB
testcase_17 AC 140 ms
8,692 KB
testcase_18 AC 151 ms
8,648 KB
testcase_19 AC 111 ms
8,732 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 106 ms
8,732 KB
testcase_23 AC 110 ms
8,560 KB
testcase_24 WA -
testcase_25 AC 214 ms
8,588 KB
testcase_26 AC 106 ms
8,592 KB
testcase_27 WA -
testcase_28 AC 162 ms
8,648 KB
testcase_29 WA -
testcase_30 AC 218 ms
8,600 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