Submission #4024517
Source Code Expand
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } static class Task { public void solve(int testNumber, InputReader in, PrintWriter out) { int h = in.nextInt(); int w = in.nextInt(); String[] a = new String[h]; for (int i = 0; i < h; i++) { a[i] = in.next(); } boolean[] row = new boolean[h]; Arrays.fill(row, false); boolean[] col = new boolean[w]; Arrays.fill(col, false); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (a[i].charAt(j) == '#') { row[i] = true; col[j] = true; } } } for (int i = 0; i < h; i++) { if (row[i]) { for (int j = 0; j < w; j++) { if (col[j]) { System.out.print(a[i].charAt(j)); } } System.out.println(); } } } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
Submission Info
Submission Time | |
---|---|
Task | B - Grid Compression |
User | tmp_jp |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 2525 Byte |
Status | AC |
Exec Time | 153 ms |
Memory | 21460 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
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 | 75 ms | 20052 KB |
0_01.txt | AC | 77 ms | 18388 KB |
0_02.txt | AC | 72 ms | 20180 KB |
0_03.txt | AC | 75 ms | 21460 KB |
1_00.txt | AC | 72 ms | 19412 KB |
1_01.txt | AC | 75 ms | 18516 KB |
1_02.txt | AC | 147 ms | 20948 KB |
1_03.txt | AC | 153 ms | 20564 KB |
1_04.txt | AC | 101 ms | 19156 KB |
1_05.txt | AC | 109 ms | 19284 KB |
1_06.txt | AC | 103 ms | 17876 KB |
1_07.txt | AC | 102 ms | 21332 KB |