Problem:


Score : 200 points

Problem Statement

There is a grid of squares with H horizontal rows and W vertical columns.
The square at the i-th row from the top and the j-th column from the left is represented as (i, j).
Each square is black or white.
The color of the square is given as an H-by-W matrix (a_{i, j}).
If a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.

Snuke is compressing this grid.
He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:

Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.

It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.
Find the final state of the grid.

Constraints

1 \leq H, W \leq 100

a_{i, j} is . or #.

There is at least one black square in the whole grid.

Input

Input is given from Standard Input in the following format:

H W
a_{1, 1}...a_{1, W}
:
a_{H, 1}...a_{H, W}

Output

Print the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.

Sample Input 1

4 4
##.#
....
##.#
.#.#

Sample Output 1

###
###
.##

The second row and the third column in the original grid will be removed.

Sample Input 2

3 3
#..
.#.
..#

Sample Output 2

#..
.#.
..#

As there is no row or column that consists only of white squares, no operation will be performed.

Sample Input 3

4 5
.....
.....
..#..
.....

Sample Output 3

#

Sample Input 4

7 6
......
....#.
.#....
..#...
..#...
......
.#..#.

Sample Output 4

..#
#..
.#.
.#.
#.#



Sample input:
4 4
##.#
....
##.#
.#.#


Sample output:
###
###
.##

Submission status: Wrong Answer

Solution code:
import sys
targetlist = []
inphead = input()
num = inphead.split(' ')
i = int(num[0])
j = int(num[1])

for i in range(i):
	smalllist = list(input())
	targetlist.append(smalllist)

flag = 0
while flag == 0:
	iflag = 0
	jflag = 0
	if targetlist:
		deletelist = []
		for row in range(i):
			if all((elem == '.') for elem in targetlist[row]):
				deletelist.append(row)
		if deletelist:
			for d in reversed(deletelist):
				targetlist.pop(d)
			i = len(targetlist)
		else:
			iflag = 1
		deletelistcol = []
		for col in range(j):
			templist = []
			for row in range(i):
				templist.append(targetlist[row][col])
			if all((elem == '.') for elem in templist):
				deletelistcol.append(col)
		if deletelistcol:
			for d in reversed(deletelistcol):
				for row in range(i):
					targetlist[row].pop(d)
			j = len(targetlist[0])
		else:
			jflag = 1
	if iflag * jflag == 1:
		flag = 1



for rowlist in targetlist:
	result = ''
	for elem in rowlist:
		result += elem
	print(result)

Submission status: Wrong Answer

Solution code:
h, w = input().split()
h, w = int(h), int(w)

inp = [input() for i in range(h)]

c = [x for x in inp if '#' in x]

bad = []

for i in range(len(c)):
    can = False
    for j in c:
        if j[i] == '#':
            can = True
    if not can:
        bad.append(i)

for i in c:
    for j in range(len(c[0])):
        if j not in bad:
            print(i[j], end="")
    print("")

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = [input() for i in range(h)]

c = []

for i in range(w):
  temp = []
  for s in a:
    temp.append(s[i])
  if len(set(temp)) == 1:
    c.append(i)

for s in a:
  if len(set(s)) == 1:
    continue
  ans = ""
  for i in range(w):
    if i not in c:
      ans += s[i]
  print(ans)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

L = []
R = []

for i in range(H):
  R_cnt = 0
  for j in range(W):
    if A[i][j] == '.':
      R_cnt += 1
  if R_cnt == W:
    R.append(i)

for j in range(W):
  L_cnt = 0
  for i in range(H):
    if A[i][j] == '.':
      L_cnt += 1
  if L_cnt == H:
    L.append(j)

for i in range(H):
  S = []
  for j in range(W):
    if i in R or j in L:
      break
    else:
      S.append(A[i][j])
  if len(S) > 0:
    print(''.join(S))

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

L = []
R = []

for i in range(H):
  R_cnt = 0
  for j in range(W):
    if A[i][j] == '.':
      R_cnt += 1
  if R_cnt == W:
    R.append(i)

for j in range(W):
  L_cnt = 0
  for i in range(H):
    if A[i][j] == '.':
      L_cnt += 1
  if L_cnt == H:
    L.append(j)

