結果
問題 | No.179 塗り分け |
ユーザー | actu3 |
提出日時 | 2015-06-21 01:02:39 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 449 ms / 3,000 ms |
コード長 | 2,600 bytes |
コンパイル時間 | 3,588 ms |
コンパイル使用メモリ | 77,848 KB |
実行使用メモリ | 56,828 KB |
最終ジャッジ日時 | 2024-07-23 14:30:57 |
合計ジャッジ時間 | 13,576 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
50,264 KB |
testcase_01 | AC | 57 ms
50,432 KB |
testcase_02 | AC | 56 ms
50,540 KB |
testcase_03 | AC | 57 ms
50,420 KB |
testcase_04 | AC | 56 ms
50,452 KB |
testcase_05 | AC | 175 ms
55,536 KB |
testcase_06 | AC | 105 ms
52,412 KB |
testcase_07 | AC | 57 ms
50,200 KB |
testcase_08 | AC | 100 ms
52,372 KB |
testcase_09 | AC | 111 ms
52,124 KB |
testcase_10 | AC | 208 ms
56,196 KB |
testcase_11 | AC | 191 ms
55,664 KB |
testcase_12 | AC | 449 ms
55,780 KB |
testcase_13 | AC | 67 ms
50,548 KB |
testcase_14 | AC | 60 ms
50,264 KB |
testcase_15 | AC | 55 ms
50,564 KB |
testcase_16 | AC | 55 ms
50,204 KB |
testcase_17 | AC | 54 ms
50,440 KB |
testcase_18 | AC | 277 ms
55,688 KB |
testcase_19 | AC | 292 ms
55,984 KB |
testcase_20 | AC | 415 ms
55,780 KB |
testcase_21 | AC | 362 ms
55,880 KB |
testcase_22 | AC | 361 ms
55,700 KB |
testcase_23 | AC | 199 ms
55,624 KB |
testcase_24 | AC | 393 ms
55,996 KB |
testcase_25 | AC | 278 ms
55,804 KB |
testcase_26 | AC | 268 ms
55,748 KB |
testcase_27 | AC | 410 ms
56,104 KB |
testcase_28 | AC | 283 ms
55,976 KB |
testcase_29 | AC | 409 ms
56,084 KB |
testcase_30 | AC | 271 ms
55,812 KB |
testcase_31 | AC | 349 ms
55,704 KB |
testcase_32 | AC | 285 ms
56,040 KB |
testcase_33 | AC | 349 ms
55,828 KB |
testcase_34 | AC | 281 ms
55,988 KB |
testcase_35 | AC | 414 ms
56,828 KB |
testcase_36 | AC | 54 ms
50,236 KB |
testcase_37 | AC | 55 ms
50,416 KB |
testcase_38 | AC | 55 ms
50,080 KB |
testcase_39 | AC | 56 ms
50,528 KB |
testcase_40 | AC | 56 ms
50,008 KB |
testcase_41 | AC | 56 ms
50,336 KB |
testcase_42 | AC | 57 ms
50,372 KB |
testcase_43 | AC | 103 ms
52,604 KB |
testcase_44 | AC | 176 ms
55,536 KB |
testcase_45 | AC | 70 ms
51,380 KB |
ソースコード
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.*; public class Yuki179 { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Solver solver = new Solver(); solver.solve(1, in, out); out.close(); } static class Solver { public void solve(int testNumber, InputReader in, PrintWriter out) { int h = in.nextInt(); int w = in.nextInt(); String[] s = new String[h]; for (int i = 0; i < h; i++) { s[i] = in.next(); } boolean none = true; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (s[i].charAt(j) == '#') none = false; } } if (none) { System.out.println("NO"); return; } for (int dh = -h; dh <= h; dh++) { for (int dw = -w; dw <= w; dw++) { if (dh == 0 && dw == 0) continue; boolean good = true; boolean[][] used = new boolean[h][w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (s[i].charAt(j) != '#' || used[i][j]) continue; //color (i,j) red int bh = i + dh; int bw = j + dw; if (bh < 0 || h <= bh) continue; if (bw < 0 || w <= bw) continue; if (s[bh].charAt(bw) != '#' || used[bh][bw]) { good = false; break; } used[i][j] = true; used[bh][bw] = true; } } if (!good) continue; //check for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (s[i].charAt(j) == '#' && !used[i][j]) { good = false; } } } if (good) { System.out.println("YES"); return; } } } System.out.println("NO"); } } 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()); } } }