Skip to content

Instantly share code, notes, and snippets.

@monchy-monchy
Created August 13, 2021 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monchy-monchy/8fd47a903ac0067a2a2f1f86d7d2e457 to your computer and use it in GitHub Desktop.
Save monchy-monchy/8fd47a903ac0067a2a2f1f86d7d2e457 to your computer and use it in GitHub Desktop.
ABC107 B - Grid Compression
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