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())
vax = []
hax = []
a = [str(input()) for i in range(H)]
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            if i not in vax:
                vax.append(i)
            if j not in hax:
                hax.append(j)
            
for i in vax:
    for j in hax:
        b = a[i][j]
        print(b,end="")
    print("")

Submission status: Wrong Answer

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

i = 0
while len(HW) > i:
  if "#" not in HW[i]:
    HW.pop(i)
  i += 1  
    
#print(HW)
clear_w = [0] * W
for i in range(len(HW)):
  for j in range(W):
    x = HW[i][j]
    if x == "#":
      clear_w[j] = 1
#print(clear_w)
    
for i in range(len(HW)):
  HW[i] = [HW[i][j] for j in range(W) if clear_w[j] == 1]
  
      
for i in range(len(HW)):
  for j in range(len(HW[i])):
    if j != len(HW[i]) - 1:
      print(HW[i][j], end = "")
    else:
      print(HW[i][j])

Submission status: Wrong Answer

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


deleterow = []
deleteline = []
for i in range(field.shape[0]):
    if len(set(field[i,:]))==1:
        deleterow.append(i)
for j in range(field.shape[1]):
    if len(set(field[:,j]))==1:
        deleteline.append(j)

for i, row in enumerate(field):
    if i in deleterow:
        continue
    for j, val in enumerate(row):
        if j in deleteline:
            continue
        print(val, end='')
    print('')

Submission status: Wrong Answer

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


deleterow = []
deleteline = []
for i in range(field.shape[0]):
    if len(set(field[i,:]))==1:
        deleterow.append(i)
for j in range(field.shape[1]):
    if len(set(field[:,j]))==1:
        deleteline.append(j)

for i, row in enumerate(field):
    if i in deleterow:
        continue
    for j, val in enumerate(row):
        if j in deleteline:
            continue
        print(val, end='')
    print('\n')

Submission status: Wrong Answer

Solution code:
H, W = [int(i) for i in input().split()]
maze = [list(input()) for _ in range(H)]
for i, l in enumerate(maze):
    if "#" not in l:
        del(maze[i])
maze = list(zip(*maze))
for i, l in enumerate(maze):
    if "#" not in l:
        del(maze[i])
maze = list(zip(*maze))
for l in maze:
    print(*l, sep="")

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l = [list(input()) for i in range(n)]
gyou = []
retsu = []
count = 0
for i in range(n):
    a = l[i][0]
    count = 0
    for j in range(m):
        if a == l[i][j]:
            count += 1
    if count != m:
        gyou.append(i)
for i in range(m):
    a = l[0][i]
    count = 0
    for j in range(n):
        if a == l[j][i]:
            count += 1
    if count != n:
        retsu.append(i)

for i in range(n):
    if i in gyou:
        for j in range(m):
            if j in retsu:
                if j == retsu[-1]:
                    print(l[i][j])
                else:
                    print(l[i][j],end="")

Submission status: Wrong Answer

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

for i in range(h):
    if i >= h:
        break
    if set(a[i]) == {"."}:
        del a[i]
        h -= 1

for i in range(w):
    t = []
    if i >= w:
        break
    for j in range(h):
        t.append(a[j][i])
    if set(t) == {"."}:
        for j in range(h):
            del a[j][i]
        w -= 1

for i in a:
    print("".join(i))

Submission status: Wrong Answer

Solution code:
import collections
H,W=map(int,input().split())
A=[]
AH=[]
AHW=[]
for i in range(H):
  A.append(list(map(str,input())))
for i in range(H):
  flag=True
  for j in range(W):
    if A[i][j]=='#':
      flag=False
      break
  if not(flag):
    AH.append(A[i])
wlist=[]
for i in range(len(AH)):
  for j in range(W):
    if A[i][j]=='.':
      wlist.append(i)
wc=collections.Counter(wlist)
print(wc)

Submission status: Wrong Answer

Solution code:
import numpy as np
H,W = map(int,input().split())
L = []
for i in range(H):
    L.append(list(input()))
L = np.array(L)
L = [x for x in L if "#" in x]
L = np.rot90(L)
L = [x for x in L if "#" in x]
L = np.rot90(L,3)

for i in range(len(L)):
    print(*L[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

h, w = map(int, input().split())
A = []

for _ in range(h):
    a = input()
    if '#' in a:
        A.append(a)

AA = []
count = 0
for j in range(w):
    retu = []
    for i in range(len(A)):
        retu.append(A[i][j])
    if '#' not in retu:
        continue
    else:
        AA.append(retu)

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

for aa in AA:
    print(*aa)

Submission status: Wrong Answer

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

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

    if cnt == h:
        skip.append(i)

for i in range(h):
    if len(set(a[i])) == 1:
        continue

    for j in range(w):
        if j in skip:
            continue

        print(a[i][j], end="")
    print()

Submission status: Wrong Answer

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

A = []

for _ in range(H):
  s = input()
  if len(set(s)) == 1:
    H -= 1
  else:
    for i in s:
      A.append(i)
      
if len(A) == 0:
  print("")

else:
  M = []
  
  for i in range(W):
    if A[i] == ".":
      for j in range(i + W,H * W,W):
        if A[j] == "#":
          break
      else:
        M.append(i)
        
  A = [A[i] for i in range(H * W) if not (i % W) in M]
  W = W - len(M)
  
  S = ""
  
  for i in range(H * W):
    S += A[i]
    if (i + 1) % W == 0:
      print(S)
      S = ""

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for _ in [0]*h:
    ai=list(input())
    print(ai)
    if "#" in ai:
        a.append(ai)
t=[]
for wi in zip(*a):
    if "#" in wi:
        t.append(wi)
for ans in zip(*t):
    print("".join(ans))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for _ in [0]*h:
    ai=list(input().split())
    if "#" in ai:
        a.append(ai)
t=[]
for wi in zip(*a):
    if "#" in wi:
        t.append(wi)
for ans in zip(*t):
    print(*ans)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for _ in [0]*h:
    ai=list(input())
    if "#" in ai:
        a.append(ai)
t=[]
for wi in zip(*a):
    if "#" in wi:
        t.append(wi)
for ans in zip(*t):
    print(*ans)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
a = []
for _ in range(h):
    aw = input()
    if set(aw) != {'.'}:
        a.append(aw)
ans = []
for i in zip(*a):
    if set(i) != {'.'}:
        ans.append("".join(list(i)[::-1]))
print(*ans[::-1], sep="\n")

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
    li=str(input())
    if len(set(li))!=1:
        a.append(li)
cnt=[]
b=[]
for j in range(w):
    for k in range(len(a)):
        b.append(a[k][j])
    if len(set(b))==2: 
      cnt.append(j)
    elif len(set(b))==1:
      if b[0]=="#":
        cnt.append(j)       
    b=[]            
ans=""
for m in range(len(a)):
  for l in cnt:
    ans+=a[m][l]
  print(ans)
  ans=""

Submission status: Wrong Answer

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

r = set()
c = set()

for i in range(h):
    for j in range(w):
        if p[i][j] == '#':
            r.add(i)
            c.add(j)

for i in range(h):
    for j in range(w):
        if i in r and j in c:
            print(p[i][j], end='')
    if i in r and j in c:
        print()

Submission status: Wrong Answer

Solution code:
import numpy as np

H,W=list(map(int,input().split(" ")))
A=np.full((H,W),".",np.str)

# 入力を格納
for h in range(H):
    A[h,:]=list(input())

# 各行について
for h in reversed(range(H)):
    if (A[h,:]==".").all()==True: # 全ての要素が"."の場合行を削除
        A=np.delete(A,h,axis=0)

# 各列について
for w in reversed(range(A.shape[1])):
    if (A[:,w]==".").all()==True: # 全ての要素が"."の場合列を削除
        A=np.delete(A,w,axis=1)

print(A)

Submission status: Wrong Answer

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

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

h_blank = [False]*h
w_blank = [False]*w
for i in range(h):
  blank = True
  for j in range(w):
    if a[i][j] == '#':
      blank = False
      break
  if blank:
    h_blank[i] = True

for i in range(w):
  blank = True
  for j in range(h):
    if a[j][i] == '#':
      blank = False
      break
  if blank:
    w_blank[i] = True

for i in range(h):
  for j in range(w):
    if h_blank[i] or w_blank[j]:
      continue
    print(a[i][j])

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
  h, w = MAP()
  a = [list(input()) for _ in range(h)]
  g = []
  r = []
  for i in range(h):
    for j in range(w):
      if a[i][j] == "#":
        g.append(i)
        r.append(j)
  g = set(g)
  r = set(r)
  #print(g)
  #print(r)
  for i in g:
    tmp = []
    for j in r:
      tmp.append(a[i][j])
    print(*tmp)

if  __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

h,w= [int(x) for x in stdin.readline().rstrip().split()]

li = [["" for i in range(w)]for j in range(h)]

for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i][j] = s[j]

li = np.asarray([s for s in li if s != ['.']*w]).T.tolist()
li = np.asarray([s for s in li if s != ['.']*len(li[0])]).T.tolist()

for i in range(len(li)):
    print(*li[i])

Submission status: Wrong Answer

Solution code:
import numpy as np
H,W = map(int,input().split())
x = [[i for i in input()] for _ in range(H)]
y = [list(k) for k in list(zip(*x))]

H_judge=[]
W_judge=[]

for i in range(H):
  if x[i].count("#")==W or x[i].count(".")==W:
    H_judge.append(i)

for j in range(W):
  if y[j].count("#")==H or y[j].count(".")==H:
    W_judge.append(j)

np_x = np.array(x)
np_x_del1 = np.delete(np_x,H_judge,0)
np_x_del2 = np.delete(np_x_del1,W_judge,1)

np_x_new = np_x_del2.tolist()
for k in np_x_new:
  print("".join(k))

Submission status: Wrong Answer

Solution code:
import numpy as np
H,W = map(int,input().split())
x = [[i for i in input()] for _ in range(H)]
y = [list(k) for k in list(zip(*x))]

H_judge=[]
W_judge=[]

for i in range(H):
  if x[i].count("#")==4 or x[i].count(".")==4:
    H_judge.append(i)

for j in range(W):
  if y[j].count("#")==4 or y[j].count(".")==4:
    W_judge.append(j)

np_x = np.array(x)
np_x_del1 = np.delete(np_x,H_judge,0)
np_x_del2 = np.delete(np_x_del1,W_judge,1)

np_x_new = np_x_del2.tolist()
for k in np_x_new:
  print("".join(k))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(input()))
