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(" "))
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):
    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):
    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)

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):
    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):
    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)

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):
    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):
    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))
B = []
for i in range(h):
    B.append([])
    for j in range(w):
        B[i].append (A[i][j])
        
        
print (B)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

ns = lambda: stdin.readline()[:-1] # s = ns()
ni = lambda: int(stdin.readline()) # N = ni()
na = lambda: list(map(int, stdin.readline().split())) # Arr = na()

H, W = na()
Grid = []
for _ in range(H):
    s = ns()
    if '#' in s:
        Grid.append(list(s))

h = len(Grid)
res = []
for i in range(W):
    s = ''
    for j in range(h):
        s += Grid[j][i]
    if '#' in s:
        res.append(s)

for i in range(len(res[0])):
    s = ''
    for j in range(len(res)):
        s += res[-1-j][i]
    print(s)

Submission status: Wrong Answer

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

for i in range(h):
    count = 0
    for j in range(w):
        if a[i][j][0] == a[i][0][0]:
            count += 1
    if count == w:
        for j in range(w):
            a[i][j][1] = True

for i in range(w):
    count = 0
    for j in range(h):
        if a[j][i][0] == a[0][i][0]:
            count += 1
    if count == h:
        for j in range(h):
            a[j][i][1] = True

for i in a:
    flag = False
    for j in i:
        if not j[1]:
            print(j[0],end = "")
            flag = True
    if flag:
        print("")

Submission status: Wrong Answer

Solution code:

H,W= map(int,raw_input().split())

M = []
for i in range(H):
	M.append(raw_input())
	
flag_list_H = []
for i in range(H):
	if '#' in M[i]:
		flag_list_H.append(True)
	else:
		flag_list_H.append(False)

flag_list_W = []
for i in range(W):
	flag = False
	for j in range(H):
		if M[j][i]=='#':
			flag=True
	flag_list_W.append(flag)

for i in range(H):
	if flag_list_H[i]:
		answer = ""
		for j in range(W):
			if flag_list_W[j]:
				answer+=M[i][j] + " "
		print answer[:-1]

Submission status: Wrong Answer

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

# Filtering the data if any "#" are existed in the each row or col
# Usage: filter(lambda row: <filtering condition>, grid or zip(*grid)) 
# If true, the row is not be deleted
# (Do not use if statement!)
row_compressed_grid = list(filter(lambda row: any(x == "#" for x in row), grid)) 
compressed_grid = list(filter(lambda col: any(x == "#" for x in col), zip(*row_compressed_grid)))

# list -> string and out
for row in compressed_grid:
    print("".join(row))

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W = list(map(int, input().split()))
arr = np.array([list(input()) for i in range(H)])
arr = arr[(np.apply_along_axis(lambda line: '#' in line, 1, arr))]
arr = arr[:, (np.apply_along_axis(lambda line: '#' in line, 0, arr))]
print(arr)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
H,W = (int(i) for i in input().split(' '))
A = ''
h,w = H,W

for i in range(H):
    row = input()
    if row.count('.') != W:
        A = A + row
    else:
        h = h - 1


# translate
B=''
for j in range(W):
    row = A[j::W]
    if row.count('.') != h:
        B = B + row
    else:
        w = w -1
A=''
for i in range(h):
    A = A + B[i::h]
     
for i in range(w):
    print(A[i*w:(i+1)*w])

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])
        print()

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
grid=[list(input())  for i in range(h)]
tag=[]
for i in range(w):
    a=[grid[j][i] for j in range(h)]
    if not "#" in a:tag.append(i)
for i in tag[::-1]:
    for j in range(h):
        grid[j].pop(i)
for i in grid:
    if "#" in i:print(*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
print(row, col)

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())
a = [input() for _ in range(H)]
row = [False] * H
col = [False] * W
for i in range(len(row)):
  for j in range(len(col)):
    if a[i][j] == '#':
      row[i] = col[j] = True

