結果
問題 | No.179 塗り分け |
ユーザー | actu3 |
提出日時 | 2015-06-21 00:54:28 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,390 bytes |
コンパイル時間 | 3,315 ms |
コンパイル使用メモリ | 77,692 KB |
実行使用メモリ | 45,012 KB |
最終ジャッジ日時 | 2024-10-02 14:27:40 |
合計ジャッジ時間 | 9,835 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
37,144 KB |
testcase_01 | AC | 49 ms
36,736 KB |
testcase_02 | AC | 48 ms
36,944 KB |
testcase_03 | AC | 49 ms
36,880 KB |
testcase_04 | AC | 49 ms
36,944 KB |
testcase_05 | AC | 111 ms
40,904 KB |
testcase_06 | AC | 83 ms
39,240 KB |
testcase_07 | WA | - |
testcase_08 | AC | 170 ms
44,968 KB |
testcase_09 | AC | 76 ms
38,448 KB |
testcase_10 | AC | 117 ms
43,848 KB |
testcase_11 | AC | 228 ms
45,012 KB |
testcase_12 | AC | 301 ms
44,432 KB |
testcase_13 | AC | 47 ms
36,968 KB |
testcase_14 | AC | 50 ms
37,092 KB |
testcase_15 | AC | 48 ms
37,052 KB |
testcase_16 | AC | 47 ms
36,944 KB |
testcase_17 | AC | 46 ms
37,240 KB |
testcase_18 | AC | 172 ms
44,660 KB |
testcase_19 | AC | 150 ms
43,936 KB |
testcase_20 | AC | 244 ms
44,924 KB |
testcase_21 | AC | 266 ms
44,972 KB |
testcase_22 | AC | 218 ms
44,048 KB |
testcase_23 | AC | 150 ms
43,956 KB |
testcase_24 | AC | 216 ms
44,204 KB |
testcase_25 | AC | 163 ms
43,988 KB |
testcase_26 | WA | - |
testcase_27 | AC | 199 ms
44,316 KB |
testcase_28 | WA | - |
testcase_29 | AC | 188 ms
43,912 KB |
testcase_30 | WA | - |
testcase_31 | AC | 198 ms
44,412 KB |
testcase_32 | AC | 167 ms
44,704 KB |
testcase_33 | AC | 168 ms
44,312 KB |
testcase_34 | WA | - |
testcase_35 | AC | 183 ms
43,828 KB |
testcase_36 | AC | 46 ms
37,236 KB |
testcase_37 | AC | 47 ms
36,960 KB |
testcase_38 | AC | 45 ms
37,060 KB |
testcase_39 | AC | 49 ms
36,876 KB |
testcase_40 | AC | 45 ms
37,060 KB |
testcase_41 | AC | 45 ms
37,200 KB |
testcase_42 | AC | 46 ms
36,748 KB |
testcase_43 | AC | 65 ms
38,972 KB |
testcase_44 | AC | 112 ms
41,832 KB |
testcase_45 | AC | 52 ms
37,060 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()); } } }