j=0
lis=[]
while j<len(a):
    if '#' not in set(a[j]):
        a.remove(a[j])
    j+=1
for k in range(len(a)):
    for l in range(w):
        if a[k][l]=='.':
            c=0
            while c<len(a):
                if a[c][l]!='.':
                    break
                if c==len(a)-1 and l not in set(lis):
                    lis.append(l)
                c+=1
ans=''
#print(lis)
tmp=0
count=0
for o in range(len(lis)):
    tmp=lis[o]
    for s in range(len(a)):
        del a[s][tmp-count]
    count+=1    
for q in range(len(a)):
    for e in range(len(a[0])):
        ans+=a[q][e]
    print(ans)
    ans=''

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
s=[list(input())for i in range(h)]
l=[x for x in s if '#' in x]
ans=[]
for i in zip(*l):
  if '#' in i:ans.append(i)
for x in ans:
  print(''.join(x))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

mat = np.zeros((H, W))
original_mat = []

removed_line = []
removed_column = []

for i in range(H):
    row = input()
    line = []
    for j, c in enumerate(row):
        if c == "#":
            mat[i, j] = 1

    # print(mat[i,:])
    if np.sum(mat[i,:]) == 0:
        removed_line.append(i)
    else:
        original_mat.append(row)

for i in range(W):
    print(mat[:,i])
    if np.sum(mat[:,i]) == 0:
        removed_column.append(i)

print(removed_line)
print(removed_column)

for row in original_mat:
    for i, c in enumerate(row):
        if i not in removed_column:
            print(c, end="")
    print("\n", end="")

Submission status: Wrong Answer

Solution code:
H,W = list(map(int,input().split()))
ary = [["." for i in range(W)] for j in range(H)]
ans = []
tf = False
yf = False
samet = []
samey = []
flg = ""
for i in range(H):
    tmp = list(input())
    for j in range(W):
        ary[i][j] = tmp[j]
for i in range(H):
    yf = False
    for k in range(W-1):
            if ary[i][k] != ary[i][k+1]:
                yf = True
    if yf == True:
        samey.append(i)
for i in range(W):
    tf = False
    for j in range(H-1):
        if ary[j][i] != ary[j+1][i]:
            tf = True
    if tf == True:
        samet.append(i)
for i in samey:
    j = 0
    c = 0
    for j in samet:
        if c != (len(samet) - 1):
            print(ary[i][j], end="")
        elif c == (len(samet) - 1):
            print(ary[i][j])
        c += 1

Submission status: Wrong Answer

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

yoko = [False] * H
for i in range(H) :
    k = set()
    for j in range(W) :
        k.add(a[i][j])
    if len(k) == 1 :
        yoko[i] = True
        
tate = [False] * W
for i in range(W) :
    k = set()
    for j in range(H) :
        k.add(a[j][i])
    if len(k) == 1 :
        tate[i] = True
        
