結果

問題 No.179 塗り分け
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-03 18:10:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,189 bytes
コンパイル時間 3,185 ms
コンパイル使用メモリ 74,152 KB
実行使用メモリ 57,612 KB
最終ジャッジ日時 2023-09-20 06:08:08
合計ジャッジ時間 12,131 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 123 ms
55,888 KB
testcase_02 WA -
testcase_03 AC 127 ms
55,900 KB
testcase_04 WA -
testcase_05 AC 140 ms
55,680 KB
testcase_06 WA -
testcase_07 AC 150 ms
55,432 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 149 ms
55,740 KB
testcase_13 AC 129 ms
55,592 KB
testcase_14 AC 131 ms
55,668 KB
testcase_15 AC 124 ms
55,748 KB
testcase_16 WA -
testcase_17 AC 125 ms
56,000 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 148 ms
55,732 KB
testcase_21 AC 150 ms
55,732 KB
testcase_22 AC 148 ms
55,652 KB
testcase_23 WA -
testcase_24 AC 149 ms
55,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 149 ms
55,828 KB
testcase_28 WA -
testcase_29 AC 150 ms
53,992 KB
testcase_30 WA -
testcase_31 AC 151 ms
55,748 KB
testcase_32 WA -
testcase_33 AC 149 ms
55,592 KB
testcase_34 WA -
testcase_35 AC 145 ms
55,864 KB
testcase_36 AC 126 ms
55,648 KB
testcase_37 AC 125 ms
55,824 KB
testcase_38 AC 126 ms
56,076 KB
testcase_39 AC 123 ms
55,904 KB
testcase_40 AC 122 ms
55,700 KB
testcase_41 AC 124 ms
56,108 KB
testcase_42 AC 124 ms
55,872 KB
testcase_43 AC 133 ms
55,660 KB
testcase_44 AC 141 ms
55,736 KB
testcase_45 AC 127 ms
56,012 KB
権限があれば一括ダウンロードができます

ソースコード

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 p = 0;
    int c = 0;
    // 1が黒、2が青、3が赤
    for(int s = 0; s < w; s++) {
      for(int t = 0; t < h; t++) {
      int[] g = grid;
        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++;
              }
            }
          }
        }
      }
    }
    String ans = "YES";
    if(p == 0) ans = "NO";
    System.out.println(ans);
  }
}
0