結果
問題 | No.179 塗り分け |
ユーザー | actu3 |
提出日時 | 2015-06-21 00:46:41 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,390 bytes |
コンパイル時間 | 3,467 ms |
コンパイル使用メモリ | 78,156 KB |
実行使用メモリ | 45,168 KB |
最終ジャッジ日時 | 2024-10-02 14:25:25 |
合計ジャッジ時間 | 11,145 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
36,956 KB |
testcase_01 | AC | 51 ms
36,728 KB |
testcase_02 | AC | 51 ms
37,212 KB |
testcase_03 | AC | 50 ms
36,948 KB |
testcase_04 | AC | 55 ms
37,228 KB |
testcase_05 | AC | 117 ms
41,632 KB |
testcase_06 | AC | 73 ms
38,456 KB |
testcase_07 | WA | - |
testcase_08 | AC | 186 ms
44,868 KB |
testcase_09 | AC | 67 ms
38,284 KB |
testcase_10 | AC | 170 ms
44,636 KB |
testcase_11 | AC | 157 ms
44,436 KB |
testcase_12 | AC | 287 ms
44,548 KB |
testcase_13 | AC | 53 ms
37,148 KB |
testcase_14 | AC | 53 ms
37,104 KB |
testcase_15 | AC | 52 ms
36,800 KB |
testcase_16 | AC | 54 ms
36,836 KB |
testcase_17 | AC | 52 ms
37,136 KB |
testcase_18 | AC | 178 ms
44,556 KB |
testcase_19 | AC | 175 ms
43,928 KB |
testcase_20 | AC | 281 ms
44,700 KB |
testcase_21 | AC | 333 ms
45,168 KB |
testcase_22 | AC | 259 ms
44,192 KB |
testcase_23 | AC | 174 ms
43,528 KB |
testcase_24 | AC | 214 ms
44,324 KB |
testcase_25 | AC | 164 ms
43,924 KB |
testcase_26 | WA | - |
testcase_27 | AC | 227 ms
44,300 KB |
testcase_28 | WA | - |
testcase_29 | AC | 212 ms
43,792 KB |
testcase_30 | WA | - |
testcase_31 | AC | 159 ms
43,928 KB |
testcase_32 | AC | 160 ms
43,840 KB |
testcase_33 | AC | 209 ms
43,936 KB |
testcase_34 | WA | - |
testcase_35 | AC | 234 ms
44,688 KB |
testcase_36 | AC | 51 ms
36,996 KB |
testcase_37 | AC | 51 ms
37,000 KB |
testcase_38 | AC | 49 ms
36,976 KB |
testcase_39 | AC | 51 ms
37,232 KB |
testcase_40 | AC | 50 ms
36,968 KB |
testcase_41 | AC | 51 ms
36,980 KB |
testcase_42 | AC | 52 ms
37,072 KB |
testcase_43 | AC | 77 ms
38,720 KB |
testcase_44 | AC | 127 ms
41,584 KB |
testcase_45 | AC | 61 ms
37,344 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()); } } }