結果
問題 | No.86 TVザッピング(2) |
ユーザー |
|
提出日時 | 2014-12-07 18:35:04 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 813 bytes |
コンパイル時間 | 2,903 ms |
コンパイル使用メモリ | 77,752 KB |
実行使用メモリ | 56,512 KB |
最終ジャッジ日時 | 2024-06-11 16:04:13 |
合計ジャッジ時間 | 7,858 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 13 |
ソースコード
import java.util.Scanner;public class Yukicoder85 {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt(), m = sc.nextInt();String[] a = new String[n];for (int i = 0; i < n; i++) a[i] = sc.next();int oddCount = 0, buf;for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {if (a[i].charAt(j) == '#') continue;buf = 0;if (i - 1 >= 0) buf += a[i - 1].charAt(j) == '.' ? 1 : 0;if (i + 1 < n) buf += a[i + 1].charAt(j) == '.' ? 1 : 0;if (j - 1 >= 0) buf += a[i].charAt(j - 1) == '.' ? 1 : 0;if (j + 1 < m) buf += a[i].charAt(j + 1) == '.' ? 1 : 0;if (buf % 2 == 0) oddCount++;}}if (oddCount % 2 == 0)System.out.println("YES");elseSystem.out.println("NO");}}