結果
| 問題 |
No.640 76本のトロンボーン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-25 10:07:07 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 532 ms / 2,000 ms |
| コード長 | 822 bytes |
| コンパイル時間 | 526 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 44,480 KB |
| 最終ジャッジ日時 | 2024-07-21 17:11:57 |
| 合計ジャッジ時間 | 10,777 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 |
ソースコード
import numpy as np
N = int(input())
S = np.array([[s == '.' for s in input()] for _ in range(N)])
def solve(S):
"""左詰め横並べ"""
left = S[:, 0].copy()
right = S[:, -1].copy()
res = 0
for i in range(N):
if np.all(S[i, 1:-1]):
if S[i, 0]:
res += 1
left[i] = False
elif S[i, -1]:
res += 1
right[i] = False
if np.all(left[1:-1]) and (left[0] or left[-1]):
res += 1
if np.all(right[1:-1]) and (right[0] or right[-1]):
res += 1
return res
ans = 0
# ぐるっと一周パターン
if np.all(S[0, :]) and np.all(S[:, 0]) and np.all(S[-1, :]) and np.all(S[:, -1]):
ans = 4
for i in range(4):
ans = max(ans, solve(S))
# 回す
S = np.fliplr(S.T)
print(ans)