結果
| 問題 |
No.832 麻雀修行中
|
| コンテスト | |
| ユーザー |
YamaKasa
|
| 提出日時 | 2022-01-24 22:59:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 984 bytes |
| コンパイル時間 | 294 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-12-15 02:31:25 |
| 合計ジャッジ時間 | 2,517 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 25 |
ソースコード
import copy
a = [0] * 9
s = list(map(int, input()))
tot = sum(s) - 13
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):
k1 = 0
k2 = 0
for i in range(7):
if p[i] - k1 - k2 < 0:
return False
k0 = (p[i] - k1 - k2) % 3
if p[i+1] - k0 - k1 < 0 or p[i+2] - k0 < 0:
return False
k2 = k1
k1 = k0
if (p[7] - k1 - k2) % 3 != 0 or (p[8] - k1) % 3 != 0:
return False
return True
def check(p):
for i in range((tot % 3) * 2 % 3, 9, 3):
if p[i] >= 2:
p[i] -= 2
if can_decomp(p):
p[i] += 2
return True
p[i] += 2
return False
for i in range(9):
if a[i] == 4: continue
a[i] += 1
tot += i
if seven_pairs(a):
print(i + 1)
elif check(a):
print(i + 1)
a[i] -= 1
tot -= i
YamaKasa