結果
問題 | No.179 塗り分け |
ユーザー | actu3 |
提出日時 | 2015-06-21 00:46:41 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,390 bytes |
コンパイル時間 | 2,905 ms |
コンパイル使用メモリ | 78,012 KB |
実行使用メモリ | 58,500 KB |
最終ジャッジ日時 | 2024-04-10 12:25:43 |
合計ジャッジ時間 | 9,518 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
50,228 KB |
testcase_01 | AC | 45 ms
50,436 KB |
testcase_02 | AC | 46 ms
50,532 KB |
testcase_03 | AC | 46 ms
50,144 KB |
testcase_04 | AC | 47 ms
50,192 KB |
testcase_05 | AC | 107 ms
54,604 KB |
testcase_06 | AC | 77 ms
51,544 KB |
testcase_07 | WA | - |
testcase_08 | AC | 195 ms
58,500 KB |
testcase_09 | AC | 68 ms
51,576 KB |
testcase_10 | AC | 173 ms
56,684 KB |
testcase_11 | AC | 139 ms
56,104 KB |
testcase_12 | AC | 280 ms
56,008 KB |
testcase_13 | AC | 46 ms
50,372 KB |
testcase_14 | AC | 46 ms
50,180 KB |
testcase_15 | AC | 44 ms
50,396 KB |
testcase_16 | AC | 44 ms
50,388 KB |
testcase_17 | AC | 46 ms
50,192 KB |
testcase_18 | AC | 181 ms
56,340 KB |
testcase_19 | AC | 200 ms
56,296 KB |
testcase_20 | AC | 222 ms
56,484 KB |
testcase_21 | AC | 268 ms
55,876 KB |
testcase_22 | AC | 192 ms
55,672 KB |
testcase_23 | AC | 141 ms
55,596 KB |
testcase_24 | AC | 228 ms
55,752 KB |
testcase_25 | AC | 163 ms
55,552 KB |
testcase_26 | WA | - |
testcase_27 | AC | 181 ms
56,436 KB |
testcase_28 | WA | - |
testcase_29 | AC | 211 ms
55,804 KB |
testcase_30 | WA | - |
testcase_31 | AC | 234 ms
56,312 KB |
testcase_32 | AC | 183 ms
55,640 KB |
testcase_33 | AC | 182 ms
55,632 KB |
testcase_34 | WA | - |
testcase_35 | AC | 174 ms
55,836 KB |
testcase_36 | AC | 45 ms
50,564 KB |
testcase_37 | AC | 45 ms
50,552 KB |
testcase_38 | AC | 44 ms
50,044 KB |
testcase_39 | AC | 44 ms
50,428 KB |
testcase_40 | AC | 45 ms
50,120 KB |
testcase_41 | AC | 45 ms
50,460 KB |
testcase_42 | AC | 44 ms
50,396 KB |
testcase_43 | AC | 61 ms
51,432 KB |
testcase_44 | AC | 107 ms
54,808 KB |
testcase_45 | AC | 50 ms
50,564 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()); } } }