結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2020-02-19 14:26:49 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,087 bytes |
コンパイル時間 | 3,006 ms |
コンパイル使用メモリ | 78,452 KB |
実行使用メモリ | 59,204 KB |
最終ジャッジ日時 | 2024-10-08 00:40:52 |
合計ジャッジ時間 | 11,560 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 34 WA * 6 |
ソースコード
import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) throws Exception { new Main().run(); } void run() { Scanner sc=new Scanner(System.in); int H=sc.nextInt(); int W=sc.nextInt(); char[][] m=new char[H][W]; for(int i=0;i<H;++i) { m[i]=sc.next().toCharArray(); } for(int dh=0;dh<H;++dh) { for(int dw=0;dw<W;++dw) { if(dh==0&&dw==0)continue; boolean flag=true; int[][] rec=new int[H][W]; for(int h=0;h<H;++h) { for(int w=0;w<W;++w) { if(m[h][w]=='.')continue; if(rec[h][w]!=0)continue; int nh=h+dh; int nw=w+dw; if(nh>=H||nw>=W) { flag=false; continue; } if(rec[nh][nw]==2) { flag=false; continue; } flag&=m[nh][nw]=='#'; rec[h][w]=1; rec[nh][nw]=2; } } if(flag) { System.out.println("YES"); return; } } } System.out.println("NO"); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }