Submission #4025580


Source Code Expand

# https://atcoder.jp/contests/abc107/tasks/abc107_b
# B - Grid Compression

N, M = gets.split(" ").map{|d|d.to_i}
A = (0...N).map{gets.strip.split("")}

ignorex = []
ignorey = []


A.size.times{|y|
	if(A[y].all?{|d|d == "."}  )
		ignorey.push(y)
	end
}

A.transpose.size.times{|x|
	if(A.transpose[x].all?{|d|d == "."}  )
		ignorex.push(x)
	end
}

out = ""
A.size.times{|y|
	A.transpose.size.times{|x|
		if(!ignorey.include?(y) && !ignorex.include?(x))
			out += "#{A[y][x]}"
		end
	}
	if(!ignorey.include?(y))
		out += "\n"
	end
}
puts out

Submission Info

Submission Time
Task B - Grid Compression
User kaeruko
Language Ruby (2.3.3)
Score 200
Code Size 574 Byte
Status AC
Exec Time 83 ms
Memory 34032 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 12
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt
Case Name Status Exec Time Memory
0_00.txt AC 7 ms 1788 KB
0_01.txt AC 7 ms 1788 KB
0_02.txt AC 8 ms 3836 KB
0_03.txt AC 7 ms 1788 KB
1_00.txt AC 7 ms 1788 KB
1_01.txt AC 61 ms 11644 KB
1_02.txt AC 83 ms 33276 KB
1_03.txt AC 83 ms 34032 KB
1_04.txt AC 59 ms 10364 KB
1_05.txt AC 59 ms 9980 KB
1_06.txt AC 61 ms 10492 KB
1_07.txt AC 60 ms 10492 KB