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())
H = []
l = []
for i in range(h):
  k = list(input())
  if len(set(k)) == 1:
    H.append(i)
  l.append(k)
W = []
for j in range(w):
  flag = True
  x = l[0][j]
  for k in l:
    if k[j] != x:
      flag = False
  if flag:
    W.append(j)
for i in H: 
  for j in range(w):
    l[i][j] = ''
for j in W:
  for i in range(h):
    l[i][j] = ''
for k in l:
  if ''.join(k) != '':
    print(''.join(k))

Submission status: Wrong Answer

Solution code:
A,B=[],[]
h,w=map(int,input().split())
for i in range(h):
    a=input()
    if "#" in a:
        A.append(a)
b=""
for i in range(w):
    if "#" not in b:
        B.append(i-1)
    b=""
    for j in range(len(A)):
        b+=A[j][i]
b=""
b+=A[len(A)-1][w-1]
if "#" not in b:
    B.append(w-1)
B.pop(0)
o=0
for i in range(len(A)):
    o=0
    A[i]=list(A[i])
    for j in B:
        A[i].pop(j-o)
        if o==len(B)-1:
            print("".join(A[i]))
        o+=1
if len(B)==0:
    for i in A:
        print("".join(i))

Submission status: Wrong Answer

Solution code:
A,B=[],[]
h,w=map(int,input().split())
for i in range(h):
    a=input()
    if "#" in a:
        A.append(a)
b=""
for i in range(w):
    if "#" not in b:
        B.append(i-1)
    b=""
    for j in range(len(A)):
        b+=A[j][i]
b=""
b+=A[len(A)-1][w-1]
if "#" not in b:
    B.append(w-1)
B.pop(0)
o=0
for i in range(len(A)):
    o=0
    A[i]=list(A[i])
    for j in B:
        A[i].pop(j-o)
        if o==len(B)-1:
            print("".join(A[i]))
        o+=1

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
s=[]
d=0
for i in range(h):
  t=input()
  if t.count('.')!=h:
    s.append(t)
  else:
    d+=1

l=[list(x) for x in zip(*s)]
t2=[]
for e in l:
  if e.count('.')!=h-d:
    t2.append(e)

ans=[list(x) for x in zip(*t2)]
for e in ans:
  print(''.join(e))

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w=map(int,input().split())
a=np.array([ list(input()) for i in range(h)])
count=0
d_w=[]
d_h=[]
for i in range(0,h):
  count=0
  for j in range(0,w):
    if a[i][j]==".":
      count+=1
  if count==w:
    d_w.append(i)
for i in range(0,w):
  count=0
  for j in range(0,h):
    if a[j][i]==".":
      count+=1
  if count==h:
    d_h.append(i)
a=np.delete(a,d_w,0)
a=np.delete(a,d_h,1)
for i in a:
  print(*i)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
grid = []
ignore_i = []
ignore_j = []
for i in range(h):
    l = list(input())
    grid.append(l)
    
    if  not("#" in l and "." in l):
        ignore_i.append(i)

for j in range(w):
    same = True
    for i in range(1, h):
        if grid[i-1][j] != grid[i][j]:
            same = False
            break
    if same:
        ignore_j.append(j)

ans = [[]*h]
ans_i = 0

for i in range(h):
    if i in ignore_i:
        continue

    for j in range(w):
        if j in ignore_j:
            continue
        print(grid[i][j], end="")
    print("\n")

Submission status: Wrong Answer

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

squares = list()
square = list()
judges = list()
judge = list()

for x in range(0, H):
    word = input()
    for a in word:
        square.append(a)
    squares.append(square)
    square = list()

for a in squares:
    if a == ['.']*W:
        del squares[squares.index(a)]

H = len(squares)

for a in range(0, W):
    for b in range(0, H):
        if squares[b][a] == '.':
            judge.append(True)
        else:
            judge.append(False)
    judges.append(judge)
    judge = list()

for a in range(0, W):
    if all(judges[a]):
        for b in range(0, H):
            squares[b][a] = 0

for a in range(0, H):
    for b in range(0, W):
        if squares[a][b] != 0:
            print(squares[a][b], end='')
    print('')

Submission status: Wrong Answer

Solution code:
def rotate(mat):
  mat2 = []
  for i in range(len(mat[0])):
    s = ""
    for k in range(len(mat)):
      s = s + mat[k][i]
    mat2.append(s)
  return mat2

H,W=map(int, input().split())
mat = []
for i in range(H):
  a = input()
  if "#" in a:
    mat.append(a)

for count in range(H+W):
  for i in range(len(mat)-1, 0, -1):
    if not "#" in mat[i]:
      del mat[i]
  rotate(mat)
  for i in range(len(mat)-1, 0, -1):
    if not "#" in mat[i]:
      del mat[i]
  rotate(mat)
  
for i in range(len(mat)):
  print(mat[i])

Submission status: Wrong Answer

Solution code:
def rotate(mat):
  mat2 = []
  for i in range(len(mat[0])):
    s = ""
    for k in range(len(mat)):
      s = s + mat[k][i]
    mat2.append(s)
  return mat2

H,W=map(int, input().split())
mat = []
for i in range(H):
  a = input()
  if "#" in a:
    mat.append(a)

for count in range(H+W):
  for i in range(len(mat)-1, 0, -1):
    if not "#" in mat[i]:
      del mat[i]
  rotate(mat)
  for i in range(len(mat)-1, 0, -1):
    if not "#" in mat[i]:
      del mat[i]
  rotate(mat)
  

print(mat)

Submission status: Wrong Answer

Solution code:
def strCut(s,n):
  return s[0:n] + s[n+1:len(s)]

H,W=map(int, input().split())
s_list = []
for i in range(H):
  s = input()
  if "#" in s: s_list.append(s)

Submission status: Wrong Answer

Solution code:
from functools import reduce
H, W =  map(int,input().split())
list1 = [input() for i in range(H)]
row_index = []
column_index =[]
print(list1)
[row_index.append(i) for i, elem in  enumerate(list1) if elem.count(".") < W]
[column_index.append(i) for i,elem in enumerate(zip(*list1)) if elem.count(".")<H]
for i in  row_index:
  for j in column_index:
    print(list1[i][j],end="")
  print("")

Submission status: Wrong Answer

Solution code:
num = list(map(int, input().split()))

grid = []
del_i = []
del_n = []

for i in range(num[0]):
  grid.append(list(input()))

  if "#" in grid[i] and "." in grid[i]:
    continue
  else:
    del_i.append(i)

check_1, check_2 = 0, 0

for n in range(num[1]):
  check_1, check_2 = 0, 0
  for i in range(num[0]):
    if grid[i][n] == "#":
      check_1 += 1
      if check_2 > 0:
        break
      if check_1 == num[0]:
        del_n.append(n)
    else:
      check_2 += 1
      if check_1 > 0:
        break
      if check_2 == num[0]:
        del_n.append(n)

for i in range(num[0]):
  if i in del_i:
    continue
  else:
    m = 0
    for n in del_n:
      n = n - m
      del grid[i][n]
      m += 1
    print(''.join(grid[i]))

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = []
delrow = []
delcol = []
cnt = 0

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

for i in range(h):
    for j in range(1, w):
        if a[i][0] != a[i][j]:
            break
        else:
            cnt += 1
        if cnt == w - 1:
            delrow.append(i)
    cnt = 0

for i in range(w):
    for j in range(1, h):
        if a[0][i] != a[j][i]:
            break
        else:
            cnt += 1
        if cnt == h - 1:
            delcol.append(i)
    cnt = 0

for i in delrow [::-1]: #行を削除
    del a[i]
for i in delcol [::-1]: #列を削除
    for j in range(len(a)):
        del a[j][i]

for i in range(len(a)):
    print(*a[i], sep="")

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
A=[list(input()) for _ in range(H)]
row=[]
col=[]
for i in range(H):
    if len(set(A[i]))==1:
        row.append(i)
for i in range(W):
    tmp=[]
    for j in range(H):
        tmp.append(A[j][i])
    if len(set(tmp))==1:
        col.append(i)