for i in range(H):
  S = []
  for j in range(W):
    if i in R or j in L:
      break
    else:
      S.append(A[i][j])
  if len(S) > 0:
    print(' '.join(S))

Submission status: Wrong Answer

Solution code:
from collections import Counter
h, w = map(int, input().split(" "))
a = [input() for i in range(h)]
rc = [i for i in range(h) if len(Counter(a[i]).most_common()) > 1]
rw = [i for i in range(w) if len(Counter(''.join(x[i] for x in a)).most_common()) > 1]
a = '\n'.join(''.join(a[j][i] for i in rw) for j in rc)
print(a)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
g = []
ans = []
for _ in range(h):
    s = [c for c in input()]
    g.append(s)
del_col = []
for j in range(w):
    col = [r[j] for r in g]
    if all([x == '.' for x in col]) or all([x == '#' for x in col]):
        del_col.append(j)
del_col.sort(reverse=True)

for i in range(h):
    if not all([x == '.' for x in g[i]]) and not all([x == '#' for x in g[i]]):
        for d in del_col:
            g[i].pop(d)
        ans.append(g[i])
for r in ans:
    print(''.join(r))

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
l_h = list(range(h))
l_w = []
l_all = []

for i in range(h):
    l = input()
    l_all.append(l)
    if not "#" in l:
        l_h.remove(i)
    for j in range(w):
        if l[j]=="#" and not j in l_w:
            l_w.append(j)
            break
l_w.sort()
ans = [[l_all[hh][ww] for ww in l_w]for hh in l_h]

for k in range(len(ans)):
    print("".join(ans[k]))

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
l_h = list(range(h))
l_w = []
l_all = []

for i in range(h):
    l = input()
    l_all.append(l)
    if not "#" in l:
        l_h.remove(i)
    for j in range(w):
        if l[j]=="#" and not j in l_w:
            l_w.append(j)
            break
ans = [[l_all[hh][ww] for ww in l_w]for hh in l_h]

for k in range(len(ans)):
    print("".join(ans[k]))

Submission status: Wrong Answer

Solution code:
H,W=map(int, input().split())
s=[]
for _ in range(H):
    s.append(list(input()))
x = []
y = []
for i in range(len(s)):
    if len(set(s[i]))==1: #残すのはset(i)==2
        x.append(i)

for i in range(len(s[0])):
    y_check = []
    for j in range(len(s)):
        y_check.append(s[j][i])
    if len(set(y_check))==1:
        y.append(i)
for i in x[::-1]:
    del s[i]
for j in range(len(s)):
    for i in y[::-1]:
        del s[j][i]
for i in s:
    for j in i:
        print(j,end="")
    print("")

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    b = ''
    for j in range(len(a)):
        b += a[j][i]
    if b == '.'*len(a):
        ls.append(i)
ans = []
for i in range(W):
    s = ''
    for j in range(len(a)):
        if i in ls:
            continue
        else:
            s += a[j][i]
    ans.append(s)
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
List = [input() for _ in range(H)]

row = [False]*H
col = [False]*W

for i in range(H):
    for j in range(W):
        if List[i][j]=='#':
            row[i] = True
            col[j] = True
        
for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(List[i][j], end=" ")
        print()

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
r = [list(input()) for i in range(h)]
for i in range(h):
    if not '#' in r[i]:
        r[i] = 'Nan'
r = [i for i in r if i != 'Nan']
l = list(map(list, zip(*r)))
for i in range(len(l)):
    if not '#' in l[i]:
        l[i] = 'Nan'
l = [i for i in l if i != 'Nan']
l.reverse()
for i in range(len(l)):
    l[i].reverse()
    print(''.join(l[i]))

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    cur = 0
    for j in range(len(a)):
        if a[j][i] == '.':
            cur += 1
    if cur == len(a):
        ls.append(i)
ans = []
for i in ls:
    for s in a:
        ans.append(s[:i] + s[i+1:])
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
maze = [input() for _ in range(H)]

index_h = []
index_w = []

for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            break
        if j == W - 1:
            index_h.append(i)

for j in range(W):
    for i in range(H):
        if maze[i][j] == '#':
            break
        if i == H - 1:
            index_w.append(j)

for i in range(H):
    for j in range(W):
        if i in index_h:
            continue
        if j in index_w:
            continue
        print(maze[i][j], end='')

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())

