結果

問題 No.179 塗り分け
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-03 22:08:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,454 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 73,852 KB
実行使用メモリ 58,696 KB
最終ジャッジ日時 2023-09-20 16:03:03
合計ジャッジ時間 11,086 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
53,848 KB
testcase_01 WA -
testcase_02 AC 123 ms
56,052 KB
testcase_03 WA -
testcase_04 AC 122 ms
55,868 KB
testcase_05 WA -
testcase_06 AC 137 ms
55,816 KB
testcase_07 WA -
testcase_08 AC 149 ms
55,956 KB
testcase_09 AC 149 ms
55,824 KB
testcase_10 AC 146 ms
56,300 KB
testcase_11 AC 146 ms
55,872 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 122 ms
55,920 KB
testcase_16 AC 125 ms
56,040 KB
testcase_17 WA -
testcase_18 AC 148 ms
55,716 KB
testcase_19 AC 145 ms
55,844 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 145 ms
56,048 KB
testcase_24 WA -
testcase_25 AC 146 ms
55,712 KB
testcase_26 AC 148 ms
56,544 KB
testcase_27 WA -
testcase_28 AC 148 ms
55,788 KB
testcase_29 WA -
testcase_30 AC 147 ms
55,736 KB
testcase_31 WA -
testcase_32 AC 150 ms
55,704 KB
testcase_33 WA -
testcase_34 AC 147 ms
55,664 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;
                  if(g[b] == 1) {
                    g[b] = 3;
                  } else {
                    p++;
                  }
                } else {
                  g[a] = 3;
                  if(g[b] == 1) {
                    g[b] = 2;
                  } else {
                    p++;
                  }
                }
                c = 1 - c;
              } else {
                p++;
              }
            }
            if(p == 0) pp++;
          }
        }
      }
    }
    String ans = "NO";
    if(pp > 0) ans = "YES";
    System.out.println(ans);
  }
}
0