for i in range(len(row)):
  if row[i]:
    for j in range(len(col)):
      if col[j]:
        print(a[i][j], '')
    print()

Submission status: Wrong Answer

Solution code:
arr = []

h, w = [int(i) for i in input().split()]
for _ in range(h):
    arr.append(input())

result = []
for ar in arr:
    if not '#' in ar:
        continue
    result.append(ar)

h = len(result)
w = len(result[0])


# print(result)
# print(h, w)

result2 = []
for j in range(w):
    flag = True
    for i in range(h):
        if result[i][j] == '#':
            flag = False
    if flag:
        result2.append(j)

result3 = []
for k in result2:
    #k番目を取り除く
    for s in result:
        line = ''
        for i, c in enumerate(s):
            if i==k:
                continue
            line += c
        result3.append(line)

for line in result3:
    print(line)

Submission status: Wrong Answer

Solution code:
# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]


for h in range(H):
    if '#' in a[h]:
        for w in range(W):
            a[h][w] = ''
for w in range(W):
    if '#' in [p[w] for p in a]:
        for h in range(H):
            a[h][w] = ''

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

Submission status: Wrong Answer

Solution code:
# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]

compressed = False
while compressed:
    compressed = False
    for h in range(H):
        if '#' not in a[h]:
            for w in range(W):
                a[h][w] = ''
                compressed = True
    for w in range(W):
        if '#' not in [p[w] for p in a]:
            for h in range(H):
                a[h][w] = ''
                compressed = True

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

Submission status: Wrong Answer

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

a=[]
H=[1 for i in range(h)]
W=[1 for i in range(w)]
cnt=0

for i in range(h):
  a.append(input())
  if not "*" in a[i]:
    H[i]=0
#print(H)

for i in range(w):
  cnt=0
  for j in range(h):
    if a[j][i]==".":
      cnt=cnt+1
  if cnt==h:
    W[i]=0
#print(W)

for i in range(h):
  for j in range(w):
    if (H[i]) and (W[j]):
      print(a[i][j],end="")
#  if H[i]:print()

Submission status: Wrong Answer

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

a=[]
H=[1 for i in range(h)]
W=[1 for i in range(w)]
cnt=0

for i in range(h):
  a.append(input())
  if not "*" in a[i]:
    H[i]=0
#print(H)

for i in range(w):
  cnt=0
  for j in range(h):
    if a[j][i]==".":
      cnt=cnt+1
  if cnt==h:
    W[i]=0
#print(W)

for i in range(h):
  for j in range(w):
    if (H[i]) and (W[j]):
      print(a[i][j],end="")
  if H[i]:print()

Submission status: Wrong Answer

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

a=[]
H=[1 for i in range(h)]
W=[1 for i in range(w)]
cnt=0

for i in range(h):
  a.append(input())
  if not "*" in a[i]:
    H[i]=0
print(H)

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

for i in range(h):
  for j in range(w):
    if (H[i]) and (W[j]):
      print(a[i][j],end="")
  if H[i]:print()

Submission status: Wrong Answer

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

ansW,ansH = [],[]
for hi in range(H):
    for wi in range(W):
        if A[hi][wi] == "#":
            break
    else:
        ansH.append(hi)
for wi in range(W):
    for hi in range(H):
        if A[hi][wi] == "#":
            break
    else:
        ansW.append(wi)

Ans = []
for hi in range(H):
    if hi not in ansH:
        ans = ""
        for wi in range(W):
            if wi not in ansW:
                ans += A[hi][wi]
        Ans.append(ans)

print(Ans)

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
a = [''] * h
print(a)
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 = '')
        print()

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W = map(int, raw_input().split())
a = []
for i in range(H):
	_a = list(raw_input())
	a.append(_a)
a = np.array(a)
b = a.copy()
#while True:
r_exist = False
c_exist = False
for i in range(len(a)):
	if not '#' in a[i, :]:
		b = np.delete(a, i, 0)
		r_exist = True