temp = [list(map(int,input().replace("#", "1").replace(".","0"))) for _ in range(H)]

cnt = 0


while cnt != 2:
    ans = []
    s = 0
    for row in temp:
        if sum(row) != 0:
            ans.append(row)
        else:
            s += 1
    if s == 0:
        cnt += 1
    else:
        cnt = 0
        
            
    temp = []
    for row in zip(*ans):
        temp.append(row)
    
    ans = []
    s = 0
    for row in temp:
        if sum(row) != 0:
            ans.append(row)
        else:
            s += 1
    if s == 0:
        cnt += 1
    else:
        cnt = 0
            
    temp = []
    for row in zip(*ans):
        temp.append(row)


for row in temp:
    res = list(map(str,row))
    res = ",".join(res).replace("1","#").replace("0",".").split(",")
    print(*res)

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())

matrix = [list(map(int,input().replace("#", "1").replace(".","0"))) for _ in range(H)]

ans = []
temp = []

for row in matrix:
    if sum(row) != 0:
        ans.append(row)

for row in zip(*ans):
    temp.append(row)

ans = []
for row in temp:
    if sum(row) != 0:
        ans.append(row)
        
temp = []
for row in zip(*ans):
    temp.append(row)


for row in temp:
    res = list(map(str,row))
    res = ",".join(res).replace("1","#").replace("0",".").split(",")
    print(*res)

Submission status: Wrong Answer

Solution code:
def abc():
    h, w = map(int, input().split())
    lines = []
    for i in range(h):
        line = list(input().rstrip())
        if '#' in line:
            lines.append(line)

    for x in reversed(range(w)):
        if len([l for l in lines if l[x] == '#']) == 0:
            for l in lines:
                l.pop(x)
    for line in lines:
        print(''.join(line))

Submission status: Wrong Answer

Solution code:
def transpose(A):
    B = []
    for j in range(len(A[0])):
        C = [A[i][j] for i in range(len(A))]
        B.append(C)
    return B

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

for i in reversed(range(H)):
    if A[i] == ['.']*W:
        A.pop(i)
        
H = len(A)        
A = transpose(A)
for j in reversed(range(W)):
    if A[j] == ['.']*H:
        A.pop(j)

A = transpose(A)
for i in range(len(A)):
 	print(*A[i])

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]

flag_row = [True] * H
flag_col = [True] * W
for i in range(H):
    cnt = 0
    for j in range(W):
        if a[i][j] == '.':
            cnt += 1
    if cnt == W:
        flag_row[i] = False

for j in range(W):
    cnt = 0
    for i in range(H):
        if a[i][j] == '.':
            cnt += 1
    if cnt == H:
        flag_col[j] = False

for i in range(H):
    for j in range(W):
        if flag_row[i] == True and flag_col[j] == True:
            if j == W-1:
                print(a[i][j])
            else:
                print(a[i][j], end='')

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]

for r in grid:
    if all(x == '.' for x in r):
        grid.remove(r)

grid = np.array(grid).T.tolist()

for r in grid:
    if all(x == '.' for x in r):
        grid.remove(r)

grid = np.array(grid).T.tolist()

for r in grid:
    print(*r, sep='')

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())

Hcnt = [0] * H
Wcnt = [0] * W

L = [list(input()) for _ in range(H)]

for i, s in enumerate(L):
  for j, c in enumerate(s):
    if c == "#":
      Hcnt[i] += 1
      Wcnt[j] += 1

for i, s in enumerate(L):
  p = ""
  for j, c in enumerate(s):
    if Hcnt[i] > 0 and Wcnt[j] > 0:
      p += " {}".format(c)
  if p:
    print(p[1:])

Submission status: Wrong Answer

Solution code:
h, w =  [ int(v) for v in input().split() ]
column_list = []
row_list = []
field = [ None for i in range(h) ]
space_column = "." * h
space_row = "." * w
for i in range(h):
	s = input()
	field[i] = s
	if s != space_column:
		column_list.append(i)

for i in range(w):
	s = "".join([field[j][i] for j in range(h)])
	if s != space_row:
		row_list.append(i)


for i in column_list:
	print("".join([ field[i][j] for j in row_list ]))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=[]
