結果
問題 | No.179 塗り分け |
ユーザー | actu3 |
提出日時 | 2015-06-21 00:54:28 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,390 bytes |
コンパイル時間 | 3,743 ms |
コンパイル使用メモリ | 78,224 KB |
実行使用メモリ | 56,580 KB |
最終ジャッジ日時 | 2024-04-10 12:27:58 |
合計ジャッジ時間 | 10,865 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
50,252 KB |
testcase_01 | AC | 49 ms
50,288 KB |
testcase_02 | AC | 51 ms
50,512 KB |
testcase_03 | AC | 50 ms
50,364 KB |
testcase_04 | AC | 51 ms
50,436 KB |
testcase_05 | AC | 116 ms
54,508 KB |
testcase_06 | AC | 81 ms
51,644 KB |
testcase_07 | WA | - |
testcase_08 | AC | 156 ms
55,620 KB |
testcase_09 | AC | 71 ms
51,504 KB |
testcase_10 | AC | 151 ms
56,208 KB |
testcase_11 | AC | 148 ms
56,008 KB |
testcase_12 | AC | 290 ms
56,276 KB |
testcase_13 | AC | 51 ms
50,628 KB |
testcase_14 | AC | 53 ms
50,152 KB |
testcase_15 | AC | 50 ms
50,512 KB |
testcase_16 | AC | 52 ms
50,352 KB |
testcase_17 | AC | 53 ms
50,492 KB |
testcase_18 | AC | 195 ms
56,396 KB |
testcase_19 | AC | 164 ms
55,768 KB |
testcase_20 | AC | 259 ms
56,492 KB |
testcase_21 | AC | 263 ms
56,440 KB |
testcase_22 | AC | 289 ms
56,580 KB |
testcase_23 | AC | 169 ms
55,320 KB |
testcase_24 | AC | 278 ms
55,756 KB |
testcase_25 | AC | 169 ms
55,504 KB |
testcase_26 | WA | - |
testcase_27 | AC | 189 ms
55,784 KB |
testcase_28 | WA | - |
testcase_29 | AC | 203 ms
56,448 KB |
testcase_30 | WA | - |
testcase_31 | AC | 211 ms
56,060 KB |
testcase_32 | AC | 227 ms
56,276 KB |
testcase_33 | AC | 208 ms
55,736 KB |
testcase_34 | WA | - |
testcase_35 | AC | 217 ms
56,176 KB |
testcase_36 | AC | 49 ms
50,444 KB |
testcase_37 | AC | 49 ms
50,504 KB |
testcase_38 | AC | 50 ms
50,060 KB |
testcase_39 | AC | 49 ms
50,140 KB |
testcase_40 | AC | 53 ms
50,604 KB |
testcase_41 | AC | 50 ms
50,468 KB |
testcase_42 | AC | 49 ms
50,392 KB |
testcase_43 | AC | 66 ms
51,504 KB |
testcase_44 | AC | 122 ms
54,796 KB |
testcase_45 | AC | 55 ms
50,272 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(); } for (int dh = -h+1; dh < h; dh++) { for (int dw = 0; 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()); } } }