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:
h,w=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(map(str,input())))
print(l)

row=[False]*h
col=[False]*w
for i in range(h):
    for k in range(w):
        if l[i][k]=="#":
            row[i]=True
            col[k]=True
for i in range(h):
    if row[i]:
        for k in range(w):
            if col[k]:
                print(l[i][k], end="")
        print("")

Submission status: Wrong Answer

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


temp1 = []
temp2 = []
for i in range(len(a)):
	ff = 0
	for j in range(len(a[i])):
		if a[i][0] == '.':
			continue
		ff = 1
	if ff == 0:
		temp1.append(i)
temp1.sort(reverse=True)
for i in range(len(a[0])):
	ff = 0
	for j in range(len(a)):
		if a[0][i] == '.':
			continue
		ff = 1
	if ff == 0:
		temp2.append(i)
temp2.sort(reverse=True)
for i in range(len(temp1)):
	a.pop(temp1[i])
for i in range(len(temp2)):
	for k in range(len(a)):
		a[k].pop(temp2[i])

for i in range(len(a)):
	s = ''
	for j in range(len(a[i])):
		s += a[i][j]
	print(s)

Submission status: Wrong Answer

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


temp1 = []
temp2 = []
for i in range(len(a)):
	ff = 0
	for j in range(len(a[i])):
		if a[i][0] == a[i][j]:
			continue
		ff = 1
	if ff == 0:
		temp1.append(i)
temp1.sort(reverse=True)
for i in range(len(a[0])):
	ff = 0
	for j in range(len(a)):
		if a[0][i] == a[j][i]:
			continue
		ff = 1
	if ff == 0:
		temp2.append(i)
temp2.sort(reverse=True)
for i in range(len(temp1)):
	a.pop(temp1[i])
for i in range(len(temp2)):
	for k in range(len(a)):
		a[k].pop(temp2[i])

for i in range(len(a)):
	s = ''
	for j in range(len(a[i])):
		s += a[i][j]
	print(s)

Submission status: Wrong Answer

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

count = -1
for i in HW:
    count += 1
    if i.count("#") == 0:
        HW.pop(count)

for i in HW:
    A = []
    for j in range(W):
        A.append(i[j])
    if A.count("#") == 0:
        i = i[:j] + i[j:]

for i in HW:
    print(i)

Submission status: Wrong Answer

Solution code:
import numpy as np
H, W = map(int, input().split())
a = []
for i in range(H):
    a_l = input()
    a.append([c for c in a_l])


for i in range(H):
    for j in range(W):
        if a[i][j] == '.':
            a[i][j] = 1
        elif a[i][j] == '#':
            a[i][j] = 0
        else:
            pass
a = np.array(a)
v = []
h = []
for i in range(H):
    if np.sum(a[i,:]) == 0 or np.sum(a[i,:]) == W:
        h.append(i)
for j in range(W):
    if np.sum(a[:,j]) == 0 or np.sum(a[:,j]) == H:
        v.append(j)

a_del = np.delete(np.delete(a, v, 1), h, 0)
a_del = list(a_del)

for i in range(len(a_del)):
    for j in range(len(a_del[i])):
        if a_del[i][j] == 1:
            print('.', end='')
        elif a_del[i][j] == 0:
            print('#', end='')
    print('')

Submission status: Wrong Answer

Solution code:
import numpy as np
H, W = map(int, input().split())
a = []
for i in range(H):
    a_l = input()
    a.append([c for c in a_l])


for i in range(H):
    for j in range(W):
        if a[i][j] == '.':
            a[i][j] = 1
        elif a[i][j] == '#':
            a[i][j] = 0
        else:
            pass
a = np.array(a)
v = []
h = []
for i in range(H):
    if np.sum(a[i,:]) == 0 or np.sum(a[i,:]) == W:
        h.append(i)
for j in range(W):
    if np.sum(a[:,j]) == 0 or np.sum(a[:,j]) == H:
        v.append(j)

a_del = np.delete(np.delete(a, v, 1), h, 0)
a_del = list(a_del)

for i in range(len(a_del)):
    for j in range(len(a_del[i])):
        if a_del[i][j] == 1:
            print('.', end='')
        elif a_del[i][j] == 0:
            print('#', end='')
    print('\n')

Submission status: Wrong Answer

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