for i in range(a):
  g=input()
  if "#" not in g:
    continue
  d=list(g)
  c.append(d)
l=len(c)
p=[]
for i in range(b):
  for j in range(l):
    if c[j][i]=="#":
      p.append(i)
      continue
for i in range(l):
  for j in range(len(p)):
    if j == len(p)-1:
      print(c[i][p[j]])
      continue
    print(c[i][p[j]],end="")

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
a=[list(map(str, input())) for _ in range(H)]

c=[]
for li in a:
    print(li)
    if li!=['.']*len(li):
        c.append(li)

b=[]
for lc in zip(*c):
    if lc!=('.',)*len(lc):
        b.append(lc)

for ld in zip(*b):
    print(''.join(ld))

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
a=[list(map(str, input())) for _ in range(H)]

for li in a:
    if li==['.']*len(li):
        a.remove(li)

b=[]
for lc in zip(*a):
    if lc!=('.',)*len(lc):
        b.append(lc)

for ld in zip(*b):
    print(''.join(ld))

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
a=[list(map(str, input())) for _ in range(H)]

for li in a:
    if li==['.']*4:
        a.remove(li)

b=[]
for lc in zip(*a):
    if lc!=('.',)*len(lc):
        b.append(lc)

for ld in zip(*b):
    print(''.join(ld))

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
target = []

for i in range(h):
    target.append(list(input()))

# 横方向のチェック
for index, row in enumerate(target):
    delete = True
    for i in range(w):
        if row[i] != ".":
            delete = False
    if delete:
        del target[index]

# print(target)

tr = []
for i in range(len(target[0])):
    tr_row = []
    for vector in target:
        tr_row.append(vector[i])
    tr.append(tr_row)    
# print(tr)

for index, row in enumerate(tr):
    delete = True
    for i in range(len(tr[0])):
        if row[i] != ".":
            delete = False
    if delete:
        del tr[index]

# print(tr)
target = []
for i in range(len(tr[0])):
    tr_row = []
    for vector in tr:
        tr_row.append(vector[i])
    target.append(tr_row)

# print(target)

for i in target:
    tmp = ""
    for l in i:
        tmp += l
    print(tmp)

Submission status: Wrong Answer

Solution code:
import numpy as np
h, w = map(int, input().split())

grid = [list(input()) for _ in range(h)]
grid = [row for row in grid if row.count(".") != len(row)]
grid = [row for row in np.rot90(grid, k=1) if np.count_nonzero(row == ".") != len(row)]
[print(row) for row in np.rot90(grid, k=-1)]

Submission status: Wrong Answer

Solution code:
import numpy as np

h, w = tuple(map(int, input().split()))
matrix = np.zeros((h, w), dtype=bool)
for i in range(h):
    row = np.array(input().split())
    matrix[i, :] = row == "."

for i in range(h)[::-1]:
    if np.all(matrix[i, :]):
        matrix = np.delete(matrix, i, 0)

for i in range(w)[::-1]:
    if np.all(matrix[:, i]):
        matrix = np.delete(matrix, i, 1)

matrix = np.where(matrix, ".", "#")
for row in matrix:
    for e in row:
        print(e+" ", end="")
    print("\b")

Submission status: Wrong Answer

Solution code:
h, w = [int(i) for i in input().split()]
a = []
d = []
h_new = 0
for i in range(h):
  b = input()
  if "#" in b:
    a.append(list(b))
    h_new += 1
for i in range(w):
  c = []
  for j in range(h_new):
    c.append(a[j][i])
  if "#" not in c:
    d.append(i)
print(d)
e = ""
for i in range(h_new):
  for j in range(w):
    if j not in d:
      print(a[i][j],end="")
  print("\n")

Submission status: Wrong Answer

Solution code:
import numpy as np 
H, W = map(int,input().split())

data = []
for i in range (H):
    temp = list(input())
    data.append(temp)

data = np.array(data)

h_true = []
for i in range (H):
    if (('#' in data[i])  & ('.' not in data[i])) | (('#' not in data[i])  & ('.' in data[i])) == True:
        h_true.append(i)

w_true = []
for j in range (W):
    if (('#' in data[:,j])  & ('.' not in data[:,j])) | (('#' not in data[:,j])  & ('.' in data[:,j])) == True:
        w_true.append(j)

data = np.delete(data,h_true,0)
data = np.delete(data,w_true,1)

for k in range (data.shape[0]):
    print(''.join(data[k]))

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]

f_row = []
f_col = []
for i in range(h):
    for j in range(w):
        if a[i][j] != '.':
            break
        if j == w-1:
            f_row.append(i)
for j in range(w):
    for i in range(h):
        if a[i][j] != '.':
            break
        if i == h-1:
            f_col.append(j)

for i in range(h):
    for j in range(w):
        if i in f_row:
            break
        if j not in f_col:
            print(a[i][j], end='')
            if j == w-1:
                print()

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
grid = []

for i in range(H):
  line = list(input())
  grid.append(line)

mod_grid = []
for i in range(H):
  if '#' in grid[i]:
    print(''.join(grid[i]))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a = [input() for i in range(N)]
counter = 0
numlist = []
delMlist = []

for i in range(N):
    #print(a[i])
    if a[i].count('#') == 0:
        delMlist.append(i)
#print(delMlist)

for i in delMlist:
    a.pop(i-counter)
    #print(a)
    counter += 1
print('---------')
#print(a)
N = N - len(delMlist)
#print(N)
newlist = []
for i in range(N):   
    for j in range(M):
        if a[i][j] == '.' :
            numlist.append([i,j])
    newlist.append([a[i]])
llist = []
for i in range(N):
    #llist = list(a[i])
    llist.append(list(a[i]))
#print(llist)
counter1 = 0
fst = ''
delNlist = []
#print(N)
for i in range(M):
    for j in range(N):
        #print(j)
        if llist[j][i] == '.':
            counter1 += 1
        if counter1 == N:
            delNlist.append(i)
    counter1 = 0
#print(delNlist)
#print('---------')
#anslist = []
counter2 = 0
if delNlist != []:
    for h in delNlist:
        for i in range(N):
            a[i] = (a[i][:h-counter2] + a[i][h+1-counter2:])
        counter2 += 1
for i in a:
    print(i)
#print(a)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(input())
print(a[0][0])
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 i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j], end='')
        print()

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
STAGE = [input() for _ in range(H)]

#print("")

ccheck = 0
for l in STAGE:
	if "#" not in l:
		STAGE.remove(l)
	else:
		ccheck |= int(l.replace("#", "1").replace(".", "0"), 2)

#print(bin(ccheck))

for l in STAGE:
	print(l)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
rs = [input() for _ in range(h)]
rows = []

#.だけの行を省いてrowsに格納
for r in rs:
  if '#' in r: rows.append(r)

print(rows)
ansrows = zip(*[c for c in zip(*rows) if '#' in c])

for r in list(ansrows):
  print(''.join(r))

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
A=[]
d="."*W
for i in range(H):
    a=input()
    if a==d:
        continue
    A.append(a+"#")
l=len(A)

list=[0]*W
for k in A:
    for i in range(W):
        if k[i]==".":
            list[i]+=1
h=0
for i in range(W):
    t=list[i]
    k=len(A[0])
    if t==l:
        for j in range(l):
            i+=h
            a=A.pop(0)
            a=a[:i]+a[i+1:]
            A.append(a)
        h-=1
for i in range(l):
    print(A[i][:-1])

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
mat = [list(map(lambda x: 0 if x == '#' else 1, input())) for _ in range(H)]
print((H - sum(all(row) for row in mat)) * (W - sum(all(row) for row in zip(*mat))))

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())

a = [input() for i in range(H)]

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 i in range(H):
  if row[i]:
    for j in range(W):
      if col[j]:
        print(a[i][j], end='')

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = [input() for i in range(H)]
res = [0 for i in range(W)]
for i in range(W):
  for j in range(H):
    if a[j][i] != ".":
      break
    res[i] += 1
for i in range(H):
  for j in range(W):
    if res[j] != H:
      print(a[i][j],end="")
  print("")

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
A = [None] * h
for i in range(h):
  A[i] = list(input())

while ('.' * w in A):
  A.remove('.' * w)

B = [''.join(col) for col in zip(*A)]

while ('.' * len(A) in B):
  B.remove('.' * len(A))

A = [''.join(col) for col in zip(*B)]

for a in A:
  print(''.join(a))

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = [input() for i in range(h)]