for i in range(H) :
    if yoko[i] : 
        continue
    s = ''
    for j in range(W) :
        if tate[j] :
            continue
        s += a[i][j]
    print(s)

Submission status: Wrong Answer

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

for i in range(H):
    h = list(input())
    matrix.append(h)
    if h == ["."] * W or h == ["#"] * W:
        continue
    hd.append(i)

for i in range(W):
    w = [list(w_[i]) for w_ in matrix]
    if w == [["."]] * H or w == [["#"]] * H:
        continue
    wd.append(i)

ansmatrix = []
row = []
for i in hd:
    for j in wd:
        row.append(matrix[i][j])
    ansmatrix.append(row)
    row = []

for ansrow in ansmatrix:
    print("".join(ansrow))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for d in c:
  print(''.join(d))

Submission status: Wrong Answer

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

cntH = 0
for i in range(H-1, 0, -1):
    flag = True
    for j in range(W):
        if a[i][j] == '#':
            flag = False
            break
    if flag:
        a.pop(i)
        cntH+=1

for j in range(W-1, 0, -1):
    flag = True
    for i in range(H-cntH):
        if a[i][j] == '#':
            flag = False
    if(flag):
        for i in range(H-cntH):
            a[i].pop(j)

for i in range(H-cntH):
    for j in range(len(a[i])):
        print(a[i][j], end='')
    print('')

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):
        print(a[i][j], end='')
    print('')
cntH = 0
for i in range(H-1, 0, -1):
    flag = True
    for j in range(W):
        if a[i][j] == '#':
            flag = False
            break
    if flag:
        a.pop(i)
        cntH+=1

for j in range(W-1, 0, -1):
    flag = True
    for i in range(H-cntH):
        if a[i][j] == '#':
            flag = False
    if(flag):
        for i in range(H-cntH):
            a[i].pop(j)

for i in range(H-cntH):
    for j in range(len(a[i])):
        print(a[i][j], end='')
    print('')

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W=map(int, input().split())
matrix=np.zeros((H, W))

for i in range(H):
  s=input()
  for j in range(W):
    if s[j]=='#':
      matrix[i, j]=1
      
for i in range(H):
  if np.sum(matrix[i, :]==0)==W:
    matrix[i, :]=-1
    
for i in range(W):
  if np.sum(matrix[:, i]<=0)==H:
    matrix[:, i]=-1
    
ans=[]
for i in range(H):
  temp=''
  if np.sum(matrix[i, :]==-1)==W:
    pass
  else:
    for j in range(W):
      if matrix[i, j]==0:
        temp=temp+'.'
      elif matrix[i, j]==1:
        temp=temp+'#'
      else:
        pass
    ans.append(temp)
    
