結果

問題 No.697 池の数はいくつか
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-23 00:51:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 3,574 ms
コンパイル使用メモリ 77,772 KB
実行使用メモリ 122,556 KB
最終ジャッジ日時 2024-05-04 05:59:07
合計ジャッジ時間 52,012 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
53,968 KB
testcase_01 AC 140 ms
54,236 KB
testcase_02 AC 139 ms
53,640 KB
testcase_03 AC 141 ms
54,280 KB
testcase_04 WA -
testcase_05 AC 136 ms
54,116 KB
testcase_06 WA -
testcase_07 AC 145 ms
54,044 KB
testcase_08 AC 151 ms
53,868 KB
testcase_09 AC 149 ms
54,072 KB
testcase_10 WA -
testcase_11 AC 155 ms
53,748 KB
testcase_12 AC 151 ms
54,036 KB
testcase_13 WA -
testcase_14 AC 143 ms
54,108 KB
testcase_15 WA -
testcase_16 AC 136 ms
53,700 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 137 ms
54,372 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 152 ms
53,796 KB
testcase_23 AC 155 ms
54,180 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 5,943 ms
122,228 KB
testcase_30 WA -
testcase_31 AC 5,588 ms
122,152 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No697{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();

		int ans = 0;
		int[][] a = new int[H+2][W+2];
		Arrays.fill(a[0], 0);
		Arrays.fill(a[H+1], 0);
		for(int h = 1; h < H+1; h++){
			Arrays.fill(a[h], 0);
			for(int w = 1; w < W+1; w++){
				a[h][w] = sc.nextInt();
				if(a[h][w] == 1 &&
				   (a[h][w-1]==0 && a[h-1][w]==0)){
					ans++;
				}
			}
		}

		for(int h = 2; h < H+1; h++){
			for(int w = 2; w < W+1; w++){
				if(a[h][w] == 1 &&
				   (a[h][w-1]==0 && a[h-1][w]==0 && (a[h][w+1]==1 || a[h+1][w]==1))){
					ans--;
				}
			}
		}
		
		System.out.println(ans);
	}
}
0