結果

問題 No.640 76本のトロンボーン
ユーザー pochiMasahiropochiMasahiro
提出日時 2018-02-14 22:35:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,374 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 9,372 KB
最終ジャッジ日時 2023-08-24 21:55:07
合計ジャッジ時間 1,369 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
9,104 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 22 ms
8,996 KB
testcase_05 AC 22 ms
9,008 KB
testcase_06 AC 23 ms
9,092 KB
testcase_07 AC 23 ms
9,232 KB
testcase_08 WA -
testcase_09 AC 23 ms
9,308 KB
testcase_10 AC 22 ms
9,300 KB
testcase_11 AC 23 ms
9,164 KB
testcase_12 AC 23 ms
9,156 KB
testcase_13 AC 21 ms
9,024 KB
testcase_14 AC 22 ms
9,164 KB
testcase_15 WA -
testcase_16 AC 22 ms
9,140 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[0] or '#' not in st[N-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] or '#' not in st[N-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[0] or '#' not in st[N-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] or '#' not in st[N-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