a = b.copy()
for i in range(len(b[0])):
	if not '#' in b[:, i]:
		a = np.delete(b, i, 1)
		c_exist = True
b = a.copy()
#	if not (r_exist or c_exist):
#		break
for i in b:
	print ('').join(i)

Submission status: Wrong Answer

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

field = []
hist = [0 for w in range(W)]

def shrink():
    newField = []
    for h in range(H):
        line = []
        for w in range(W):
            if(hist[w] != H):
                line.append(field[h][w])
        newField.append(line)        
    return newField            

for h in range(H):
    line = list(input().strip())
    if(line.count(".") != len(line)):
        field.append(list(line))
        for w in range(W):
            hist[w] += 1 if field[-1][w] == "." else 0 
H = len(field)

newField = shrink()

for h in newField:
 "".join(h)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = [input() for _ in range(h)]
ans_w = []
ans_h = []
for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      break
  else:
    ans_h.append(i)
for j in range(w):
  for i in range(h):
    if a[i][j] == "#":
      break
  else:
    ans_w.append(j)

for i in ans_h:
  print(*[a[i][j] for j in ans_w], sep="")

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
mas = []
deltags = []
for x in range(W):
    try:
        temp = list(input())
    except:
        pass
    if "#" in temp:
        mas.append(temp)

for x in range(len(mas[0])):
    deltag = False
    for y in range(len(mas)):
        if mas[y][x] == "#":
            break
        if y == len(mas)-1:
            deltag = True
    deltags.append(deltag)

for x in range(len(mas)):
    for y in range(len(mas[x])):
      if deltags[y]:
        mas[x][y] = "A"

try:
    x = 0
    while True:
        while "A" in mas[x]:
            mas[x].remove("A")
        print("".join(mas[x]))
        x += 1
except:
    pass

Submission status: Wrong Answer

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

v_list = []
reverse_list = [""]*W
h_list = []

for i in range(H):
    if "#" in A[i]:
        v_list.append(A[i])

print(v_list)

for i in range(W):
    for j in range(len(v_list)):
        reverse_list[i] = reverse_list[i] + v_list[j][i]

for i in range(W):
    if "#" in reverse_list[i]:
        h_list.append(reverse_list[i])

result_list = [""]*(len(h_list[0]))

for i in range(len(h_list[0])):
    for j in range(len(h_list)):
        result_list[i] = result_list[i] + h_list[j][i]

for s in result_list:
    print(s)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
mas = []
deltags = []
for x in range(W):
    try:
        temp = list(input())
    except:
        pass
    if "#" in temp:
        mas.append(temp)
for x in range(len(mas[0])):
    deltag = False
    for y in range(len(mas)):
        if mas[y][x] == "#":
            break
        if y == len(mas)-1:
            deltag = True
    deltags.append(deltag)

for x in range(len(mas)):
    for y in range(len(mas[x])):
      if deltags[y]:
        mas[x][y] = "A"

for x in range(len(mas)):
    for y in range(len(mas[x])):
      while "A" in mas[x]:
        mas[x].remove("A")
    print("".join(mas[x]))

Submission status: Wrong Answer

Solution code:
h,w=map(int, input().split())
s = [list(input()) for i in range(h)]
for i in s:print(i)
s=[i for i in s if '#' in i]
count=0
while count<len(s[0]):
    check=0
    for i in s:
        if i[count]=='#':
            check=1
    if check==0:
        for i in s:
            i.pop(count)
    else:count+=1
for i in s:print(''.join(i))

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
mas = []
deltags = []
for x in range(W):
    try:
        temp = list(input())
    except:
        pass
    if "#" in temp:
        mas.append(temp)
for x in range(len(mas[0])):
    deltag = False
    for y in range(len(mas)):
        if mas[y][x] == "#":
            break
        if y == len(mas)-1:
            deltag = True
    if deltag:
        deltags.append(True)
    else:
        deltags.append(False)

