結果

問題 No.832 麻雀修行中
ユーザー Coki628Coki628
提出日時 2020-08-16 18:59:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 2,379 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 82,888 KB
実行使用メモリ 57,708 KB
最終ジャッジ日時 2024-04-19 18:28:38
合計ジャッジ時間 2,402 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
56,508 KB
testcase_01 AC 43 ms
55,812 KB
testcase_02 AC 42 ms
56,704 KB
testcase_03 AC 44 ms
56,764 KB
testcase_04 AC 42 ms
57,260 KB
testcase_05 AC 42 ms
56,112 KB
testcase_06 AC 42 ms
57,676 KB
testcase_07 AC 43 ms
55,952 KB
testcase_08 AC 40 ms
57,176 KB
testcase_09 AC 41 ms
57,708 KB
testcase_10 AC 42 ms
56,508 KB
testcase_11 AC 42 ms
57,384 KB
testcase_12 AC 43 ms
56,360 KB
testcase_13 AC 41 ms
56,788 KB
testcase_14 AC 42 ms
56,152 KB
testcase_15 AC 40 ms
55,588 KB
testcase_16 AC 42 ms
57,068 KB
testcase_17 AC 39 ms
56,568 KB
testcase_18 AC 40 ms
55,948 KB
testcase_19 AC 40 ms
57,424 KB
testcase_20 AC 39 ms
55,184 KB
testcase_21 AC 41 ms
56,600 KB
testcase_22 AC 41 ms
55,888 KB
testcase_23 AC 39 ms
56,572 KB
testcase_24 AC 40 ms
56,232 KB
testcase_25 AC 39 ms
56,728 KB
testcase_26 AC 39 ms
56,956 KB
testcase_27 AC 39 ms
55,676 KB
testcase_28 AC 39 ms
56,796 KB
testcase_29 AC 40 ms
56,104 KB
testcase_30 AC 40 ms
56,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

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

def check1(C):
    for v in C.values():
        if v >= 5:
            return False
    return True

def check2(C, x):
    for i in range(1, 8):
        while C[i] > 0 and C[i+1] > 0 and C[i+2] > 0:
            if x in [i, i+1, i+2] and C[x]-1 < 2:
                break
            C[i] -= 1
            C[i+1] -= 1
            C[i+2] -= 1
    tmp = []
    for k in C:
        if not C[k]:
            tmp.append(k)
        if k == x:
            if C[k] % 3 == 2:
                tmp.append(k)
        else:
            if C[k] % 3 == 0:
                tmp.append(k)
    for k in tmp:
        del C[k]
    if not C:
        return True
    else:
        return False

def check3(C, x):
    for k in C:
        if k == x:
            while C[k]-3 >= 2:
                C[k] -= 3
        else:
            C[k] %= 3
    for i in range(1, 8):
        while C[i] > 0 and C[i+1] > 0 and C[i+2] > 0:
            if x in [i, i+1, i+2] and C[x]-1 < 2:
                break
            C[i] -= 1
            C[i+1] -= 1
            C[i+2] -= 1
    tmp = []
    for k in C:
        if not C[k]:
            tmp.append(k)
    for k in tmp:
        del C[k]
    if len(C) == 1:
        return True
    else:
        return False

def check4(C):
    for v in C.values():
        if v != 2:
            return False
    return True

ans = []
for num in range(1, 10):
    C = Counter(S+[num])

    if not check1(C.copy()):
        continue
    if check4(C.copy()):
        ans.append(num)
        continue
    for k in C:
        if check2(C.copy(), k) or check3(C.copy(), k):
            ans.append(num)
            break
for a in ans:
    print(a)
0