結果

問題 No.459 C-VS for yukicoder
ユーザー compass19compass19
提出日時 2016-12-10 01:24:13
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 1,490 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 23,548 KB
最終ジャッジ日時 2023-08-19 06:49:11
合計ジャッジ時間 6,342 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,820 KB
testcase_01 AC 16 ms
7,816 KB
testcase_02 AC 16 ms
7,952 KB
testcase_03 AC 16 ms
7,908 KB
testcase_04 AC 16 ms
7,816 KB
testcase_05 AC 15 ms
7,904 KB
testcase_06 AC 16 ms
7,876 KB
testcase_07 AC 17 ms
7,776 KB
testcase_08 AC 16 ms
7,764 KB
testcase_09 AC 16 ms
7,760 KB
testcase_10 AC 16 ms
7,856 KB
testcase_11 AC 16 ms
8,356 KB
testcase_12 AC 17 ms
7,932 KB
testcase_13 AC 16 ms
7,864 KB
testcase_14 AC 16 ms
7,764 KB
testcase_15 AC 23 ms
8,644 KB
testcase_16 AC 20 ms
8,580 KB
testcase_17 AC 17 ms
8,296 KB
testcase_18 AC 17 ms
8,192 KB
testcase_19 AC 17 ms
8,248 KB
testcase_20 AC 17 ms
8,304 KB
testcase_21 AC 284 ms
23,548 KB
testcase_22 AC 270 ms
23,464 KB
testcase_23 AC 269 ms
21,472 KB
testcase_24 AC 107 ms
13,496 KB
testcase_25 AC 76 ms
10,992 KB
testcase_26 AC 81 ms
9,916 KB
testcase_27 AC 61 ms
10,048 KB
testcase_28 AC 59 ms
11,044 KB
testcase_29 AC 115 ms
13,104 KB
testcase_30 AC 69 ms
10,044 KB
testcase_31 AC 69 ms
11,024 KB
testcase_32 AC 25 ms
8,764 KB
testcase_33 AC 76 ms
11,488 KB
testcase_34 AC 91 ms
12,036 KB
testcase_35 AC 27 ms
8,796 KB
testcase_36 AC 84 ms
11,484 KB
testcase_37 AC 26 ms
8,516 KB
testcase_38 AC 79 ms
11,548 KB
testcase_39 AC 26 ms
8,616 KB
testcase_40 AC 63 ms
10,604 KB
testcase_41 AC 23 ms
8,488 KB
testcase_42 AC 61 ms
10,364 KB
testcase_43 AC 84 ms
11,488 KB
testcase_44 AC 31 ms
9,224 KB
testcase_45 AC 30 ms
9,016 KB
testcase_46 AC 29 ms
8,828 KB
testcase_47 AC 24 ms
8,568 KB
testcase_48 AC 85 ms
11,508 KB
testcase_49 AC 25 ms
8,516 KB
testcase_50 AC 74 ms
11,240 KB
testcase_51 AC 25 ms
8,924 KB
testcase_52 AC 45 ms
9,644 KB
testcase_53 AC 28 ms
8,788 KB
testcase_54 AC 78 ms
11,564 KB
testcase_55 AC 41 ms
9,216 KB
testcase_56 AC 63 ms
10,516 KB
testcase_57 AC 26 ms
8,960 KB
testcase_58 AC 95 ms
11,716 KB
testcase_59 AC 31 ms
9,268 KB
testcase_60 AC 44 ms
9,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# データ入力
h, w, n = map(int, input().split())
s = [0 for _ in range(w)]
for i in range(h):
	for k, elm in enumerate(list(input())): 
		if elm == '#': 
			s[k] += 1

c_tmp = [int(input()) for _ in range(n)]


# パック情報
# pack_dic[pack]: dict.
pack_dic = { pack: {'left': c_tmp[pack], 'elm': [0, 0, 0], 'sum': 0} for pack in range(n)}


# 列の情報の入力
# column_list[column] = list(columnに影響するpack_number)
column_list = [list() for _ in range(w)]
for pack, left in enumerate(c_tmp):
	column_list[left].append(pack)
	column_list[left+1].append(pack)
	column_list[left+2].append(pack)


# main(詰め込み)
for column in range(w):
	sorted_temp_list = sorted(column_list[column], \
							  key=lambda x: (pack_dic[x]['sum'], pack_dic[x]['left']))

	# 列columnについて、そのcolumnに影響するpackを
	# 現時点でのpackの要素の合計が少ない順に#を詰める(要素が全くないpackをなくすため)
	stock = s[column]
	while stock != 0:
		for pack in sorted_temp_list:
			left = pack_dic[pack]['left']
			pack_dic[pack]['elm'][column-left] += 1
			pack_dic[pack]['sum'] += 1
			stock -= 1
			if stock == 0:
				break


# パックの表示
def pack_print(_list):
	left, center, right = _list
	for _ in range(3):
		s = str()
		s += '#' if left > 0 else '.'
		s += '#' if center > 0 else '.'
		s += '#' if right > 0 else '.'
		print(s)
		left -= 1
		center -= 1
		right -= 1

for pack in range(n):
	pack_print(pack_dic[pack]['elm'])
0