結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-28 21:40:48 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,572 bytes |
| 記録 | |
| コンパイル時間 | 3,900 ms |
| コンパイル使用メモリ | 77,632 KB |
| 実行使用メモリ | 43,260 KB |
| 最終ジャッジ日時 | 2024-10-03 03:38:59 |
| 合計ジャッジ時間 | 22,497 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 WA * 1 |
| other | AC * 34 WA * 6 |
ソースコード
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);
}
}
for(int r = 0;r<H;r++){
for(int q = 0;q < W;q++){
color[r][q][1] = 0;
}
}
for(int j = 0;j <W-x;j++){
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 r = 0;r<H;r++){
for(int q = 0;q < W;q++){
color[r][q][1] = 0;
}
}
}
if(cp == redc ||cn == redc){
count = 0;
break;
}
}
if(count == 0){
break;
}
}
if(count == 0){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
}
}