aa = [input() for _ in range(h)]
aa_rm=[]
target_row=[]
for row,a in enumerate(aa):
    if a.count('.') < w and a.count('#') < w:
        target_row.append(row)

target_col=[]
for iw in range(w):
    col=[]
    for ih in range(h):
        col.append(aa[ih][iw])
    # print(col)
    if col.count('.') < h and col.count('#') < h:
        target_col.append(iw)

ans =[]
for row in target_row:
    s=""
    for col in target_col:
        s+=aa[row][col]
    ans.append(s)
for a in ans:
    print(a)

Submission status: Wrong Answer

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

arr_all = []
arr_del = []
for i in range(h):
    arr_w = input()
    if list(set(arr_w)) == ["."]:
        continue
    else:
        arr_all.append(arr_w)
        arr_del.append([])


d = []
for i in range(w):
    for j in range(len(arr_all)):
        if arr_all[j][i] == ".":
            if i == w - 1:
                break
            else:
                continue
        else:
            d.append(i)
            break

for j in range(len(arr_all)):
    for i in d:
        arr_del[j] += arr_all[j][i]


for i in range(len(arr_all)):
    print(''.join(arr_del[i]))

Submission status: Wrong Answer

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

arr_all = []
arr_del = []
for i in range(h):
    arr_w = input()
    if list(set(arr_w)) == ["."]:
        continue
    else:
        arr_all.append(arr_w)
        arr_del.append([])

print(arr_all)

d = []
for i in range(w):
    for j in range(len(arr_all)):
        if arr_all[j][i] == ".":
            if i == w - 1:
                break
            else:
                continue
        else:
            d.append(i)
            break

for j in range(len(arr_all)):
    for i in d:
        arr_del[j] += arr_all[j][i]

print(arr_del)

for i in range(len(arr_all)):
    print(''.join(arr_del[i]))

Submission status: Wrong Answer

Solution code:
h,w = map(int,input().split())
M = []
for i in range(h):
        k = str(input())
        if "#"  in k:
                M.append(k)

N = []
for i in range(w):
        s = ""
        for j in range(len(M)):
                s += M[j][i]
        if "#" not in s:
                N.append(i)

for i in range(len(N)):
        for j in range(len(M)):
                M[j] = M[j][0:N[i]]+M[j][N[i]+1:]
                
for i in range(len(M)):
        print(M[i])

Submission status: Wrong Answer

Solution code:

def solve(h, w, a):
    rs = []
    for r in range(h):
        ok = True
        for c in range(w):
            if a[r][c] == "#":
                ok = False
                break
        if not ok:
            rs.append(r)
    cs = []
    for c in range(w):
        ok = True
        for r in range(h):
            if a[r][c] == "#":
                ok = False
                break
        if not ok:
            cs.append(c)
    res = "\n".join(map(lambda r: "".join(map(lambda c: a[r][c], cs)), rs))
    return res


h, w = map(int, raw_input().split())
a = []
for r in range(h):
    a.append(raw_input())

print h, w

print a
#print solve(h, w, a)

Submission status: Wrong Answer

Solution code:
h,w=map(int, input().split())
a=[""]*h
for i in range(h):
  a[i]=input()
row=[False]*h
column=[False]*w
for i in range(h):
  for j in range(w):
    if a[i][j]=="#":
      row[i]=True
      column[j]=True
for i in range(h):
  if row[i]:
    for j in range(w):
      if column[j]:
        print(a[i][j]+" ")
    print()

Submission status: Wrong Answer

Solution code:
h,w=map(int, input().split())
a=[" "]*h
for i in range(h):
  a[i]=input()
row=[False]*h
column=[False]*w
for i in range(h):
  for j in range(w):
    if a[i][j]=="#":
      row[i]=True
      column[j]=True
for i in range(h):
  if row[i]:
    for j in range(w):
      if column[j]:
        print(a[i][j]+" ")
    print()

Submission status: Wrong Answer

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

matrix = []

for i in range(H):
  matrix.append(list(input()))

white = ['.'] * W

pop_list = []
counter = 0

i = H - 1
while i >= 0:
  if matrix[i] == white:
    matrix.pop(i)
    i -= 1
    counter += 1
  i -= 1

white = ['.'] * (H - counter)
i = W - 1
 
