Submission #5573051
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; 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(in, out); out.close(); } static class Task { int H, W; char[][] A; boolean possible = true; void solve(InputReader in, PrintWriter out) { H = in.nextInt(); W = in.nextInt(); A = new char[H][W]; for (int i = 0; i < H; ++i) { A[i] = in.next().toCharArray(); } for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { if (A[i][j] == '#' && i > 0 && j < W - 1) { possible &= A[i - 1][j + 1] == '.'; } } } out.println(possible ? "Possible" : "Impossible"); } } static class InputReader { BufferedReader reader; StringTokenizer tokenizer; InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int size) { int[] arr = new int[size]; for (int i = 0; i < size; i++) { arr[i] = nextInt(); } return arr; } long nextLong() { return Long.parseLong(next()); } long[] nextLongArray(int size) { long[] arr = new long[size]; for (int i = 0; i < size; i++) { arr[i] = nextLong(); } return arr; } } }
Submission Info
Submission Time | |
---|---|
Task | A - Shik and Stone |
User | hatsujime |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 2460 Byte |
Status | AC |
Exec Time | 72 ms |
Memory | 23380 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt, example2.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, example0.txt, example1.txt, example2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 70 ms | 19412 KB |
001.txt | AC | 72 ms | 19412 KB |
002.txt | AC | 71 ms | 19284 KB |
003.txt | AC | 70 ms | 19668 KB |
004.txt | AC | 71 ms | 20948 KB |
005.txt | AC | 69 ms | 18644 KB |
006.txt | AC | 70 ms | 18900 KB |
007.txt | AC | 69 ms | 18388 KB |
008.txt | AC | 69 ms | 18644 KB |
009.txt | AC | 70 ms | 20052 KB |
010.txt | AC | 70 ms | 23380 KB |
011.txt | AC | 69 ms | 18004 KB |
012.txt | AC | 70 ms | 20436 KB |
013.txt | AC | 70 ms | 16340 KB |
014.txt | AC | 71 ms | 22740 KB |
015.txt | AC | 69 ms | 21332 KB |
016.txt | AC | 70 ms | 19412 KB |
017.txt | AC | 71 ms | 22100 KB |
018.txt | AC | 71 ms | 18388 KB |
example0.txt | AC | 71 ms | 19924 KB |
example1.txt | AC | 70 ms | 17876 KB |
example2.txt | AC | 69 ms | 19668 KB |