結果

問題 No.832 麻雀修行中
ユーザー bellangeldindonbellangeldindon
提出日時 2019-04-25 15:46:52
言語 Python2
(2.7.18)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 1,397 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 7,096 KB
実行使用メモリ 6,108 KB
最終ジャッジ日時 2023-08-15 11:00:31
合計ジャッジ時間 2,850 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,108 KB
testcase_01 AC 13 ms
6,084 KB
testcase_02 AC 12 ms
5,976 KB
testcase_03 AC 15 ms
5,848 KB
testcase_04 AC 12 ms
5,844 KB
testcase_05 AC 11 ms
5,844 KB
testcase_06 AC 11 ms
6,080 KB
testcase_07 AC 13 ms
5,920 KB
testcase_08 AC 14 ms
6,104 KB
testcase_09 AC 13 ms
5,928 KB
testcase_10 AC 14 ms
5,916 KB
testcase_11 AC 14 ms
5,952 KB
testcase_12 AC 14 ms
5,924 KB
testcase_13 AC 10 ms
6,100 KB
testcase_14 AC 13 ms
5,956 KB
testcase_15 AC 13 ms
5,920 KB
testcase_16 AC 11 ms
5,884 KB
testcase_17 AC 11 ms
5,848 KB
testcase_18 AC 12 ms
6,032 KB
testcase_19 AC 13 ms
5,912 KB
testcase_20 AC 13 ms
5,912 KB
testcase_21 AC 14 ms
6,088 KB
testcase_22 AC 12 ms
6,032 KB
testcase_23 AC 12 ms
5,956 KB
testcase_24 AC 12 ms
5,952 KB
testcase_25 AC 11 ms
6,032 KB
testcase_26 AC 11 ms
5,924 KB
testcase_27 AC 12 ms
6,092 KB
testcase_28 AC 10 ms
5,952 KB
testcase_29 AC 15 ms
5,924 KB
testcase_30 AC 12 ms
5,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def judge(tile):
	cnt = 0
	for i in range(0, 9):
		if tile[i] > 4: return False
	for i in range(0, 9):
		if tile[i] == 2: cnt += 1
	if cnt == 7: return True
	pair = []
	for i in range(0, 9):
		if tile[i] >= 2:
			pair.append(i)
	queue = []
	for i in range(0, len(pair)):
		newtile = []
		for j in range(0, 9):
			if j == pair[i]:
				newtile.append(tile[j]-2)
			else:
				newtile.append(tile[j])
		queue.append(newtile)
	while(queue != []):
		now = queue.pop(0)
		flag = True
		for i in range(0, 9):
			if now[i] != 0:
				flag = False
				break
		if flag: return True

		for i in range(0, 9):
			if now[i] >= 3:
				nexttile = []
				for j in range(0, 9):
					if j == i: nexttile.append(now[j]-3)
					else: nexttile.append(now[j])
				if now != nexttile and nexttile not in queue: queue.append(nexttile)
			if i < 7:
				if now[i] >= 1 and now[i+1] >= 1 and now[i+2] >= 1:
					nexttile = []
					for j in range(0, 9):
						if i <= j and j <= i+2:
							nexttile.append(now[j]-1)
						else: nexttile.append(now[j])
					if now != nexttile and nexttile not in queue: queue.append(nexttile)
	return False

S = raw_input()
tiles = []
for i in range(0, 9):
	tiles.append(0)
for i in range(0, 13):
	n = int(S[i])
	tiles[n-1] += 1
for i in range(0, 9):
	newtiles = []
	for j in range(0, 9):
		if i == j: newtiles.append(tiles[j]+1)
		else: newtiles.append(tiles[j])
	if judge(newtiles): print i+1
0