while i >= 0:
  current_col = [r[i] for r in matrix]
  if current_col == white:
    for j, r in enumerate(matrix):
      matrix[j].pop(i)
    i -= 1
  i -= 1

for r in matrix:
  for rr in r:
    print(rr, end = '')
  print('\n')

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = []
for i in range(h):
    A = list(map(str,input().split()))
    a.append(A)
kesu = []
for i in range(h):
    b = str(a[i])
    ten = 0
    for l in range(w):
        if b[l+2] == ",":
           ten += 1
    if w == ten :
        kesu.append(i)
for i in range(len(kesu)):
    K = int(kesu[i])
    a.pop(K-i)
hi = []
for i in range(w):
    hkari = ""
    for l in range(len(a)):
        h = str(a[l])
        hz = str(h[i+2])
        hkari += str(hz)
    hi.append(hkari)
kesu = []
for i in range(len(hi)):
    b = str(hi[i])
    ten = 0
    for l in range(len(b)):
        if b[l] == ",":
            ten += 1
    if len(b) == ten:
        kesu.append(i)
for i in range(len(kesu)):
    K = int(kesu[i])
    hi.pop(K-i)
b = len(str(hi[0]))
ans = []
for i in range(b):
    hkari = ""
    for l in range(len(hi)):
        h = str(hi[l])
        hz = str(h[i])
        hkari += str(hz)
    ans.append(hkari)
for i  in range(len(ans)):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = []
for i in range(h):
    A = list(map(str,input().split()))
    a.append(A)
kesu = []
for i in range(h):
    b = str(a[i])
    ten = 0
    for l in range(w):
        if b[l+2] == ",":
           ten += 1
    if w == ten :
        kesu.append(i)
for i in range(len(kesu)):
    K = int(kesu[i])
    a.pop(K-i)
hi = []
for i in range(w):
    hkari = ""
    for l in range(len(a)):
        h = str(a[l])
        hz = str(h[i+2])
        hkari += str(hz)
    hi.append(hkari)
kesu = []
for i in range(len(hi)):
    b = str(hi[i])
    ten = 0
    for l in range(len(b)):
        if b[l] == ",":
            ten += 1
    if len(b) == ten:
        kesu.append(i)
for i in range(len(kesu)):
    K = int(kesu[i])
    hi.pop(K-i)
b = len(str(hi[0]))
ans = []
for i in range(b):
    hkari = ""
    for l in range(len(hi)):
        h = str(hi[l])
        hz = str(h[i])
        hkari += str(hz)
    ans.append(hkari)
print(ans)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
b=[x for x in a if "#" in x]
c=zip(*[y for y in zip(*b) if "#" in y])
for d in zip(*c):print("".join(d))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
    x = input()
    if "#" in x:
        a.append(x)
a=list(zip(*a))
print(a)
b=[]
for y in a:
    if "#" in y:
        b.append(y)
b=list(zip(*b))
print(b)
for c in b:
    print("".join(c))

Submission status: Wrong Answer

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

for j in a:
  if '#' not in j:
    a.remove(j)
    h-=1
   
b=[]

for k in range(w):
  c=''
  for l in range(h):
    c+=a[l][k]
  b.append(c)

for m in b:
  if '#' not in m:
    b.remove(m)
    w-=1

for o in range(h):
  d=''
  for p in range(w):
    d+=b[p][o]
  print(d)

Submission status: Wrong Answer

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

print(a)
print(h)
print(w)

for j in a:
  if '#' not in j:
    a.remove(j)
    h-=1
    
print(a)
print(h)
print(w)
   
b=[]

for k in range(w):
  c=''
  for l in range(h):
    c+=a[l][k]
  b.append(c)

print(b)
print(h)
print(w)
  
for m in b:
  if '#' not in m:
    b.remove(m)
    w-=1
    
print(b)
print(h)
print(w)

for o in range(h):
  d=''
  for p in range(w):
    d+=b[p][o]
  print(d)

Submission status: Wrong Answer

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

print(a)

for j in a:
  if '#' not in j:
    a.remove(j)
    h-=1
    
print(a)
   
b=[]

for k in range(w):
  c=''
  for l in range(h):
    c+=a[l][k]
  b.append(c)

for m in b:
  if '#' not in m:
    b.remove(m)
    w-=1
    
