結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2017-03-28 21:31:33 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,365 bytes |
コンパイル時間 | 3,193 ms |
コンパイル使用メモリ | 77,756 KB |
実行使用メモリ | 56,608 KB |
最終ジャッジ日時 | 2024-10-03 03:38:00 |
合計ジャッジ時間 | 12,726 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 36 WA * 4 |
ソースコード
import java.util.Scanner; public class Nuriwake { public static void main(String[] args) { Scanner s = new Scanner(System.in); int H = s.nextInt(), W = s.nextInt(),count = 0; int[][][] color = new int[H][W][2]; for(int i = 0;i < H;i++){ String str = s.next(); for(int j = 0;j < W;j++){ if(str.charAt(j) == '#'){ color[i][j][0] = 1; //1は[0]なら黒、[1]なら青候補 count++; } } } s.close(); if(count%2 == 1||count == 0){ System.out.println("NO"); }else{ int redc = count / 2; for(int x = 0;x < W;x++){ for(int y = 0;y < H;y++){ int cp = 0,cn = 0; for(int i = 0;i < H;i++){ for(int j = 0;j < W-x;j++){ if(i+y<H&&color[i][j][0] == 1&&color[i+y][j+x][0] == 1&&color[i+y][j+x][1] == 0&&color[i][j][1] == 0){ color[i+y][j+x][1] = 1; cp++; //System.out.println(i+" "+j+" "+y+" "+x); }else if(i-y>=0&&color[i][j][0] == 1&&color[i-y][j+x][0] == 1&&color[i-y][j+x][1] == 0&&color[i][j][1] == 0){ color[i-y][j+x][1] =1; cn++; } } } for(int i = 0;i<H;i++){ for(int j = 0;j < W;j++){ color[i][j][1] = 0; } } if(cp == redc ||cn == redc){ count = 0; } } } if(count == 0){ System.out.println("YES"); }else{ System.out.println("NO"); } } } }