for i in a:
  if i == "." * w:
    a.remove(i)
hh = len(a)
  
a = ["".join(h_line) for h_line in zip(*a)]
for i in a:
  if i == "." * hh:
    a.remove(i)
    
for line in zip(*a):
  print("".join(line))

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = [input() for i in range(h)]

for i in a:
  if i == "." * w:
    a.remove(i)
  
a = ["".join(h_line) for h_line in zip(*a)]
for i in a:
  if i == "." * len(a[0]):
    a.remove(i)
    
for line in zip(*a):
  print("".join(line))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
l=[]
n=0
m=0
cou=0
for i in range(h):
    x=input()
    if x==("."*w):
        cou+=1
        continue
    l.append(list(x))
for i in range(w):
    k=0
    for j in range(h-cou-1):
        if l[j][i]=="#":
            break
        else:
            k+=1
    if k==h-cou:
        for d in range(h-cou):
            del l[d][i]
for i in range(h-cou):
    l[i]="".join(l[i])
    print(l[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

data = input().split()

h = int(data[0])
w = int(data[1])

count = 0
# creating math
i = 0
math = []
while i < h:
    x = input()
    x = list(x)
    math.append(x)
    i += 1
math = np.array(math).reshape(h,w)


# row check

i = 0 # row
j = 0 # colum
while i < h:
    while j < w:
        if math[i][j] == ".":
            
            j += 1
            if j == w:
                math = np.delete(math,i,0)
                h = h-1
                
                
        else:
            break
    j = 0
    i += 1
i = 0
j = 0

# colum check

while j < w:
    while i < h:
        if math[i][j] == ".":
            
            i += 1
            if i == h:
                math = np.delete(math,j,1)
                w = w-1
                
                
        else:
            break
    i = 0
    j += 1
i = 0
j = 0
while i < h:
    while j < w:
        print(*math[i][j],end = "")
        j += 1
    i += 1
    j = 0
    print()

Submission status: Wrong Answer

Solution code:
import numpy as np

data = input().split()

h = int(data[0])
w = int(data[1])

count = 0
# creating math
i = 0
math = []
while i < h:
    x = input()
    x = list(x)
    math.append(x)
    i += 1
math = np.array(math).reshape(h,w)


# row check

i = 0 # row
j = 0 # colum
while i < h:
    while j < w:
        if math[i][j] == ".":
            
            j += 1
            if j == w:
                math = np.delete(math,i,0)
                h = h-1
                
                
        else:
            break
    j = 0
    i += 1
i = 0
j = 0

# colum check

while j < w:
    while i < h:
        if math[i][j] == ".":
            
            i += 1
            if i == h:
                math = np.delete(math,j,1)
                w = w-1
                
                
        else:
            break
    i = 0
    j += 1

print(math)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split());b=[input()for i in range(h)];a=[]
for i in b:
  if i!="."*w:a.insert(0,i)
b=[]
for i in range(w):
  s=""
  for j in a:s+=j[i]
  if s!="."*len(a):b.insert(0,s)
for i in b:print(i)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split());b=[input()for i in range(h)];a=[]
for i in b:
  if i!="."*w:a.append(i)
b=[]
for i in range(w):
  s=""
  for j in a:s+=j[i]
  if s!="."*len(a):b.append(s)
for i in b:print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin
h,w = [int(x) for x in stdin.readline().rstrip().split()]
data = [stdin.readline().rstrip() for _ in range(w)]
row=[False]*h
col=[False]*w
for i,r in enumerate(data):
    for j,c in enumerate(r):
        if c=='#':
            row[i]=True
            col[j]=True
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(data[i][j],end='')
        print()

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = []
for i in range(H):
    list = [i for i in input()]
    a.append(list)
column = [int(i) for i in range(W)]
row = [int(i) for i in range(H)]
for i in range(H):
    for j in range(W):
        if a[i][j] == "#":
            if i in row:
                row.remove(i)
            if j in column:
                column.remove(j)
print(column)
print(row)
for i in range(H):
    printed = False
    for j in range(W):
        if i not in row and j not in column:
            print(a[i][j], end="")
            printed = True
    if printed:
        print("")

Submission status: Wrong Answer

Solution code:
H, W = (int(i) for i in input().split())
e = [input() for i in range(H)] 