print(b)

for o in range(h):
  d=''
  for p in range(w):
    d+=b[p][o]
    print(d)

Submission status: Wrong Answer

Solution code:
def str_del(string,index):
    string = string[:index]+string[index+1:]
    return string


H,W=map(int,input().split())
lines=[]
for i in range(H):
    get=input()
    flag=True
    for s in get:
        if s=='#':
            flag=False
            break
    if not flag:
        lines.append(get)
    else:
        H-=1



for i in range(W):
    same_flag = True

    for s in range(len(lines)):
        #print(lines)
        try:
            if(lines[s][i]=='#'):
                same_flag=False
                break
        except:
            same_flag = False
            break

    if same_flag:
        for s in range(len(lines)):
            lines[s]=str_del(lines[s],i)
            #print(lines[s])
        #print('deleted')


for i in range(len(lines)):
    print(lines[i])

Submission status: Wrong Answer

Solution code:
def str_del(string,index):
    string = string[:index]+string[index+1:]
    return string


H,W=map(int,input().split())
lines=[]
for i in range(H):
    get=input()
    flag=True
    for s in get:
        if s=='#':
            flag=False
            break
    if not flag:
        lines.append(get)
    else:
        H-=1



for i in range(W):
    same_flag = True

    for s in range(len(lines)):
        #print(lines)
        try:
            if(lines[s][i]=='#'):
                same_flag=False
                break
        except:
            same_flag = False
            break

    if same_flag:
        for s in range(len(lines)):
            lines[s]=str_del(lines[s],i)
            #print(lines[s])
        print('deleted')


