結果

問題 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
コンパイル時間 302 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-05-07 16:55:37
合計ジャッジ時間 2,439 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 32 ms
11,008 KB
testcase_02 AC 32 ms
10,880 KB
testcase_03 AC 32 ms
11,008 KB
testcase_04 AC 32 ms
10,880 KB
testcase_05 AC 32 ms
10,880 KB
testcase_06 AC 32 ms
10,880 KB
testcase_07 AC 32 ms
11,008 KB
testcase_08 AC 32 ms
11,008 KB
testcase_09 AC 32 ms
11,008 KB
testcase_10 AC 32 ms
11,008 KB
testcase_11 AC 32 ms
10,880 KB
testcase_12 AC 32 ms
11,008 KB
testcase_13 AC 32 ms
10,880 KB
testcase_14 AC 32 ms
11,008 KB
testcase_15 AC 32 ms
11,136 KB
testcase_16 AC 33 ms
11,136 KB
testcase_17 AC 32 ms
11,008 KB
testcase_18 AC 32 ms
11,008 KB
testcase_19 AC 33 ms
11,136 KB
testcase_20 AC 33 ms
11,008 KB
testcase_21 AC 32 ms
10,880 KB
testcase_22 WA -
testcase_23 AC 33 ms
10,880 KB
testcase_24 AC 33 ms
10,880 KB
testcase_25 AC 33 ms
11,008 KB
testcase_26 AC 31 ms
11,008 KB
testcase_27 AC 33 ms
11,136 KB
testcase_28 AC 32 ms
11,136 KB
testcase_29 AC 32 ms
11,008 KB
testcase_30 AC 32 ms
10,880 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