for i in range(H):
    print("\n")
    for j in range(W):
        if i not in row and j not in col:
            print(A[i][j],end="")

Submission status: Wrong Answer

Solution code:
H,W = map(int, input().split())
map =[]
for _ in range(H):
     a = list(input())
     map.append([int(x !='.') for x in a ])
memo = []
for i in range(H):
    if sum(map[i]) == 0:
        memo.append(i)
while memo:
    del map[memo[-1]]
    del memo[-1]
    H -= 1
for j in range(W):
    color = [map[x][j] for x in range(H)]
    if sum(color) == 0:
        memo.append(j)
while memo:
    for k in range(H):
        del map[k][memo[-1]]
    del memo[-1]
    W = -1
for j in map:
    a = ["." if ab == 0 else "#" for ab in j]
    print(*a)

Submission status: Wrong Answer

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

# 横除外
b = [i for i in a if not i.count('.') == w]
for i in b:
    print(''.join(i))
# 縦除外
h2 = len(b)
w2 = len(b[0])
ret = []
for i in range(w2):
    for x in range(h2):
        if b[x][i] == '#':
            ax = [b[xx][i] for xx in range(h2)]
            ret += [ax]
            break
    else:
        continue

for i in range(len(ret[0])):
    print(''.join([ret[x][i] for x in range(len(ret))]))

Submission status: Wrong Answer

Solution code:
h,w = map(int,input().split())
a = [list(input()) for _ in range(h)]
y= 0
while y < h:
    x = 0
    flag = True
    while x < w:
        if a[y][x]=="#":
            flag = False
        x += 1
    if flag == True:
        a.pop(y)
        h -= 1
    y += 1
x = 0
while x < w:
    y = 0
    flag = True
    while y < h:
        if a[y][x]=="#":
            flag = False
        y += 1
    if flag == True:
        for i in range(h):
            a[i].pop(x)
        w -= 1
    x += 1

for i in a:
    ans = ''.join(i)
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


def yoko(row):
    cnt = sum(row)
    return cnt == len(row)


def main():
    h, w = map(int, input().split(' '))
    a = []

    for i in range(h):
        b = input()
        a += [1 if c == '.' else 0 for c in b]
    a = np.array(a).reshape(h, w)

    while True:
        cnt = 0
        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            del_cnt = 0
            for idx in del_list:
                a = np.delete(a, idx - del_cnt, axis=0)
                del_cnt += 1
        else:
            cnt += 1

        a = a.T

        print('-------')
        print(a)

        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            del_cnt = 0
            for idx in del_list:
                a = np.delete(a, idx - del_cnt, axis=0)
                del_cnt += 1
        else:
            cnt += 1

        a = a.T

        if cnt >= 2:
            break

    for i in range(len(a)):
        r = ''
        for j in a[i]:
            if j == 1:
                r += '.'
            else:
                r += '#'
        print(r)


main()

Submission status: Wrong Answer

Solution code:
# ABC 107: B – Grid Compression
h, w = [int(s) for s in input().split()]
a = [input() for _ in range(h)]

rows = []
columns = []

for i in range(w):
    for j in range(h):
        if a[j][i] != a[0][i]:
            break
    else:
        columns.append(i)

for i in range(h):
    if a[i].count('#') == 0 or a[i].count('.') == 0:
        rows.append(i)

for i in range(h):
    tmp = ''
    if i not in rows:
        for j in range(w):
            if j not in columns:
                tmp += a[i][j]
        print(tmp)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
grid = [list(input()) for i in range(h)]
if ['.']*w in grid:
  grid.remove(['.']*w)
for i in range(w):
  judge =True
  for j in range(len(grid)):
    if grid[j][i] == '#':
      judge = False
      break
  if judge:
    for j in range(len(grid)):
      grid[j][i] = ''

for i in range(len(grid)):
  L=''.join(grid[i])
  print(L)

Submission status: Wrong Answer

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

l=[]
for i in range(H):
  x=input()
  if x!='.'*W:
    l.append(x)

rm=[]
for i in range(W):
  f=True
  for j in range(len(l)):
    if l[j][i]=='#':
      f=False

  if f:
    rm.append(i)
print()
a=[]
print(l)
print(rm)
for x in l:
  for i in rm[::-1]:
    print(i)
    x=x[:i]+x[i+1:]
  a.append(''.join(x))

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
a = [input() for i in range(h)]
ans = []
memo_x = []
memo_y = []
for i in range(h):
    cnt = 0
    print(a[i])
    for j in range(w):
        if a[i][j] == '.':
            cnt += 1
    if cnt == w:
        memo_x.append(i)
for i in range(w):
    cnt = 0
    for j in range(h):
        if a[j][i] == '.':
            cnt += 1
    if cnt == h:
        memo_y.append(i)
for i in range(h):
    if i not in memo_x:
        b = ''
        for j in range(w):
            if j not in memo_y:
                b += a[i][j]
        ans.append(b)
for i in range(len(ans)):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
p,q= input().split()
a,b =(int(p), int(q))
a_list = []
count_row = 0
b_h ='.'*b

for i in range(a):
    c = input()
    
    if c == b_h:
        count_row+=1
    else:
        a_list.append(c)

ans_list=[]
for i in range(b):
    count_clm = 0
    
    for j in range(a-count_row):
        if a_list[j][i] == '.':
            count_clm+=1
    
    
    if count_clm == b:        
        ans_list.append(i)



for j in range(a-count_row):
    total=''
    for i in range(b):
        if i in ans_list:
            ds = 0
        else:
            total +=a_list[j][i]
            
    print(total)

Submission status: Wrong Answer

Solution code:
H, W = list(map(int, input().split()))  #リスト
A = list(input() for i in range(H)) #スペース抜きの複数行
#A = [input() for _ in range(H)]

B = [False] * H
C = [False] * W

print(A)
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            B[i] = True
            C[j] = True

for i in range(H):
	if B[i]:
		for j in range(W):
			if C[j]:
				print(A[i][j], end = '')
		print()

Submission status: Wrong Answer

Solution code:
inputs = open(0).readlines()
import numpy as np
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, rows in zip(range(h), grid):
            for j, val in zip(range(w), rows):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, rows)) for rows in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

h, w = map(int, inputs[0].split())
grid = Grid(inputs[1:]).grid
h0, w0 = h, w
h1, w1 = h+1, w+1
while h0 != h1 or w0 != w1:
    h1, w1 = grid.shape
    grid = grid[:, ~np.all(grid == '.', axis=0)]
    grid = grid[~np.all(grid == '.', axis=1), :]
    h0, w0 = grid.shape
print(*[''.join(map(str, rows)) for rows in grid], sep='\n')

Submission status: Wrong Answer

Solution code:
inputs = open(0).readlines()
import numpy as np
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, rows in zip(range(h), grid):
            for j, val in zip(range(w), rows):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, rows)) for rows in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

h, w = map(int, inputs[0].split())
grid_origin = Grid(inputs[1:])
grid = grid_origin.grid

grid = grid[:, ~np.all(grid == '.', axis=0)]
grid = grid[~np.all(grid == '.', axis=1), :]
print(*[''.join(map(str, rows)) for rows in grid], sep='\n')

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
G = [list(input()) for _ in range(H)]
v = [g for g in G if g.count('.') != W]
print(v)
for i in reversed(range(W)):
    chk = True
    for vv in v:
        if vv[i] == '#':
            chk = False
            break
    if chk:
        for vv in v:
            vv.pop(i)
for vv in v:
    print(''.join(vv))

Submission status: Wrong Answer

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

rev_maze = [[0] * H for i in range(W)]
for i in range(W):
    for j in range(H):
        #rev_maze = 
        rev_maze[i][j] = maze[j][i]

ans_yoko = []
for i in range(H):
    if maze[i].count('.') == W:
        ans_yoko.append(i)
        
ans_tate = []
for i in range(W):
    if rev_maze[i].count('.') == H:
        ans_tate.append(i)

for i in range(H):
    for j in range(W):
        if i in ans_yoko:
            continue
        if j in ans_tate:
            continue
        else:
            if j == W - 1:
                print(maze[i][j] + '')
            else:
                print(maze[i][j], end='')

Submission status: Wrong Answer

Solution code:
h,w = map(int,input().split())
l = list(list(input()) for i in range(h))
for i in l:
  if i.count('.') ==w:
    i.clear()
    l.remove([])
t = len(l)
for i in range(w):
  if all (l[q][i]=="." for q in range(t)):
    for q in range(t):
      l[q][i] =""
if "" in l:
  for z in l:
    z.remove("")
for i in l:
  print("".join(i))

Submission status: Wrong Answer

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

y = [False]*H
x = [False]*W

for i in range(H):
    for j in range(W):
        print(a[i][j])
        if a[i][j] == "#":
            y[i] = True
            x[j] = True
            
for i in range(H):
    if y[i] == True:
        for j in range(W):
            if x[j] == True:
                print(a[i][j],end="")
        print()

Submission status: Wrong Answer

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

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

y = [False]*H
x = [False]*W

for i in range(H):
    for j in range(W):
        if a[i][j] == "#":
            y[i] == True
            x[j] == True
            
for i in range(H):
    if y[i] == True:
        for j in range(W):
            if x[j] == True:
                print(a[i][j],end="")
        print()

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
A = [input() for i in range(H)]
low = [False]*H
col= [False]*W
for l in range(H):
    for c in range(W):
        if A[l][c] == "#":
            low[l] = True
            col[c] = True
for l in range(H):
    if low[l] ==True:
        for c in range(W):
            if col[c]==True:
                print("#",end="")
        print()

Submission status: Wrong Answer

Solution code:
h, w = [int(elem) for elem in input().split()]
matrix = []
for i in range(h):
  tmp = input()
  if '#' in tmp:
    matrix.append(tmp)

j = 0
while j < len(matrix[0]):
  tmp = [matrix[i][j] for i in range(len(matrix))]
  if not '#' in tmp:
    for i in range(len(matrix)):
      matrix[i] = matrix[i][:j] + matrix[i][j+1:]
  j += 1

if len(matrix) == 1:
  matrix[0] = matrix[0].strip(".")
  
for i in range(len(matrix)):
  print(matrix[i])

Submission status: Wrong Answer

Solution code:
h, w = [int(elem) for elem in input().split()]
matrix = []
for i in range(h):
  tmp = input()
  if '#' in tmp:
    matrix.append(tmp)

j = 0
while j < len(matrix[0]):
  tmp = [matrix[i][j] for i in range(len(matrix))]
  if not '#' in tmp:
    for i in range(len(matrix)):
      matrix[i] = matrix[i][:j] + matrix[i][j+1:]
  j += 1

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

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
a=[input() for i in range(H)]
useh=[True]*H
usew=[True]*W
for h in range(H):
    cnt=0
    for w in range(W):
        if a[h][w]=='.':
            cnt+=1
    if cnt in [0,W]:
        useh[h]=False
for w in range(W):
    cnt=0
    for h in range(H):
        if a[h][w]=='.':
            cnt+=1
    if cnt in [0,H]:
        usew[w]=False
for h in range(H):
    if useh[h]:
        for w in range(W):
            if usew[w]:
                print(a[h][w],end='')
        print()

Submission status: Wrong Answer

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

H,W = list(map(int, input().rstrip().split()))
a_list=[list(input().rstrip()) for i in range(H)]
#-----

row_del_list=[]
for i,v in enumerate(a_list):
    if v.count(".") == W:
        row_del_list.append(i)

for i in row_del_list[::-1]:
    del a_list[i]
    H -= 1

       
column_del_list=[]
for j in range(W):
    cnt_white=0
    for i in range(H):
        if a_list[i][j] == ".":
            cnt_white += 1
    
    if cnt_white == H:
        column_del_list.append(j)
        
for j in column_del_list[::-1]:
    #print("j",j)
    for i in range(H):
        del a_list[i][j]
        W -= 1


for row in a_list:
    print(*row)

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
print(A)
"""
cnt_1=0
for i in range(H):
    for j in range(W):
        if A[i][j]!='.':
            break
        elif j==W-1:
            del A[i]
            print(A[i])
            cnt_1+=1
        else:
            continue
"""
"""
cnt=cnt_1
for j in range(W):
    for i in range(H-cnt):
        if A[i][j]!='.':
            break
        elif i==H-cnt-1:
            for k in range(H-cnt):
                del A[k][j]
                cnt+=1

[print(A[i] for i in range(cnt_1))]
"""

Submission status: Wrong Answer

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

a = list(zip(*[i for i in a if "#" in i]))
print(a)
a = list(zip(*[j for j in a if "#" in j]))
print(a)

for n in range(len(a)):
    print("".join(a[n]))

Submission status: Wrong Answer

Solution code:
import math


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
a = [None]*h
print(a)
for i in range(h):
    a[i] = input()
print(a)
x = [None]*h
y = [None]*w
print(x)
print(y)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            x[i] = True
            y[j] = True
print(x)
print(y)
for i in range(h):
    if x[i] == True:
        for j in range(w):
            if y[j] == True:
                print(a[i][j], end="")
        print()

Submission status: Wrong Answer

Solution code:
import math


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
a = [None]*h
print(a)
for i in range(h):
    a[i] = str(input())
print(a)
x = [None]*h
y = [None]*w
print(x)
print(y)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            x[i] = True
            y[j] = True
print(x)
print(y)
for i in range(h):
    if x[i] == True:
        for j in range(w):
            if y[j] == True:
                print(a[i][j], end="")
        print()

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[[0 for _ in range(h)] for _ in range(w)]
ans=[]
print(a)
for i in range(h):
    b=list(input())#w nonagasa 
    if '#'  in b:
        for j in range(w):
            a[j][i]=b[j]
#for i in range(w):
    #print(a[i])
c=0
for i in range(0-c,w-c):
    if '#' not in a[i]:
        for j in range(h):
            a[i][j]=0
for i in range(h):
    for j in range(w):
        if a[j][i]!=0:
            print(a[j][i],end="")
            c+=1
    if c!=0:
        print()
    c=0

Submission status: Wrong Answer

Solution code:
import numpy as np
h, w = map(int, input().split())
f = np.array([list(input()) for _ in range(h)])

while True:
    f_shape = f.shape
    f = f[~np.all(f=='.', axis=1)]
    f = f[:, ~np.all(f=='.', axis=0)]
    if f.shape == f_shape:
        break

for x in f:
    print(*x)

Submission status: Wrong Answer

Solution code:
import numpy as np
h, w = map(int, input().split())
f = np.array([list(input()) for _ in range(h)])

f = f[~np.all(f=='.', axis=1)]
f = f[:, ~np.all(f=='.', axis=0)]

for x in f:
    print(*x)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]
a = list(zip(*[i for i in a if "#" in a]))
a = list(zip(*[i for i in a if "#" in a]))
for i in range(len(a)):
    print("".join(a[i]))

Submission status: Wrong Answer

Solution code:
import sys
H_W = list(map(int,input().split()))
H = H_W[0]
W = H_W[1]
b = [[0 for i in range(W)] for j in range(H)]
a = [[str(c) for c in l.strip()] for l in sys.stdin]

# .を0に, #を1にした新しい配列bを作る
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            b[i][j] = 1

# 列と行ごとにすべて0のものを探す
w = [0] * W
h = [0] * H
for i in range(H):
    for j in range(W):
        h[i] = h[i] + b[i][j]
        w[j] = w[j] + b[i][j]

#print(h)
#print(w)
# 全ての要素が0の列と行を削除する
i = 0
c = 0
j = 0
for i in range(H):
    if h[i] == 0:
        del a[j]
        H = H - 1
        j = j - 1
    j = j + 1
#print(a)

k = 0
for i in range(W):
    if w[i] == 0:
        for j in range(H):
            del a[j][k]
            print(a)
        W = W - 1
        k = k - 1
    k = k + 1
#print(a)
# 答え
for i in range(H):
    flag = 0
    for j in range(W):
        if flag == 0:
            ans = a[i][j]
            flag = 1
        else:
            ans = ans + a[i][j]
    print(ans)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[input() for i in range(h)]
lst=[]
for i in range(len(a)):
  flag=0
  for j in range(len(a[i])):
    if a[i][j]=="#":
      flag=1
  if flag==0:
    lst.append(i)
lst.reverse()

for j in lst:
  del a[j]
lst=[]
for i in range(len(a[0])):
  flag=0
  for j in range(len(a)):
    if a[j][i]=="#":
      flag=1
  if flag==0:
    lst.append(j)
lst.reverse()
for j in lst:
  for i in range(len(a)):
    print(j)
print(a)

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
L=[list(input()) for _ in range(H)]
for _ in range(H+W):
    ans=[]
    res=[]
    l=[]
    for s in L:
        if '#' in s:
            l.append(s)
    for z in zip(*l):
        if '#' in z:
            res.append(z)
    for z in zip(*res):
        ans.append(list(z))
    L=ans.copy()
print(L)

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
l = [list(list(input())) for i in range(h)]
W = []
for j in range(1, w):
    for k in range(h-1):
        if l[k][j] == l[k+1][j] == '.':
            continue
        else:
            break
    else:
        print(j)
        W.append(j)
W = sorted(W, reverse=True)
#print(W) #後で消す列

H = []
for m in range(h):
    if set(l[m]) == {'.'}:
        H.append(m)
H = sorted(H, reverse=True)
#print(H)

for p in range(len(W)):
    for q in range(h):
        del l[q][W[p]]
#print(l)

for r in H:
    del l[r]
#print(l)

for s in l:
    print(''.join(s))

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
l = [list(list(input())) for i in range(h)]
W = []
for j in range(w):
    for k in range(h-1):
        if l[k][j] == l[k+1][j] == '.':
            continue
        else:
            break
    else:
        if j != 0:
            W.append(j)
W = sorted(W, reverse=True)
#print(W) #後で消す列

H = []
for m in range(h):
    if set(l[m]) == {'.'}:
        H.append(m)
H = sorted(H, reverse=True)
#print(H)

for p in range(len(W)):
    for q in range(h):
        del l[q][W[p]]
#print(l)

for r in H:
    del l[r]
#print(l)

for s in l:
    print(''.join(s))

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
l = [list(list(input())) for i in range(h)]
W = []
for j in range(w):
    for k in range(h-1):
        if l[k][j] == l[k+1][j] == '.':
            continue
        else:
            break
    else:
        W.append(j)
W = sorted(W, reverse=True)
#print(W) #後で消す列

H = []
for m in range(h):
    if set(l[m]) == {'.'}:
        H.append(m)
H = sorted(H, reverse=True)
#print(H)

for p in range(len(W)):
    for q in range(h):
        del l[q][W[p]]
#print(l)

for r in H:
    del l[r]
#print(l)

for s in l:
    print(''.join(s))

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
l = [list(list(input())) for i in range(h)]
W = []
for j in range(w):
    for k in range(h-1):
        if l[k][j] == l[k+1][j] == '.':
            continue
        else:
            break
    else:
        W.append(j)
W = sorted(W, reverse=True)
#print(W) #後で消す列

H = []
for m in range(h):
    if set(l[m]) == {'.'}:
        H.append(m)
H = sorted(H, reverse=True)
#print(H)

for p in range(len(W)):
    for q in range(h):
        del l[q][W[p]]
#print(l)

for r in range(len(H)):
    del l[H[r]]
#print(l)

for s in l:
    print(''.join(s))

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
l = [list(list(input())) for i in range(h)]
W = []
for j in range(w):
    for k in range(h-1):
        if l[k][j] == l[k+1][j]:
            continue
        else:
            break
    else:
        W.append(j)
W = sorted(W, reverse=True)
#print(W) #後で消す列

H = []
for m in range(h):
    if len(set(l[m])) == 1:
        H.append(m)
H = sorted(H, reverse=True)
#print(H)

for p in range(len(W)):
    for q in range(h):
        del l[q][W[p]]
#print(l)

for r in range(len(H)):
    del l[H[r]]
#print(l)

for s in l:
    print(''.join(s))