結果
問題 | No.832 麻雀修行中 |
ユーザー | Coki628 |
提出日時 | 2020-08-16 18:59:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 2,379 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 82,468 KB |
実行使用メモリ | 56,192 KB |
最終ジャッジ日時 | 2024-10-11 10:39:01 |
合計ジャッジ時間 | 2,663 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
55,168 KB |
testcase_01 | AC | 50 ms
55,168 KB |
testcase_02 | AC | 47 ms
54,912 KB |
testcase_03 | AC | 46 ms
55,552 KB |
testcase_04 | AC | 47 ms
55,168 KB |
testcase_05 | AC | 46 ms
55,552 KB |
testcase_06 | AC | 47 ms
55,808 KB |
testcase_07 | AC | 46 ms
55,168 KB |
testcase_08 | AC | 46 ms
55,552 KB |
testcase_09 | AC | 52 ms
55,296 KB |
testcase_10 | AC | 46 ms
55,424 KB |
testcase_11 | AC | 47 ms
56,192 KB |
testcase_12 | AC | 47 ms
55,680 KB |
testcase_13 | AC | 46 ms
55,296 KB |
testcase_14 | AC | 45 ms
55,808 KB |
testcase_15 | AC | 46 ms
55,808 KB |
testcase_16 | AC | 46 ms
55,424 KB |
testcase_17 | AC | 45 ms
55,296 KB |
testcase_18 | AC | 48 ms
55,296 KB |
testcase_19 | AC | 47 ms
55,808 KB |
testcase_20 | AC | 46 ms
55,168 KB |
testcase_21 | AC | 48 ms
55,936 KB |
testcase_22 | AC | 47 ms
55,680 KB |
testcase_23 | AC | 46 ms
55,552 KB |
testcase_24 | AC | 46 ms
55,296 KB |
testcase_25 | AC | 45 ms
55,040 KB |
testcase_26 | AC | 46 ms
55,568 KB |
testcase_27 | AC | 44 ms
55,040 KB |
testcase_28 | AC | 45 ms
55,168 KB |
testcase_29 | AC | 45 ms
55,424 KB |
testcase_30 | AC | 45 ms
55,552 KB |
ソースコード
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)