結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,964 KB
testcase_01 AC 21 ms
8,980 KB
testcase_02 AC 20 ms
8,912 KB
testcase_03 AC 20 ms
8,964 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 21 ms
8,932 KB
testcase_08 AC 21 ms
9,040 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 21 ms
8,920 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 20 ms
8,796 KB
testcase_16 AC 20 ms
9,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import functools
import itertools

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

	tmp = 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] or '#' not in st[1:N]:
			ans_c1 += 1

	tmp = 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[:N-1] or '#' not in st[1:N]:
			ans_c2 += 1
		
	tmp = list(zip(*S))
	ans_r1 = 0
	for i, s in enumerate(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] or '#' not in st[1:N]:
			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[:N-1] or '#' not in st[1:N]:
			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] and '#' not in list(zip(*S))[0] and '#' not in list(zip(*S))[N]:
			print(4)
		else:
			print(at[-1])
		

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