Created
August 13, 2021 02:26
-
-
Save monchy-monchy/8fd47a903ac0067a2a2f1f86d7d2e457 to your computer and use it in GitHub Desktop.
ABC107 B - Grid Compression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
H, W = list(map(int, input().split())) | |
A = [] | |
for h in range(H): | |
a = list(input()) | |
A.append(a) | |
row = [False] * H | |
col = [False] * W | |
for i in range(H): | |
for j in range(W): | |
if A[i][j] == "#": | |
row[i] = True | |
col[j] = True | |
for h in range(H): | |
if row[h]: | |
for w in range(W): | |
if col[w]: | |
print(A[h][w], end="") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment