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 = [list(input()) for _ in range(h)]

row = [False] * h
col = [False] * w

for i in range(h):
    for j in range(w):
        if A[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(A[i][j], end = '')

Submission status: Wrong Answer

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

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

ans = []
for j in range(W):
    for i in range(len(B)):
        if "#" ==  B[i][j]:
            ans.append(j)
            break

for i in range(len(B)):
    for j in range(len(ans)):
        print(B[i][j], end="")
    print()

Submission status: Wrong Answer

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

h_set = set()
w_set = set()
B = [input() for i in range(H)]
for i in range(H):
  for j in range(W):
    if B[i][j] == '#':
      w_set.add(j)
      h_set.add(i)

for i in range(H):
  if i in h_set:
    for j in range(W):
      t = ""
      if j in w_set:
        t += B[i][j]
    print(t)

Submission status: Wrong Answer

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

h_set = set()
w_set = set()
for i in range(H):
  r = input()
  for j in range(W):
    if r[j] == '#':
      w_set.add(j)
      h_set.add(i)
print( len(h_set) * len(w_set) )

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
G=[list(input()) for i in range(H)]
allwhite=['.']*W
for h in G:
    if h==allwhite:
        G.remove(h)
ans=["" for i in range(len(G))]
for j in range(W):
    p=False
    for i in range(len(G)):
        if G[i][j]=='#':
            p=True
            break
    if p:
        for i in range(len(G)):
            ans[i]+=G[i][j]
print(*ans,sep='\n')

Submission status: Wrong Answer

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

h,w = MI()
a = LS(h)

# pprint(a)

rc = []
rr = []

for i in range(h):
    r = a[i]
    if r == ['.']*len(a[0]):
        rr.append(i)
# print(rr)

na = []
for i in range(h):
    if i not in rr:
        na.append(a[i])
# pprint(na)

for i in range(w):
    c = mycol(na,i)
    if c == ['.']*len(na):
        rc.append(i)
# print(rc)

ans = []
for i in range(len(na)):
    row = na[i]
    new_row = []
    for j in range(len(na[0])):
        if j not in rc:
            new_row.append(row[j])
    ans.append(new_row)
pprint(ans)

for i in range(len(ans)):
    myoutput(ans[i],space=False)

Submission status: Wrong Answer

Solution code:
s = input().split()

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

for i in range(h):
    check = False
    v = input()
    x = list(v)
    for j in range(w):
        if x[j] == '#':
            check = True
            break
    if check:
        print(v)

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="")
        print

Submission status: Wrong Answer

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

for i, j in enumerate(a):
    if set(j) == set("."):
        a.pop(i)
a_t = [list(x) for x in zip(*a)]
for i, j in enumerate(a_t):
    if set(j) == set("."):
        a_t.pop(i)

[print(*x,sep="") for x in zip(*a_t)]

Submission status: Wrong Answer

Solution code:
def elim(lst):
    lst_after = []
    H1 = len(lst)
    for i in range(H1):
        gset = list(set(lst[i]))
        if gset[0] != '.':
            lst_after.append(lst[i])
    return lst_after

def trans(lst):
    return list(zip(*lst))


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

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

grid_after = elim(grid)
gridT = trans(grid_after)
grid_after2 = elim(gridT)
gridT2 = trans(grid_after2)

for i in gridT2:
    print(*i,sep='')

Submission status: Wrong Answer

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

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

def elim(grid):
    grid_after = []
    H1 = len(grid)
    for i in range(H1):
        gset = list(set(grid[i]))
        if gset[0] != '.':
            grid_after.append(grid[i])
    return grid_after

def trans(lst):
    return list(zip(*lst))
    
grid_after = elim(grid)
#print(grid_after)
gridT = trans(grid_after)
#print(gridT)
grid_after2 = elim(gridT)
gridT2 = trans(grid_after2)


for i in gridT2:
    print(*i,sep='')

Submission status: Wrong Answer

Solution code:
import sys
H,W = map(int,input().split())
array_list = []
for I in range(H):
    array_list.append(list(map(str,input())))

if not ( 1 <= H <= 100 and 1 <= W <= 100 ):
    sys.exit()

# print(array_list)

Horizon_list = []
Vertical_list = []
# Horizon check
for J in range(len(array_list)):
    if array_list[J].count('.') == W:
        Horizon_list.append(J)
# Vertical check
list_check = [list(x) for x in zip(*array_list)]
for K in range(len(list_check)):
    if list_check[K].count('.') == H:
        Vertical_list.append(K)
print(Horizon_list)
print(Vertical_list)
for L in range(H):
    for M in range(W):
        if (L not in Horizon_list ) and (M not in Vertical_list):
            print(array_list[L][M],end='')
    print('\n')

Submission status: Wrong Answer

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

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

remove_w = []
for j in range(w):
    if len(set([g[j] for g in G])) == 1:
        remove_w.append(j)

for i in range(h):
    if i not in remove_h:
        S = ""
        for j in range(w):
            if j not in remove_w:
                S += G[i][j]
        print(S)

Submission status: Wrong Answer

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

row=[]
col=[]
#行探索
for i in range(h):
    flg=0
    for j in range(w):
        if grid[i][j]=='#':
            flg=1

    if flg==0:
        row.append(i)

#列探索
for j in range(w):
    flg=0
    for i in range(h):
        if grid[i][j]=='#':
            flg=1

    if flg==0:
        col.append(j)

ans=[]
for i in range(h):
    arr=[]
    for j in range(w):
        if i in row or j in col:
            continue
        else:
            arr.append(grid[i][j])
    if len(arr)!=0:
        ans.append(arr)

for k in ans:
    print(*k)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
a = []
for i in range(H):
    b = input()
    count = b.count('.')
    if count == 0 or count == W:
        continue
    else:
        a += [list(map(str, b))]

num = len(a)
val = []
for i in range(W):
    for j in range(num):
        if a[j][i] == '.':
            if j == num-1:
                val.append(i)
            else:
                continue
        else:
            break
for i in reversed(val):
    for j in range(num):
        del a[j][i]
for i in range(len(a)):
    print(''.join(a[i]))

Submission status: Wrong Answer

Solution code:
from functools import reduce
from decimal import *
from operator import mul

def main():
    h, w = input_list()
    masu = []
    for _ in range(h):
        line = list(input())
        if len(set(line)) == 1:
            continue
        masu.append(line)
    row = len(masu)
    white = {}
    for m in masu:
        for i, v in enumerate(m):
            if v == '.':
                if i in white:
                    white[i] += 1
                else:
                    white[i] = 1
    for m in masu:
        r = ''
        for i, v in enumerate(m):
            if i in white and white[i] == row:
                continue
            r += v
        print(r)

def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import numpy as np
print(np.array([i for i in np.array(a).T if "#" in i]).T)
for i in np.array([i for i in np.array(a).T if "#" in i]).T.tolist():
    print("".join(i))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def kk(al):
	for i in range(len(al)-1, -1, -1):
		if list(al[i]) == ['.']*len(al[i]):
			al = np.delete(al, i, 0)
	return al

def main():
	#a = int(input())
	h, w = tin()
	#s = input()
	al=[]
	for _ in range(h):
		s=list(input())
		al.append(s)
	al = np.array(al)
	al = kk(al)
	al = kk(al.T)
	al=al.T
	for v in al:
		print(*v)
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

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

a = np.array(a).reshape(h, w)
a = [i for i in a if "#" in i]

a = np.array(a).T
a = [i for i in a if "#" in i]

a = np.array(a).T
for i in a:
    print(*i)

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):
    a = [j for j in a if "#" in j]
    a = list(map(list, (zip(*a))))
for i in a:
    print("".join(i))

Submission status: Wrong Answer

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

a = [list(input()) for i in range(h)]

row = [False]*h
col = [False]*w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        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())
M=[list(input()) for i in range(H)]
for i in range(H):
    if not'#'in M[i]:
        s=[]
        for x in range(W):
            t=[M[y][x] for y in range(H)]
            if not'#'in t: s.append(M[i][x])
        print(''.join(s))

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
M=[list(input()) for i in range(H)]
for i in range(H):
    if '.'in M[i] and '#'in M[i]:
        s=[]
        for x in range(W):
            t=[M[y][x] for y in range(H)]
            if '.'in t and '#'in t: s.append(M[i][x])
        print(''.join(s))

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

h,w=l()
A=[list(input()) for i in range(h)]
Aprev=[]
while(Aprev!=A):
    # for x in A:
    #     print("".join(x))
    # print()
    Aprev=A[::]
    present=0
    for i in range(len(A)):
        if(A[i]==["."]*len(A[0])):
            present=1
            break
    if(present):
        del(A[i])
    present=0
    for j in range(len(A[0])):
        if([A[i][j] for i in range(len(A))]==["."]*len(A)):
            present=1
            break
    if(present):
        for i in range(len(A)):
            del(A[i][j])
for x in A:
    print("".join(x))

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

h,w=l()
A=[list(input()) for i in range(h)]
Aprev=[]
while(Aprev!=A):
    Aprev=A[::]
    present=0
    for i in range(len(A)):
        if(A[i]==["."]*len(A[0])):
            present=1
            break
    if(present):
        del(A[i])
        continue
    for j in range(len(A[0])):
        if([A[i][j] for i in range(len(A))]==["."]*len(A)):
            present=1
            break
    if(present):
        for i in range(len(A)):
            del(A[i][j])
    else:
        break
for x in A:
    print("".join(x))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
  temp=list(map(str,input()))
  a.append(temp)
temph=[]
tempw=[]
for i in range(h):
  for j in range(w-1):
    if a[i][j]!=".":
      break
  else:
    temph.append(i)
for i in range(w):
  for j in range(h-1):
    if a[j][i]!=".":
      break
  else:
    tempw.append(i)
import numpy as np
tempnp=np.array(a)
for i in range(len(temph)):
  tempnp=np.delete(tempnp, temph[i]-i, 0)
for i in range(len(tempw)):
  tempnp=np.delete(tempnp, tempw[i]-i, 1)
for i in range(h-len(temph)):
  print("".join(tempnp[i]))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
  temp=list(map(str,input()))
  a.append(temp)
temph=[]
tempw=[]
for i in range(h):
  for j in range(w-1):
    if a[i][j]!=a[i][j+1]:
      break
  else:
    temph.append(i)
for i in range(w):
  for j in range(h-1):
    if a[j][i]!=a[j+1][i]:
      break
  else:
    tempw.append(i)
import numpy as np
tempnp=np.array(a)
for i in range(len(temph)):
  tempnp=np.delete(tempnp, temph[i]-i, 0)
for i in range(len(tempw)):
  tempnp=np.delete(tempnp, tempw[i]-i, 1)
for i in range(h-len(temph)):
  print("".join(tempnp[i]))

Submission status: Wrong Answer

Solution code:
h,w = map(int,input().split())
mat = []
for i in range(h):
  g = list(input())
  if g.count(".") != w:
    mat.append(g)


for i in range(w-1, -1, -1):
  count = 0
  for j in range(len(mat)):
    if mat[j][i] == ".":
      count += 1
  if count == len(mat):
    for j in range(len(mat)):
      mat[j].pop(i)

for h in range(len(mat)):
  print(" ".join(mat[h]))

Submission status: Wrong Answer

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

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

for i in range(h):
    a[i] = list(a[i])

del_side = []
del_vertical = []

for i in range(h):
    if a[i].count('.') == w:
        del_side.append(i)

for i in range(w):
    dot_count = 0
    for j in range(h):
        if a[j][i] == '.':
            dot_count += 1
    if dot_count == h:
        del_vertical.append(i)

ans_list = []

for i in range(h):
    for j in range(w):
        if i not in del_side and j not in del_vertical:
            ans_list.append(a[i][j])
            
count = -1

for i in range(len(ans_list)):
    count += 1
    if count != 0 and count % (h-len(del_side)) == 0:
        print('\n', end="")
    print(ans_list[i], end="")

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(input())
H=[]
W=[]
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            H.append(i)
            W.append(j)
for j in H:
    ans=[]
    for i in W:
        ans.append(a[j][i])
print("".join(ans))

Submission status: Wrong Answer

Solution code:
print("HWWW")

Submission status: Wrong Answer

Solution code:
import numpy as np

h, w = map(int,input().split())
grid = np.array([list(input()) for _ in range(h)], dtype="U1") # ここ最大の学びだ

row = []
col = []

for i in range(h):
    if (grid[i] != ".").any():
        row.append(i)

trans_grid = np.transpose(grid)

for i in range(w):
    if (trans_grid != ".").any():
        col.append(i)

G = grid[row][:,col] # ここも学び。colに指定されているとこだけだす　https://qiita.com/supersaiakujin/items/d63c73bb7b5aac43898a

for g in G:
    print("".join(g))

Submission status: Wrong Answer

Solution code:
import numpy as np

H,W = map(int,input().split())
MAP = []
for _ in range(H):
    tmp = tuple(input())
    MAP.append(tmp)

MAP = np.array(MAP)
L = []
for i in range(H):
    if all(MAP[i,:] == '.'):
        L.append(i)

MAP = np.delete(MAP,L,0)

L = []
for i in range(W):
    if all(MAP[:,i] == '.'):
        L.append(i)

MAP = np.delete(MAP,L,1)
for m in MAP:
    print(*m)

Submission status: Wrong Answer

Solution code:
import sys

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

def solve(H, W):
    for i, a in enumerate(A):
        if all([x == "." for x in a]):
            A.pop(i)

    s = []
    for j in range(W):
        for i in range(len(A)):
            if A[i][j] != ".":
                break
        else:
            s.append(j)
    s.sort(reverse=True)
    for a in A:
        for i in s:
            a.pop(i)

solve(H, W)
solve(len(A), len(A[0]))

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

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w = map(int,input().split())
graph = [['.' for j in range(w)]for i in range(h)]


for i in range(h):
    tmp = input()
    for j in range(len(tmp)):
        graph[i][j] = tmp[j]
graph = np.array(graph)

flag = True
while flag:
    flag = False
    for i in range(graph.shape[1]):
        if( graph[:,i] == ['.']*graph.shape[0]).all():
            flag = True
            if i == 0:
                graph = graph[: , 1:]
                break
                
            if i == graph.shape[1] -1:
                graph = graph[:,:i]
                break
                
            else:
                graph = np.concatenate([graph[:,:i],graph[:,i+1:] ], 1)
                break
                
    for i in range(graph.shape[0]-1):
        if (graph[i,:] == ['.']*graph.shape[1]).all():
            flag = True
            if i == 0:
                graph = graph[1: , :]
                break
                
            if i == graph.shape[0] -1:
                graph = graph[:i,:]
                break
                
            else:
                graph = np.concatenate([graph[:i , :],graph[i+1: , :] ], 0)
                break
                
for i in graph:
    print(*i, sep="")

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w = map(int,input().split())
graph = [['.' for j in range(w)]for i in range(h)]


for i in range(h):
    tmp = input()
    for j in range(len(tmp)):
        graph[i][j] = tmp[j]
graph = np.array(graph)

flag = True
while flag:
    flag = False
    for i in range(graph.shape[1]-1):
        if( graph[:,i] == ['.']*graph.shape[0]).all():
            flag = True
            if i == 0:
                graph = graph[: , 1:]
                break
                
            if i == graph.shape[1] -1:
                graph = graph[:,:i-1]
                break
                
            else:
                graph = np.concatenate([graph[:,:i],graph[:,i+1:] ], 1)
                break
                
    for i in range(graph.shape[0]-1):
        if (graph[i,:] == ['.']*graph.shape[1]).all():
            flag = True
            if i == 0:
                graph = graph[1: , :]
                break
                
            if i == graph.shape[0] -1:
                graph = graph[:i-1,:]
                break
                
            else:
                graph = np.concatenate([graph[:i , :],graph[i+1: , :] ], 0)
                break
                
for i in graph:
    print(*i, sep="")

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w = map(int,input().split())
graph = [['.' for j in range(w)]for i in range(h)]


for i in range(h):
    tmp = input()
    for j in range(len(tmp)):
        graph[i][j] = tmp[j]
graph = np.array(graph)

flag = True
while flag:
    flag = False
    for i in range(graph.shape[1]-1):
        if( graph[:,i] == ['.']*graph.shape[0]).all():
            flag = True
            if i == 0:
                graph = graph[: , 1:]
                break
                
            if i == graph.shape[1] -1:
                graph = graph[:,:i-1]
                break
                
            else:
                graph = np.concatenate([graph[:,:i],graph[:,i+1:] ], 1)
                break
                
    for i in range(graph.shape[0]-1):
        if (graph[i,:] == ['.']*graph.shape[1]).all():
            flag = True
            if i == 0:
                graph = graph[1: , :]
                break
                
            if i == graph.shape[0] -1:
                graph = graph[:i-1,:]
                break
                
            else:
                graph = np.concatenate([graph[:i , :],graph[i+1: , :] ], 0)
                break
                