for i in range(len(lines)):
    print(lines[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

a1, a2 = map(int, input().split())
mx = [[list(i) for i in input().split()] for i in range(a1)]
mx = np.reshape(mx,-1)
mx = [0 if i == '.' else 1 for i in mx]
mx = np.reshape(mx,[a1,a2])

w = min(np.append(sum(mx,1),sum(mx,0)))

while w == 0:
    mx = mx[np.sum(mx,1) > 0]
    mx = mx.T[np.sum(mx.T,1) > 0].T
    w = min(np.append(sum(mx,1),sum(mx,0)))

res = np.where(mx == 0 ,".","#")

for x in zip(*res):
    print(''.join(x))

Submission status: Wrong Answer

Solution code:
import numpy as np

a1, a2 = map(int, input().split())
mx = [[list(i) for i in input().split()] for i in range(a1)]
mx = np.reshape(mx,-1)
mx = [0 if i == '.' else 1 for i in mx]
mx = np.reshape(mx,[a1,a2])

w = min(np.append(sum(mx,1),sum(mx,0)))

while w == 0:
    mx = mx[np.sum(mx,1) > 0]
    mx = mx.T[np.sum(mx.T,1) > 0].T
    w = min(np.append(sum(mx,1),sum(mx,0)))

res = np.where(mx == 0 ,".","#")

print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np


def main():
    """Function."""
    h, w = map(int, input().split())

    mat = []
    for _ in range(h):
        mat.append(list(str(input())))

    mat = np.array(mat).reshape(h, w)

    yoko_keep, tate_keep = [], []
    for i in range(h):
        if len(np.unique(mat[i, :])) == 1:
            yoko_keep.append(i)
    for i in range(w):
        if len(np.unique(mat[:, i])) == 1:
            tate_keep.append(i)

    mat = np.delete(mat, yoko_keep, axis=0)
    mat = np.delete(mat, tate_keep, axis=1)

    for i in range(len(mat)):
        s = "".join(mat[i])
        print(s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    h, w = map(int, input().split())

    mat = []
    for _ in range(h):
        mat.append(list(str(input())))

    yoko_keep = []
    for i in range(h):
        if len(set(mat[i])) == 1:
            yoko_keep.append(i)

    keep = []
    for j in range(w):
        temp = []
        for i in range(h):
            temp.append(mat[i][j])
        if len(set(temp)) == 1:
            keep.append(j)
        else:
            pass

    for i in range(1, len(yoko_keep)+1):
        del(mat[yoko_keep[-i]])

    for i in range(len(mat)):
        for j in range(1, len(keep)+1):
            del(mat[i][keep[-j]])

    for i in range(len(mat)):
        s = "".join(mat[i])
        print(s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
A = []
for _ in range(H):
    a = list(input())
    if '#' in a:
        A.append(a)
    else:
        H -= 1

for i in range(W-1,-1,-1):
    ch = 0
    for j in range(H):
        if A[j][i] == '#':
            break
        else:
            ch = 1
    if ch == 1:
        for k in range(H):
            del A[k][i]
    
for i,a in enumerate(A):
    print(''.join(a))

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
A = []
for _ in range(H):
    a = list(input())
    if '#' in a:
        A.append(a)
    else:
        H -= 1

for i in range(W-1,-1,-1):
    ch = 0
    for j in range(H):
        if A[j][i] == '#':
            break
        else:
            ch = 1
    if ch == 1:
        for k in range(H):
            del A[k][i]
    
for a in A:
    print(''.join(a))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M=map(int,input().split())
x=[]
for n in range(N):
	x.append(list(input()))

for __ in range(2):
	check=[]
	for _ in range(len(x[0])):
		check.append(".")
	for xi in x:
		if xi == check:
			x.remove(xi)
	x=np.array(x).T.tolist()


for i in range(len(x)):
	for j in range(len(x[0])):
		print(x[i][j],end="")
	if i != len(x)-1:
		print()

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
hlist = []
wlist = []
a = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            hlist.append(i)
            wlist.append(j)
print(hlist,wlist)
for i in set(hlist):
    for j in set(wlist):
        print(a[i][j], end ="")
    print()

Submission status: Wrong Answer

Solution code:
H, W = map(int, raw_input().split())
a = []
for i in range(H):
  a.append(raw_input())
b = [r for r in a if "#" in r]
c = ["".join(r) for r in zip(*b) if "#" in r]
for l in c:
  print "".join(l)

Submission status: Wrong Answer

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

grid = []
for i in range(h):
    row = str(input())

    for j in range(w):
        if row[j] == "#":
            grid.append(row)
            break
#print(grid)
cls = []

for i in range(w):
    count = 0

    for j in range(len(grid)):
        #print(i,j,grid[j])
        if grid[j][i] == "." :
            count += 1

    if count >= len(grid) :
        cls.append(i)

for i in cls:
    for j in range(len(grid)):
        grid[j] = grid[j][:i] + grid[j][i+1:]

for i in range(len(grid)):
    print(grid[i])

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = ['']*h
for i in range(h):
    a[i] = input()
    
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=input().split()
cnt=0
b=[]
for i in range(int(h)):
  a=input()
  if a.count('.') < int(w):
    b.append(a)

for i in range(len(b)):
    print(b[i])

print(len(b))

c=[]
for j in range(len(b[0])):
  for i in range(len(b)):
    c.append(b[i][j])
  
print(c)

Submission status: Wrong Answer

Solution code:
f=lambda s:zip(*[t for t in s if'#'in t]);
for r in f(f(__import__('sys').stdin)):print(*r)

Submission status: Wrong Answer

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

row = []
column = []

for i in range(h):
    flag = 1
    first = a[i][0]
    for j in range(w):
        if a[i][j] != first:
            flag = 0
    if flag == 0:
        row.append(i)

for j in range(w):
    flag = 1
    first = a[0][j]
    for i in range(h):
        if a[i][j] != first:
            flag = 0
    if flag == 0:
        column.append(j)


for i in row:
    output = ""
    for j in column:
        output += a[i][j]
    if output != "":
        print(output)

Submission status: Wrong Answer

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

row = []
column = []

for i in range(h):
    flag = 1
    first = a[i][0]
    for j in range(w):
        if a[i][j] != first:
            flag = 0
    if flag == 0:
        row.append(i)

for j in range(w):
    flag = 1
    first = a[0][j]
    for i in range(h):
        if a[i][j] != first:
            flag = 0
    if flag == 0:
        column.append(j)


for i in row:
    output = ""
    for j in column:
        output += a[i][j]
    print(output)

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
L = [input() for i in range(H)]
X = [False for i in range(W)]
Y = [False for i in range(H)]

for y in range(H) :
    for x in range(W) :
        if L[y][x] == "#" :
            X[x] = True
            Y[y] = True
print(X,Y)

for y in range(H) :
    if Y[y] == True :
        ANS = []
        for x in range(W) :
            if X[x] == True :
                ANS.append(L[y][x])
        print("".join(ANS))

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w=map(int,input().split())
lst=list(input() for i in range(h))
for a in lst:
    if a=="."*w:
        h-=1
        lst.remove(a)
lst=np.array(list(map(list,lst)))
lst=np.rot90(lst,k=-1).tolist()
for a in lst:
    if "#" not in a:
        lst.remove(a)
lst=np.array(list(map(list,lst)))
lst=np.rot90(lst,k=1).tolist()
for b in range(h):
    print("".join(lst[b]))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
lst=list(input() for i in range(h))
for a in lst:
    if a=="."*w:
        h-=1
        lst.remove(a)
lst=list(map(list,lst))
for i in range(w):
    T=True
    if i>w:
        break
    for b in range(h):
        if lst[b][i]!="." :
            T=False
            break
    if T==True:
        for b in range(h):
            lst[b].pop(i)
            w-=1
for b in range(h):
    print("".join(lst[b]))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
lst=list(input() for i in range(h))
for a in lst:
    if a=="."*w:
        h-=1
        lst.remove(a)
for i in range(w):
    T=True
    if i>w:
        break
    for b in range(h):
        if lst[b][i]!="." :
            T=False
            break
    if T==True:
        for b in range(h):
            lst[b]=lst[b][:i]+lst[b][i+1:]
            w-=1
for b in range(h):
    print("".join(lst[b]))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
lst=list(input() for i in range(h))
print(lst)
for a in lst:
    if a=="."*w:
        h-=1
        lst.remove(a)
for i in range(w):
    T=True
    if i>w:
        break
    for b in range(h):
        if lst[b][i]!="." :
            T=False
            break
    if T==True:
        for b in range(h):
            lst[b]=lst[b][:i]+lst[b][i+1:]
            w-=1
for b in range(h):
    print("".join(lst[b]))

Submission status: Wrong Answer

Solution code:
import copy
h,w=map(int,input().split())
a=[]
deleted=0
for i in range(h):
    l=list(input())
    for j in l:
        if j=='#':
            a.append(l)
            break
    else:
        deleted+=1
print(a)

h-=deleted

deleted=0
b=copy.deepcopy(a)
for i in range(w):
    for j in range(h):
        if a[j][i]=='#':
            break
    else:
        for j in range(h):
            b[j].pop(i-deleted)
        deleted+=1

s=''
for i in b:
    s+=''.join(i)+'\n'
print(s)

Submission status: Wrong Answer

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

for h in range(H):
    temp = []
    line = input()
    for w in range(W):
        temp.append(line[w])
    grid.append(temp)

for n, l in enumerate(grid):
    if not any([grid[n][w] == '#' for w in range(len(grid[n]))]):
            grid.pop(n)
            break

for w in range(W):
    if not any([grid[h][w] == '#' for h in range(len(grid))]):
        for h in range(len(grid)):
            grid[h][w] = ''

for h in range(len(grid)):
    print(''.join(grid[h]))

Submission status: Wrong Answer

Solution code:
h,w = map(int,input().split())
map_ = list()
for i in range(h):
    map_.append(list(input()))
flag = True
while flag:

    flag = False

    for ii in range(len(map_)):
        if set(map_[ii]) == {"."}:
            del map_[ii]
            flag = True
            break

    map_t = [list(x) for x in zip(*map_)]

    for ii in range(len(map_t)):
        if set(map_t[ii]) == {"."}:
            del map_t[ii]
            flag = True
            break

    map_ = map_t

for iiii in map_:
    print(*iiii,sep="")

Submission status: Wrong Answer

Solution code:
h,w = map(int,input().split())
map_ = list()
for i in range(h):
    map_.append(list(input()))
flag = True
while flag:

    flag = False

    for ii in range(len(map_)):
        if set(map_[ii]) == {"."}:
            del map_[ii]
            flag = True
            break

    map_t = [list(x) for x in zip(*map_)]

    for ii in range(len(map_t)):
        if set(map_t[ii]) == {"."}:
            del map_t[ii]
            flag = True
            break

    map_ = map_t.copy()

for iiii in map_:
    print(*iiii,sep="")

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[[c for c in input()] for _ in range(h)]
b=[]
flag=0
for s in a:
  if ("#" in s) and ("." in s):
    b.append(s)
for i in range(w):
  flag=0
  for j in range(len(b)):
    if b[j][i]!=b[0][i]:
      flag=1
      break
  if flag==0:
    for j in range(len(b)):
      b[j][i]=""
for s in b:
  print("".join(s))

Submission status: Wrong Answer

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

ans = 0
minans = 0
flag = 0
row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if li[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(li[i][j],end =" ")
                
        print()

Submission status: Wrong Answer

Solution code:
h,w= map(int,input().split())
l = list()
m = 0
for i in range(h):
  c = input()
  if "#" in c:
    b = [ w for w in range(len(c)) if c[w] == "#" ]
    l.append(b)
    if m < max(b) : m = max(b)
p = list()
for i in range(m) :
  for j in l:
    if i in j: break
  else:
    p.append(i)
for j in range(len(l)):
  for e in range(len(l[j])):
    cnt = 0
    for q in p:
      if l[j][e] > q : cnt += 1
    l[j][e]  = l[j][e]  - cnt
print(l)
m = 0
for i in l:
  if m < max(i) : m = max(i)
for i in l:
  t = ""
  for j in range(m+1):
    if j in i : t = t + "#"
    else: t = t + "."
  print(t)

Submission status: Wrong Answer

Solution code:
h,w= map(int,input().split())
l = list()
m = 0
for i in range(h):
  c = input()
  if "#" in c:
    b = [ w for w in range(len(c)) if c[w] == "#" ]
    l.append(b)
    if m < max(b) : m = max(b)
p = list()
for i in range(m) :
  for j in l:
    if i in j: break
  else:
    p.append(i)
for j in range(len(l)):
  for e in range(len(l[j])):
    for q in p:
      if l[j][e] > q : l[j][e]  = l[j][e]  - 1 
m = 0
for i in l:
  if m < max(i) : m = max(i)
for i in l:
  t = ""
  for j in range(m+1):
    if j in i : t = t + "#"
    else: t = t + "."
  print(t)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = []
hantei = 0
for i in range(H):
    aa = input()
    if aa != '.'*W:
        a.append(aa)
ans = []
for i in range(W):
    las_kensa = [k[i] for k in a]
    if ''.join(las_kensa) =='.'*len(a):
        hantei = 1
        g = [gyou1[:i]+gyou1[i+1:] for gyou1 in a]

if hantei == 1:
    for i in g:
        print(i)
else:
    for i in a:
        print(i)

Submission status: Wrong Answer

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

newGrid = []
for i in range(h):
    a = list(input())
    for j,a_j in enumerate(a):
        if a_j == "#":
            newGrid.append(a)
            break
        else:
            continue

ans = []
for j in range(w):
    for i in range(len(newGrid)):
        if newGrid[i][j] == "#":
            ans.append([newGrid[k][j] for k in range(len(newGrid))])
            break
        else:
            continue
            
for ansi in ans:
    print("".join(ansi))

Submission status: Wrong Answer

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

newGrid = []
for i in range(h):
    a = list(input())
    for j,a_j in enumerate(a):
        if a_j == "#":
            newGrid.append(a)
            break
        else:
            continue

ans = []
for j in range(w):
    for i in range(len(newGrid)):
        if newGrid[i][j] == "#":
            ans.append([newGrid[k][j] for k in range(len(newGrid))])
            break
        else:
            continue
            
print(ans)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split(" "))
A=[]
for i in range(H):
    tmp = input()
    A.append ([c  for c in tmp])
    
# print (A)

h=H
w=W
for i in range(H):
    for t in range(H+W):
        cnt = 0    
        for j in range(W):
            if A[i][j] == ".":
                cnt += 1


        if cnt == W:
            h -= 1
            for ii in range(i, H-1):
                for jj in range(W):
                    A[ii][jj] = A[ii+1][jj]

for j in range(W):
    for t in range(H+W):
        cnt = 0    
        for i in range(h):
            if A[i][j] == ".":
                cnt += 1


        if cnt == h:
            w -= 1
            for jj in range(j, W-1):
                for ii in range(h):
                    A[ii][jj] = A[ii][jj+1]

# print ("h={0} w={1}\n".format(h, w))
for i in range(h):
    st = ""
    for j in range(w):
        st += (A[i][j])
        
    print (st)