結果

問題 No.832 麻雀修行中
ユーザー YamaKasaYamaKasa
提出日時 2022-01-24 02:34:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,075 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 8,596 KB
最終ジャッジ日時 2023-08-20 09:53:07
合計ジャッジ時間 3,236 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 19 ms
8,396 KB
testcase_02 AC 20 ms
8,408 KB
testcase_03 AC 19 ms
8,572 KB
testcase_04 AC 19 ms
8,416 KB
testcase_05 AC 19 ms
8,528 KB
testcase_06 AC 19 ms
8,512 KB
testcase_07 AC 20 ms
8,516 KB
testcase_08 AC 19 ms
8,336 KB
testcase_09 AC 19 ms
8,404 KB
testcase_10 AC 19 ms
8,516 KB
testcase_11 AC 19 ms
8,472 KB
testcase_12 AC 20 ms
8,416 KB
testcase_13 AC 19 ms
8,468 KB
testcase_14 AC 19 ms
8,580 KB
testcase_15 AC 19 ms
8,408 KB
testcase_16 AC 19 ms
8,532 KB
testcase_17 AC 19 ms
8,516 KB
testcase_18 AC 19 ms
8,404 KB
testcase_19 AC 19 ms
8,496 KB
testcase_20 AC 19 ms
8,404 KB
testcase_21 AC 19 ms
8,468 KB
testcase_22 WA -
testcase_23 AC 20 ms
8,532 KB
testcase_24 AC 19 ms
8,420 KB
testcase_25 AC 19 ms
8,596 KB
testcase_26 AC 19 ms
8,496 KB
testcase_27 AC 19 ms
8,404 KB
testcase_28 AC 19 ms
8,412 KB
testcase_29 AC 19 ms
8,516 KB
testcase_30 AC 19 ms
8,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy

a = [0] * 9
s = list(map(int,input()))
for i in s:
    a[i - 1] += 1


def seven_pairs(a):
    cnt = 0
    for i in range(9):
        if a[i] == 2: cnt += 1
    return cnt == 7


def can_decomp(p):
    cnt = 0
    for i in range(9):
        if p[i] >= 3:
            cnt += 1
            p[i] -= 3
        if i < 7:
            if p[i] >= 2 and p[i+1] >= 2 and p[i+2] >= 2:
                cnt += 2
                p[i] -= 2
                p[i + 1] -= 2
                p[i + 2] -= 2
            elif p[i] >= 1 and p[i+1] >= 1 and p[i+2] >= 1:
                cnt += 1
                p[i] -= 1
                p[i + 1] -= 1
                p[i + 2] -= 1
    return cnt == 4


def check(p):
    for i in range(9):
        if p[i] >= 2:
            p[i] -= 2
            if can_decomp(copy.deepcopy(p)):
                return True
            p[i] += 2
    return False


for i in range(9):
    if a[i] == 4: continue
    a[i] += 1
    if seven_pairs(a):
        print(i + 1)
        continue
    if check(copy.deepcopy(a)):
        print(i + 1)

    a[i] -= 1
0