結果

問題 No.179 塗り分け
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-03 18:21:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,238 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 74,328 KB
実行使用メモリ 57,888 KB
最終ジャッジ日時 2023-09-20 07:14:53
合計ジャッジ時間 11,388 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,776 KB
testcase_01 WA -
testcase_02 AC 129 ms
55,736 KB
testcase_03 WA -
testcase_04 AC 127 ms
55,604 KB
testcase_05 WA -
testcase_06 AC 144 ms
55,784 KB
testcase_07 WA -
testcase_08 AC 154 ms
56,068 KB
testcase_09 AC 154 ms
55,796 KB
testcase_10 AC 157 ms
55,568 KB
testcase_11 AC 153 ms
55,728 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 126 ms
55,820 KB
testcase_17 WA -
testcase_18 AC 155 ms
55,728 KB
testcase_19 AC 154 ms
55,884 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 151 ms
55,852 KB
testcase_24 WA -
testcase_25 AC 150 ms
55,968 KB
testcase_26 AC 156 ms
55,852 KB
testcase_27 WA -
testcase_28 AC 153 ms
55,840 KB
testcase_29 WA -
testcase_30 AC 152 ms
55,744 KB
testcase_31 WA -
testcase_32 AC 155 ms
55,764 KB
testcase_33 WA -
testcase_34 AC 153 ms
55,876 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int[] grid = new int[h * w];
    for(int i = 0; i < h; i++) {
      String s = sc.next();
      for(int j = 0; j < w; j++) {
        if(s.charAt(j) == '#') {
          grid[w * i + j] = 1; 
        }
      }
    }
    int pp = 0;
    // 1が黒、2が青、3が赤
    for(int s = 0; s < w; s++) {
      for(int t = 0; t < h; t++) {
      int[] g = grid;
      int p = 0;
      int c = 0;
        for(int i = 0; i < h; i++) {
          for(int j = 0; j < w; j++) {
            int a = i * w + j;
            if(g[a] == 1) {
              if(((j + s) < w) && ((i + t) < h)) {
                int b = (i + t) * w + (j + s);
                if(c == 0) {
                  g[a] = 2;
                  g[b] = 3;
                } else {
                  g[a] = 3;
                  g[b] = 2;
                }
                c = 1 - c;
              } else {
                p++;
              }
            }
            if(p == 0) pp++;
          }
        }
      }
    }
    String ans = "NO";
    if(pp > 0) ans = "YES";
    System.out.println(ans);
  }
}
0