for i in graph:
    print(*i)

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w = map(int,input().split())
graph = [['.' for j in range(w)]for i in range(h)]


for i in range(h):
    tmp = input()
    for j in range(len(tmp)):
        graph[i][j] = tmp[j]
graph = np.array(graph)

flag = True
while flag:
    flag = False
    for i in range(graph.shape[1]-1):
        if( graph[:,i] == ['.']*graph.shape[0]).all():
            flag = True
            if i == 0:
                graph = graph[: , 1:]
                break
                
            if i == graph.shape[1] -1:
                graph = graph[:,:i-1]
                break
                
            else:
                graph = np.concatenate([graph[:,:i],graph[:,i+1:] ], 1)
                break
                
    for i in range(graph.shape[0]-1):
        if (graph[i,:] == ['.']*graph.shape[1]).all():
            flag = True
            if i == 0:
                graph = graph[1: , :]
                break
                
            if i == graph.shape[0] -1:
                graph = graph[:i-1,:]
                break
                
            else:
                print(i)
                graph = np.concatenate([graph[:i , :],graph[i+1: , :] ], 0)
                break
                
for i in graph:
    print(*i)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d = defaultdict(int)
H, W = map(int, input().split())
L = []
for i in range(H):
    L.append(input())
cl = L[:]

al = []
for i in cl:
    if ('#' in i):
        al.append(i)
# print(al)

if (len(al) == 0):
    print()
    exit()

for i in range(W):
    d[i] = True

for i, v in enumerate(al):
    for k, j in enumerate(v):
        if (j == '.'):
            continue
        else:
            d[k] = False
for i, v in d.items():
    if (v):
        for j, k in enumerate(al):
            if (i == 0):
                al[j] = ' ' + k[1:]
            elif ((i == len(al) - 1) and (len(al) != 1)):
                al[j] = k[:i - 1] + ' '
            else:
                al[j] = k[:i] + ' ' + k[i + 1:]

for i in al:
    print(i.replace(' ', ''))

Submission status: Wrong Answer

Solution code:
h, w = [int(x) for x in input().split()]

temp_list = []
l = w
r = -1
for _ in range(h):
    a = input()
    temp_l = a.find("#")
    if temp_l == -1:
        continue
    l = min(temp_l, l)
    r = max(a.rfind("#"), r)
    temp_list.append(a)

for temp in temp_list:
    print(temp[l:r+1])

Submission status: Wrong Answer

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

f = []

for i in range(h):
    f.append(list(input()))
    
for i in f:
    if i == ["."]*len(i):
        f.remove(i)
        
f2 = []

for i in range(w):
    s = []
    
    for k in f:
        s.append(k[i])
        
    f2.append(s)
    
for i in f2:
    if i == ["."]*len(i):
        f2.remove(i)
        
for i in f2:
    for s in range(len(i)-1):
        print(i[s],end = "")
    
    print(i[-1])

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
A=[list(input())for i in range(H)]
ww=set()
hh=set()
for h in range(H):
  for w in range(W):
    if A[h][w]=='#':
      ww.add(w)
      hh.add(h)
print(ww,hh)
ww=sorted(list(ww))
for h in sorted(list(hh)):
  _=''
  for w in ww:
    _+=A[h][w]
  print(_)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
X = []
res = []
F = [True] * W

for i in range(H):
  x = list(input())
   
  if x.count("#") != 0:
    X.append(x)

  for j in range(W):
    if x[j] == "#":
      F[j] = False
      break

for k in range(len(X)):
  r = ""
  for l in range(W):
    if not F[l]:
      r += (X[k][l])
  print(r)

Submission status: Wrong Answer

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

for i in range(H):
  line = input()
  if line != '.' * W:
    G.append(line)

H = len(G)
ans = []

for i in range(W):
  flg = False
  tmp = ''
  for j in range(H):
    if G[j][i] == '.':
      flg = False
    else:
      flg = True
    tmp += G[j][i]
  if flg == True:
    ans.append(tmp)

print(ans)

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]
if "#" not in b:
    B.append(w-1)
B.pop(0)
o=0
print(B)
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]
if "#" not in b:
    B.append(w-1)
    print(b)
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))