for x in range(len(mas)):
    for y in range(len(mas[x])):
      if deltags[y]:
        mas[x][y] = "A"

for x in range(len(mas)):
    for y in range(len(mas[x])):
      while "A" in mas[x]:
        mas[x].remove("A")
    print("".join(mas[x]))

Submission status: Wrong Answer

Solution code:
h,w = (int(i) for i in input().split())
a,b = [],["" for i in range(w)]
for _ in range(h):
	s = input()
	if s.count("#")!=0:
		a.append(s)
		for i in range(w): b[i]+=s[i]
num,ans = [True for i in range(w)],["" for i in range(len(a))]
for i in range(w):
	if b[i].count("#")==0: num[i] = False
for i in range(len(a)):
	for j in range(w):
		if num[j]: ans[i]+=a[i][j]
for i in ans: print(ans)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
mas = []
for x in range(W):
    try:
        temp = list(input())
    except:
      pass
    if "#" in temp:
        mas.append(temp)
deltags = []
for x in range(len(mas[0])):
    deltag = False
    for y in range(len(mas)):
        if mas[y][x] == "#":
            break
        if y == len(mas)-1:
            deltag = True
    if deltag:
        deltags.append(True)
    else:
        deltags.append(False)

for x in range(len(mas)):
    for y in range(len(mas[x])):
      if deltags[y]:
        mas[x][y] = "A"

for x in range(len(mas)):
    for y in range(len(mas[x])):
      while "A" in mas[x]:
          mas[x].remove("A")
    print("".join(mas[x]))

Submission status: Wrong Answer

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

bw_str = []
for i in range(H):
    bw_str.append(input())

del_v = np.zeros(W)

for i in range(W):
    tmp = []
    for j in range(H):
        tmp.append(bw_str[j][i])
    if  (tmp.count('.') == 0) or \
        (tmp.count('#') == 0):
        del_v[i] = 1
    
del_h = np.zeros(H)
for i in range(H):
    if  (bw_str[i].count('.') == 0) or \
        (bw_str[i].count('#') == 0):
        del_h[i] = 1

list_ap_row = [i for i, a in enumerate(del_v) if a == 0]
list_ap_col = [i for i, a in enumerate(del_h) if a == 0]


for i in range(len(list_ap_col)):
    tmp_ans = []
    for j in range(len(list_ap_row)):
        tmp_ans.append(bw_str[list_ap_col[i]][list_ap_row[j]])
    print(''.join(tmp_ans))

Submission status: Wrong Answer

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


for i in a:
    if i == '.'*W:
        a.remove('.'*W)
        break


aa = list(map(list, zip(*a)))


for i in aa:
    if i == ['.']*len(aa[0]):
        aa.remove(['.']*len(aa[0]))
        break

aaa = list(map(list, zip(*aa)))

for i in aaa:
    print(''.join(i))

Submission status: Wrong Answer

Solution code:
i,j = map(int,input().split())

iCnt = 0
input_line = []
for iCnt in range(i):
    line = input()
    input_line.append (list(line))

for iCnt in reversed(range(i)):
    flg_white = True
    for jCnt in (range(j)):
        if input_line[iCnt][jCnt] != ".":
            flg_white = False
    if flg_white == True:
        del input_line[iCnt]

for line in input_line:
    for dot in line:
        print(dot,end="")
    print()

Submission status: Wrong Answer

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

bw_str = []
for i in range(H):
    bw_str.append(input())

del_v = np.zeros(W)

for i in range(W):
    tmp = []
    for j in range(H):
        tmp.append(bw_str[j][i])
    if  (tmp.count('.') == 0) or \
        (tmp.count('#') == 0):
        del_v[i] = 1
    
del_h = np.zeros(H)
for i in range(H):
    if  (bw_str[i].count('.') == 0) or \
        (bw_str[i].count('#') == 0):
        del_h[i] = 1

list_ap_row = [i for i, a in enumerate(del_v) if a == 0]
list_ap_col = [i for i, a in enumerate(del_h) if a == 0]


for i in range(len(list_ap_col)):
    tmp_ans = []
    for j in range(len(list_ap_row)):
        tmp_ans.append(bw_str[i][j])
    print(''.join(tmp_ans))

Submission status: Wrong Answer

Solution code:
def main():
    num_lines=int(input())
    H,W=[int(j) for j in input().split()]
    list=[]
    for i in range(H):
        for k in input.split():
            list.append(k)

Submission status: Wrong Answer

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

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


for i in range(H)[::-1]:
    s = 0
    if "#" in a[i]:
        continue
    else:
        del a[i]
        s += 1

for j in range(W)[::-1]:
        m = [t[j] for t in a[0:H-s-1]]
        if "#" in m:
            continue
        else:
            del m

print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

field=[i for i in field if "#" in i]

field=np.array(field)
#print(field)

field=np.rot90(field,k=1)
field=field.tolist()

field=[i for i in field if "#" in i]

field=np.rot90(field,k=-1)
field=field.tolist()

print(field)

Submission status: Wrong Answer

Solution code:
HW = input()
masu = "none"
hw = HW.split()

Adata = []
for lop in range(int(hw[0])):
    A = input()
    Adata.append(A)

x = []
y = []
buf = ""
for lop in range(int(hw[0])):
    if str(Adata[lop]).find(".") == -1 or str(Adata[lop]).find("#") == -1:
      x.append(lop)
      
for lop in range(int(hw[1])):
    for lop2 in range(int(hw[0])):
        buf = buf + str(Adata[lop2][lop])
    if str(buf).find(".") == -1:
        y.append(lop)
    buf = ""

for lop in range(len(x)-1,-1,-1):
    Adata.pop(x[lop])


ans = []
for lop in range(len(Adata)):
    buf = list(Adata[lop])
    for lop2 in range(len(y)-1,-1,-1):
        buf.pop(y[lop2])
    ans.append(buf)

for lop in range(len(ans)):
    ANS = ""
    for lop2 in range(len(ans[0])):
        ANS += ans[lop][lop2]
    print(ANS)

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
li = [input() for i in range(H)]
num_lists = []
num_lists2 = []
for i in range(H):
    if "#" in li[i]:
        print("") 
    else :
        num_lists.append(i)
for i in reversed(num_lists):
    li.pop(i)
n_H = len(li)
for i in range(W) :
    ch_li = []
    for j in range(n_H):
        ch_li.append(li[j][i])
    if "#" in ch_li:
        print("")
    else :
        num_lists2.append(i)
for i in reversed(num_lists2):
    for k in range(n_H) :
        li[k] = li[k][:i]+li[k][(i+1):]
print(li)

Submission status: Wrong Answer

Solution code:
import numpy as np

h,w=map(int,input().split())
tmp=[]
for i in range(h):
        a=list(input())
        tmp.append(a)
ans1=[]
for i in range(h):
    if(len(set(tmp[i]))==1 and tmp[i]!="#"):
        ans1.append(i)
ans2=[]
tmp=list(map(list,zip(*tmp)))
for i in range(w):
    if(len(set(tmp[i]))==1 and tmp[i]!="#"):
        ans2.append(i)
# print(ans1,ans2)
tmp=list(map(list,zip(*tmp)))
tmp=np.delete(tmp,ans1,axis=0)
tmp=np.delete(tmp,ans2,axis=1)
for i in range(len(tmp)):
    for j in range(len(tmp[0])):
        print(tmp[i][j],end="")
    print()

Submission status: Wrong Answer

Solution code:
import numpy as np

h,w=map(int,input().split())
tmp=[]
for i in range(h):
        a=list(input())
        tmp.append(a)
ans1=[]
if(w!=1):
    for i in range(h):
        if(len(set(tmp[i]))==1 and tmp[i]!="#"):
            ans1.append(i)
ans2=[]
tmp=list(map(list,zip(*tmp)))
if(h!=1):
    for i in range(w):
        if(len(set(tmp[i]))==1 and tmp[i]!="#"):
            ans2.append(i)
# print(ans1,ans2)
tmp=list(map(list,zip(*tmp)))
tmp=np.delete(tmp,ans1,axis=0)
tmp=np.delete(tmp,ans2,axis=1)
for i in range(len(tmp)):
    for j in range(len(tmp[0])):
        print(tmp[i][j],end="")
    print()

Submission status: Wrong Answer

Solution code:
import sys

HW = input()
masu = "none"
hw = HW.split()

Adata = []
for lop in range(int(hw[0])):
    A = input()
    Adata.append(A)

x = []
y = []
buf = ""
for lop in range(int(hw[0])):
    if str(Adata[lop]).find(".") == -1 or str(Adata[lop]).find("#") == -1:
      x.append(lop)
      
for lop in range(int(hw[1])):
    for lop2 in range(int(hw[0])):
        buf = buf + str(Adata[lop2][lop])
    if str(buf).find(".") == -1 or str(buf).find("#") == -1:
        y.append(lop)
    buf = ""

for lop in range(len(x)-1,-1,-1):
    Adata.pop(x[lop])


ans = []
for lop in range(len(Adata)):
    buf = list(Adata[lop])
    for lop2 in range(len(y)-1,-1,-1):
        buf.pop(y[lop2])
    ans.append(buf)

for lop in range(len(ans)):
    ANS = ""
    for lop2 in range(len(ans[0])):
        ANS += ans[lop][lop2]
    print(ANS)

Submission status: Wrong Answer

Solution code:
import numpy as np

h,w=map(int,input().split())
tmp=[]
for i in range(h):
        a=list(input())
        tmp.append(a)
ans1=[]
for i in range(h):
    if(len(set(tmp[i]))==1):
        ans1.append(i)
ans2=[]
tmp=list(map(list,zip(*tmp)))
for i in range(w):
    if(len(set(tmp[i]))==1):
        ans2.append(i)
# print(ans1,ans2)
tmp=list(map(list,zip(*tmp)))
tmp=np.delete(tmp,ans1,axis=0)
tmp=np.delete(tmp,ans2,axis=1)
for i in range(len(tmp)):
    for j in range(len(tmp[0])):
        print(tmp[i][j],end="")
    print()

Submission status: Wrong Answer

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

num_list=[]

for i in range(1,h+1):
    tmp_list = list(input())
    if("#" in tmp_list):
       num_list.append(tmp_list)

tate=[]
newh=len(num_list)

for i in range(0,w):
  for j in range(0,newh):
       if(num_list[j][i]=="#"):
          break
       if(j==newh-1):
          tate.append(i)

tate.reverse()

for j in range(0,newh):
    for k in tate:
      del num_list[j][k]
    print(" ".join(num_list[j]))

Submission status: Wrong Answer

Solution code:
ip = input().split()
data = []
for i in ip:
    data.append(int(i))

def pary(array):
    # print
    for i in range(len(array)):
        for j in range(len(array[i])):
            print(array[i][j], end="")
        print("")


H = data[0]
W = data[1]

array = []

for i in range(H):
    ip = input()
    data = []
    for j in ip:
        data.append(j)
    array.append(data)

#array is completed#
count = 0

# 縦
# convert
carray = []
for q in range(W):
    carray.append([])

for p in array:
    for q in range(len(p)):
        carray[q].append(p[q])

#pary(carray)

# judge
for p in carray:
    if len([i for i in p if i == "."]) == len(p):
        for r in range(H):
            #print(r,count)
            del array[r][count]
    else:
            count += 1
 #   pary(array)
#横

count = 0
for p in array:
    if len([i for i in p if i == "."]) == len(p):
        del array[count]
    else:
        count += 1

pary(array)

Submission status: Wrong Answer

Solution code:
import numpy as np
A = []
length = list(map(int,input().split()))
for i in range(0,length[0]):
    A.append(input())
for i in A:
    frag = 1
    for j in i:
        if j != '.':
            frag = 0
    if frag == 1:
        del A[A.index(i)]
B = list(map(list, zip(*A)))
for i in B:
    frag = 1
    for j in i:
        if j != '.':
            frag = 0
    if frag == 1:
        del B[B.index(i)]
A = list(map(list, zip(*B)))
for i in A:
  for j in i:
    print(j,end="")
  print()

Submission status: Wrong Answer

Solution code:
import numpy as np
A = []
length = list(map(int,input().split()))
for i in range(0,length[0]):
    A.append(input())
 
for i in A:
    frag = 1
    for j in i:
        if j != '.':
            frag = 0
    if frag == 1:
        del A[A.index(i)]
B = list(map(list, zip(*A)))
for i in B:
    frag = 1
    for j in i:
        if j != '.':
            frag = 0
    if frag == 1:
        del B[B.index(i)]
A = list(map(list, zip(*B)))
for i in A:
  for j in i:
    print(j,end="")
  print()

Submission status: Wrong Answer

Solution code:
import copy

H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(input().split())
aa = copy.copy(a)
#print(a)
aaa = 0
for i in range(H):
    if a[i][0] == "....":
        aa.pop(i-aaa)
        aaa += 1
#print(aa)
b = []
bb = ""
for i in range(W):
    for j in range(H-aaa):
        bb += aa[j][0][i]
    b.append(bb)
    bb = ""
#print(b)
d = ""
for i in range(H-aaa):
    d += "."
#print(d)
bc = copy.copy(b)
bbb = 0
for i in range(W):
    if b[i] == d:
        bc.pop(i-bbb)
        bbb += 1
#print(bc)
ans = []
ansc = ""
for i in range(H-aaa):
    for j in range(W-bbb):
        ansc += bc[j][i]
    ans.append(ansc)
    ansc = ""
#print(ans)
for i in range(H-aaa):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

A = []
length = list(map(int,input().split()))
for i in range(0,length[0]):
	A.append(input())

for i in A:
    frag = 1
    for j in i:
        if j != '.':
            frag = 0
    if frag == 1:
    	del A[A.index(i)]
B = list(map(list, zip(*A)))
for i in B:
    frag = 1
    for j in i:
        if j != '.':
            frag = 0
    if frag == 1:
    	del B[B.index(i)]
A = list(map(list, zip(*B)))
for i in A:
  for j in i:
    print(j,end="")
  print()

Submission status: Wrong Answer

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

field = [[s for s in input()] for _ in range(h)]

tmp = ["" for _ in range(w)]
for i in range(h):
    for j in range(w):
        tmp[j] += field[i][j]

row = [s.count("#") == 0 for s in field]
col = [s.count("#") == 0 for s in tmp]

for i,r in enumerate(row):
    for j,c in enumerate(col):
       if not (r or c):
           print(field[i][j],end="")
    if not (r or c):
        print()

Submission status: Wrong Answer

Solution code:
import sys

aa = input().strip().split()
h = int(aa[0])
w = int(aa[1])
a = [list(input().strip()) for _ in range(h)]
r = [list() for _ in range(2)]

for i in range(h):
    if 1 < w:
        flag = True

        for j in range(1, w):
            if a[i][j] != a[i][0]:
                flag = False
                break

        if flag:
            r[0].append(i)

for i in range(w):
    if 1 < h:
        flag = True

        for j in range(1, h):
            if a[j][i] != a[0][i]:
                flag = False
                break

        if flag:
            r[1].append(i)

for i in reversed(range(len(r[0]))):
    del a[r[0][i]]

for i in reversed(range(len(r[1]))):
    for j in reversed(range(len(a))):
        del a[j][r[1][i]]

for i in range(len(a)):
    for j in range(len(a[i])):
        sys.stdout.write(a[i][j])

    sys.stdout.write('\n')