結果

問題 No.640 76本のトロンボーン
ユーザー pochiMasahiropochiMasahiro
提出日時 2018-02-14 22:43:07
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,412 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,780 KB
実行使用メモリ 9,324 KB
最終ジャッジ日時 2023-09-03 23:31:27
合計ジャッジ時間 1,458 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
8,908 KB
testcase_01 AC 23 ms
8,984 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 22 ms
8,956 KB
testcase_05 AC 22 ms
9,116 KB
testcase_06 AC 23 ms
9,092 KB
testcase_07 AC 23 ms
9,216 KB
testcase_08 AC 23 ms
9,324 KB
testcase_09 AC 24 ms
9,208 KB
testcase_10 AC 23 ms
9,096 KB
testcase_11 AC 23 ms
9,100 KB
testcase_12 AC 23 ms
9,116 KB
testcase_13 AC 22 ms
8,936 KB
testcase_14 AC 24 ms
9,324 KB
testcase_15 AC 23 ms
8,992 KB
testcase_16 AC 22 ms
9,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import functools
import itertools
import copy

def solve():
	N = int(input())
	S = [ input() for _ in range(N) ]

	tmp = copy.deepcopy(S)
	ans_c1 = 0
	for i, s in enumerate(S):
		if '#' not in s[:N-1]:
			ans_c1 += 1
			tmp[i] = (N-1)*'#'+ tmp[i][N-1]
	else:
		st = list(zip(*tmp))
		if '#' not in st[N-1][:N-1] or '#' not in st[N-1][1:]:
			ans_c1 += 1
	

	tmp = copy.deepcopy(S)
	ans_c2 = 0
	for i, s in enumerate(S):
		if '#' not in s[1:N]:
			ans_c2 += 1
			tmp[i] = tmp[i][0] + (N-1)*'#' 
	else:
		st = list(zip(*tmp))
		if '#' not in st[0][:N-1] or '#' not in st[0][1:]:
			ans_c2 += 1
		
	tmp = list(map(list, zip(*S)))
	ans_r1 = 0
	for i, s in enumerate(list(map(list, zip(*S)))):
		if '#' not in s[:N-1]:
			ans_r1 += 1
			tmp[i] = (N-1)*'#' + tmp[i][N-1]
	else:
		st = list(zip(*tmp))
		if '#' not in st[N-1][:N-1] or '#' not in st[N-1][1:]:
			ans_r1 += 1

	tmp = list(zip(*S))
	ans_r2 = 0
	for i, s in enumerate(list(zip(*S))):
		if '#' not in s[1:N]:
			ans_r2 += 1
			tmp[i] = tmp[i][0] + (N-1)*'#' 
	else:
		st = list(zip(*tmp))
		if '#' not in st[0][:N-1] or '#' not in st[0][1:]:
			ans_r2 += 1

	at = sorted([ans_r1, ans_r2, ans_c1, ans_c2])
	
	if at[-1] >= 4:
		print(at[-1])
	else:
		if '#' not in S[0] and '#' not in S[N-1] and '#' not in list(zip(*S))[0] and '#' not in list(zip(*S))[N-1]:
			print(4)
		else:
			print(at[-1])
		

if __name__ == "__main__":
	solve()
0