結果

問題 No.832 麻雀修行中
ユーザー aaaaaaaaaa2230
提出日時 2022-06-23 23:31:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,029 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 69,248 KB
最終ジャッジ日時 2024-11-07 17:31:12
合計ジャッジ時間 3,276 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(map(int,input()))

def solve(x):
    nums = [0]*10
    for s in S+[x]:
        nums[s] += 1
    if max(nums) > 4:
        return False
    two = 0
    for i in nums:
        two += i == 2
    if two == 7:
        return True

    for b in range(1<<10):
        nnums = nums[:]
        for i in range(10):
            if b >> i & 1:
                nnums[i] -= 3

        if min(nnums) < 0:
            continue
        record = nnums[:]
        for i in range(10):
            nnums = record[:]
            if nnums[i] < 2:
                continue
            nnums[i] -= 2
            for i in range(8):
                while nnums[i]:
                    if nnums[i]*nnums[i+1]*nnums[i+2]:
                        nnums[i] -= 1
                        nnums[i+1] -= 1
                        nnums[i+2] -= 1
                    else:
                        break
            if sum(nnums) == 0 and max(nnums) == 0:

                return True
    return False
for i in range(1,10):
    if solve(i):
        print(i)
0