for i in range(len(temp)):
  print(ans[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W=map(int, input().split())
matrix=np.zeros((H, W))

for i in range(H):
  s=input()
  for j in range(W):
    if s[j]=='#':
      matrix[i, j]=1
      
for i in range(H):
  if np.sum(matrix[i, :]==0)==W:
    matrix[i, :]=-1
    
for i in range(W):
  if np.sum(matrix[:, i]==0)==H:
    matrix[:, i]=-1
    
i=0
for i in range(H):
  if np.sum(matrix[i, :]==-1)==W:
    pass
  else:
    for j in range(W):
      if matrix[i, j]==0:
        print('.', end='')
      elif matrix[i, j]==1:
        print('#', end='')
      else:
        pass
    print('\n', end='')

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
a = [list(input()) for _ in range(H)]
for i in a:
    if set(i) == {"."}:
        a.remove(i)
aa = [[] for _ in range(W)]
for i in range(len(a)):
    for l in range(W):
        aa[l].append(a[i][l])
for i in aa:
    if set(i) == {"."}:
        aa.remove(i)
b = [[] for _ in range(len(aa[0]))]
for i in range(len(aa)):
    for l in range(len(aa[0])):
        b[l].append(aa[i][l])
for i in b:
    print("".join(i))

Submission status: Wrong Answer

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

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

i = 0
while i < H:
    for j in range(W):
        if a[i][j] != '.':
            break
    else:
        a.pop(i)
        H -= 1
    i += 1

i = 0
while i < W:
    for j in range(H):
        if a[j][i] != '.':
            break
    else:
        for k in range(H):
            a[k].pop(i)
        W -= 1
    i += 1

for i in range(H):
    for j in range(W):
        print(a[i][j], end='')
    print()

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
a = [list(x for x in input()) for _ in range(h)]
b = []
c = []
for i in range(h):
  if '#' in a[i]:
    continue
  else:
    b.append(i)

for j in range(w):
  for k in range(h):
    if '#' == a[k][j]:
      break
    elif k == h-1:
      c.append(j)

for m in range(h):
  if m in b:
    continue
  for n in range(w):
    if n in c:
      continue
    else:
      print(a[m][n], end='')
    if w>1 and n == w-1:
      print()

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
a = [list(x for x in input()) for _ in range(h)]
b = []
c = []
for i in range(h):
  if '#' in a[i]:
    continue
  else:
    b.append(i)

for j in range(w):
  for k in range(h):
    if '#' == a[k][j]:
      break
    elif k == h-1:
      c.append(j)

for m in range(h):
  if m in b:
    continue
  for n in range(w):
    if n in c:
      continue
    else:
      print(a[m][n], end='')
    if n == w-1:
      print()

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
lst = []
for i in range(H):
    lst.append(list(input()))
for i in range(H-1, -1, -1):
    if '#' not in lst[i]:
        del lst[i]
for j in range(W-1, -1, -1):
    cnt = 0
    for i in range(len(lst)):
        if lst[i][j] == '#':
            cnt += 1
    if cnt == 0:
        for i in range(len(lst)):
            del lst[i][j]
for i in lst:
    print(*i)

Submission status: Wrong Answer

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

box_t=[[] for _ in range(len(box_y))]
for i in range(w):
    if any(["#"==box_y[j][i] for j in range(len(box_y))]):
        for j in range(len(box_y)):
            box_t[j].append(box_y[j][i])

for i in box_t:
    print(*i)

Submission status: Wrong Answer

Solution code:
H,W = map(int, input().split())
A = [input() for h in range(H)]
A = [list(a) for a in A if '#' in a]
print(A)
w = 0
while w < W:
    for a in A:
        if a[w]=='#':
            break
    else:
        for a in A:
            a.pop(w)
        W -= 1
        w -= 1
    w += 1
for a in A:
    print(''.join(a))

Submission status: Wrong Answer

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

x=[False]*w
y=[False]*h

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


for i in range(h):
    li=[]
    for j in range(w):
        if x[j]==True and y[i]==True:
            li+=a[i][j]
    if li!=[]:
        print(*li)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
matrix = []
hp = []
wp = list(range(W))

for i in range(H):
    h = list(input())
    if h == ["."]*W or h == ["#"]*W:
        hp.append(i)
    matrix.append(h)

for j in range(W):
    for k in range(H-1):
        if matrix[k][j] != matrix[k + 1][j]:
            wp.remove(j)
            break

hp.reverse()
wp.reverse()

for hp_ in hp:
    matrix.pop(hp_)
for wp_ in wp:
    for l in range(H-len(hp)):
        matrix[l].pop(wp_)

for m in matrix:
    print("".join(m))

Submission status: Wrong Answer

Solution code:
import numpy as np

h,w=map(int,input().split())
zentai=[list(input()) for i in range(h)]

for z in zentai[:]:
  if "#" not in z:
    zentai.remove(z)

tr=np.array(zentai)
tr=tr.T
tr=tr.tolist()

for z in tr[:]:
  if "#" not in z:
    tr.remove(z)

tr=np.array(tr)
tr=tr.T
print(tr)

Submission status: Wrong Answer

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

for i in range(W):
    cnt=0
    for j in range(1,H):
        if a[0][i]==a[j][i]:
            cnt+=1
            if cnt==H-1:
                rmidx.append(i)
        else:
            break


for i in range(H):
    for j in reversed(rmidx):
        a[i].pop(j)

rmidx=[]

for i in range(H):
    if a[i].count("#")==0:
        rmidx.append(i)

for i in range(H):
    if not i in rmidx:
        print("".join(a[i]))

Submission status: Wrong Answer

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

for i in range(W):
    cnt=0
    for j in range(1,H):
        if a[0][i]==a[j][i]:
            cnt+=1
            if cnt==H-1:
                rmidx.append(i)
        else:
            break


for i in range(H):
    for j in reversed(rmidx):
        a[i].pop(j)

rmidx=[]

for i in range(H):
    if a[i].count("#")==0:
        rmidx.append(i)

for i in range(H):
    if rmidx.count(i)==0:
        print("".join(a[i]))

Submission status: Wrong Answer

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

for i in range(W):
    cnt=0
    for j in range(1,H):
        if a[0][i]==a[j][i]:
            cnt+=1
    if cnt==H-1:
        rmidx.append(i)

for i in range(H):
    for j in reversed(rmidx):
        a[i].pop(j)

rmidx=[]

for i in range(H):
    if a[i].count("#")==0:
        rmidx.append(i)

for i in range(H):
    if not rmidx.count(i)!=0:
        print("".join(a[i]))

Submission status: Wrong Answer

Solution code:
from collections import Counter

def trace(matrix):
    tr=[]
    for i in range(len(matrix)):
        tr_row = []
        for vector in matrix:
            tr_row.append(vector[i])
        tr.append(tr_row)
    return tr

a=[]
a2=[]
ans=[]
h, w = map(int, input().split())
for i in range(h):
    tmpList=[]
    tmp = input()
    for j in range(len(tmp)):
        tmpList.append(tmp[j])
    a.append(tmpList)

for i in range(h):
    c = Counter(a[i])
    if len(c) != 1 and c.values() != ".":
        a2.append(a[i])
print(a2)

tr = trace(a2)

print("転置行列")
print(tr)

for i in range(len(tr)):
    c = Counter(tr[i])
    if len(c) != 1 and c.values() != ".":
        ans.append(tr[i])
ans = trace(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
l = [int(i) for i in input().split()]
print(l[0]-l[1]+1)

Submission status: Wrong Answer

Solution code:
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

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

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

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    H, W = list(map(int, sys.stdin.readline().split()))
    L = [list(list(sys.stdin.readline().rstrip())) for i in range(H)]

    L = list(filter(lambda a: any(x == "#" for x in a), L))
    L = list(filter(lambda a : any(x == "#" for x in a), zip(*L)))
    for l in L:
        print("".join(l))

Submission status: Wrong Answer

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

H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(list(map(str, input().split())))
# まずは行を取り除く
new_a = []
for i in range(H):
    if a[i][0].count('#') != 0:
        new_a.append(a[i])

# 列を取り除く
del_k = []
for k in range(W):
    for i in range(len(new_a)):
        if new_a[i][0][k] == '#':
            break
        if i == len(new_a)-1:
            del_k.append(k)

for k in del_k:
    for i in range(len(new_a)):
        new_a[i][0] = new_a[i][0][0:k] + new_a[i][0][k+1:len(new_a[i][0])]

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

Submission status: Wrong Answer

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

for y in range(h):
    a = input()
    grid.append(a)
    remove = True
    for x in range(w):
        if a[x] == "#":
            remove = False
            if x not in stay_x:
                stay_x.append(x)        
    if remove != True:
        stay_y.append(y)
for y in stay_y:
    out = ""
    for x in stay_x:
        out += grid[y][x]
    print(out)

Submission status: Wrong Answer

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

m = []

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


#行に着目
dl = []

for i in range(h):
    if all(j =='_' for j in m[i]):
        dl.append(int(i))

if dl:
    for i in range(len(dl)):
        del m[dl[len(dl)-i-1]]


#転置して同様
m = list(zip(*m)) 
if m:
    dl = []
    for i in range(w):
        if all(j =='_' for j in m[i]):
            dl.append(int(i))

    if dl:
        for i in range(len(dl)):
            del m[dl[len(dl)-i-1]]
            


#転置して元に戻す
m = list(zip(*m))


#出力
for i in range(len(m)):
    m[i] = ''.join(m[i])
    print(m[i])

Submission status: Wrong Answer

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

m = []

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


#行に着目
dl = []

for i in range(h):
    if all(j =='_' for j in m[i]):
        dl.append(int(i))

for i in dl:
    del m[i]


#転置して同様
m = list(zip(*m)) 

dl = []
for i in range(w):
    if all(j =='_' for j in m[i]):
        dl.append(int(i))

for i in dl:
    del m[i]


#転置して元に戻す
m = list(zip(*m))


#出力
for i in range(len(m)):
    m[i] = ''.join(m[i])
    print(m[i])

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
li = []
for i in range(h):
    a = list(input())
    '''
    if all([a[i] == "." for i in range(w)]):
        continue
    else:
        li.append(a)
    '''
    if "#" in a:
      li.append(a)
print(li)
for j in range(w):
    #if all([li[k][j] == "." for k in range(len(li))]):
    if all(li[k][j] == "." for k in range(len(li))):
        for k in range(len(li)):
            #li[k][j] == ""
            li[k][j] = ""
for m in range(len(li)):
    print("".join(li[m]))