new_e = []
for row in e:
    if row.count("#") > 0:
        new_e.append(row)

use_col = []
for row in new_e:
    for col in range(W):
        if row[col] == "#" and col not in use_col:
            use_col.append(col)
            break

for row in new_e:
    x=""
    for col in sorted(use_col):
        x += row[col]
    print(x)

Submission status: Wrong Answer

Solution code:
H, W = (int(i) for i in input().split())
e = [input() for i in range(H)] 

new_e = []
for row in e:
    if row.count("#") > 0:
        new_e.append(row)

use_col = []
for row in new_e:
    for col in range(W):
        if row[col] == "#" and col not in use_col:
            use_col.append(col)
            break

for row in new_e:
    x=""
    for col in use_col:
        x += row[col]
    print(x)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
grid = []
for i in range(H):
  line = input()
  for i in range(len(line)):
    if line[i] == '#':
      grid.append(line)
      break
gridans = [[''] for i in range(len(grid))]
for i in range(W):
  flag = 0
  for j in range(len(grid)):
    if grid[j][i] == '#':
      flag = 1
  if flag == 1:
    for j in range(len(grid)):
      gridans[j] += grid[j][i]
for i in range(len(gridans)):
  print(gridans[i])

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]

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 i in range(h):
    if row[i]:
        ans = ""
        for j in range(w):
            if col[j]:
                ans.join(a[i][j])
        if "#" in ans:
            print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import numpy as np
H, W = map(int, input().split())
a = []
r_idx = []
c_idx = []
#a.shape = (H, W)
for i in range(H):
    line = list(input())
    ct = Counter(line).most_common()
    if ct[0][1] != W and ct[0][0]==".":
        r_idx.append(i)
    a.append(line)
a = np.array(a).T
#a.shape = (W, H)
b = []
for i in range(W):
    ct = Counter(a[i]).most_common()
    if ct[0][1] == H and ct[0][0]==".":
        continue
    b.append(a[i])

b = np.array(b).T
c = []
for idx in r_idx:
    c.append(b[idx])

for i in range(len(c)):
    print("".join(c[i]))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import numpy as np
H, W = map(int, input().split())
a = []
r_idx = []
c_idx = []
#a.shape = (H, W)
for i in range(H):
    line = list(input())
    if Counter(line).most_common()[0][1] != W:
        r_idx.append(i)
    a.append(line)
a = np.array(a).T
#a.shape = (W, H)
b = []
for i in range(W):
    if Counter(a[i]).most_common()[0][1] == H:
        continue
    b.append(a[i])

b = np.array(b).T
c = []
for idx in r_idx:
    c.append(b[idx])

for i in range(len(c)):
    print("".join(c[i]))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import numpy as np
H, W = map(int, input().split())
a = []
r_idx = []
c_idx = []
#a.shape = (H, W)
for i in range(H):
    line = list(input())
    if Counter(line).most_common()[0][1] != W:
        r_idx.append(i)
    a.append(line)
a = np.array(a).T
#a.shape = (W, H)
b = []
for i in range(W):
    if Counter(a[i]).most_common()[0][1] == W:
        continue
    b.append(a[i])

b = np.array(b).T
c = []
for idx in r_idx:
    c.append(b[idx])

for i in range(len(c)):
    print("".join(c[i]))

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
rows = [input() for _ in range(H)]

for row in rows:
    if row.count('#')==0:
        rows.remove(row)

rows2 = ['']*W
for i in range(W):
    for row in rows:
        rows2[i] += row[i]

for row2 in rows2:
    if row2.count('#')==0:
        rows2.remove(row2)

rows3 = ['']*len(rows2[0])
for i in range(len(rows3)):
    for row2 in rows2:
        rows3[i] += row2[i]

for row in rows3:
    print(row)

Submission status: Wrong Answer

Solution code:
H,W=(int(i) for i in input().split())
L=[]
for i in range(H):
    L.append(list(input()))

for x in L:
    if '#' in x:
        continue
    else:
        L.remove(x)

L=list(map(list,zip(*L)))
for x in L:
    if '#' in x:
        continue
    else:
        L.remove(x)
L=list(map(list,zip(*L)))
for i in range(len(L)):
    print(''.join(L[i]))