結果

問題 No.832 麻雀修行中
ユーザー htkbhtkb
提出日時 2019-05-24 22:21:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 11,856 KB
実行使用メモリ 10,260 KB
最終ジャッジ日時 2023-10-17 12:52:07
合計ジャッジ時間 2,622 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,256 KB
testcase_01 AC 34 ms
10,256 KB
testcase_02 AC 32 ms
10,256 KB
testcase_03 AC 39 ms
10,256 KB
testcase_04 AC 35 ms
10,256 KB
testcase_05 AC 34 ms
10,256 KB
testcase_06 AC 35 ms
10,256 KB
testcase_07 AC 39 ms
10,256 KB
testcase_08 AC 36 ms
10,256 KB
testcase_09 AC 34 ms
10,256 KB
testcase_10 AC 40 ms
10,256 KB
testcase_11 AC 35 ms
10,256 KB
testcase_12 AC 42 ms
10,256 KB
testcase_13 AC 31 ms
10,256 KB
testcase_14 AC 34 ms
10,256 KB
testcase_15 AC 35 ms
10,256 KB
testcase_16 AC 31 ms
10,256 KB
testcase_17 AC 31 ms
10,256 KB
testcase_18 AC 34 ms
10,256 KB
testcase_19 AC 40 ms
10,256 KB
testcase_20 AC 32 ms
10,256 KB
testcase_21 AC 36 ms
10,256 KB
testcase_22 AC 31 ms
10,256 KB
testcase_23 AC 32 ms
10,256 KB
testcase_24 AC 34 ms
10,256 KB
testcase_25 AC 32 ms
10,256 KB
testcase_26 AC 31 ms
10,256 KB
testcase_27 AC 32 ms
10,260 KB
testcase_28 AC 29 ms
10,256 KB
testcase_29 AC 29 ms
10,256 KB
testcase_30 AC 31 ms
10,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter


def check(c: Counter):
    for i in range(1, 10):
        if c[i] >= 3:
            c2 = c.copy()
            c2[i] -= 3
            if check(c2):
                return True
        if c[i] and c[i+1] and c[i+2]:
            c2 = c.copy()
            c2[i] -= 1
            c2[i+1] -= 1
            c2[i+2] -= 1
            if check(c2):
                return True

    return c.most_common(2)[0][1] == 2 and c.most_common(2)[1][1] == 0


def solve():
    counter = Counter(map(int, input()))
    for i in range(1, 10):
        if counter[i] == 4:
            continue
        counter[i] += 1
        if all(v == 2 for v in counter.values() if v) or check(counter.copy()):
            print(i)
        counter[i] -= 1


if __name__ == "__main__":
    solve()
0