結果

問題 No.697 池の数はいくつか
ユーザー iwkjoseciwkjosec
提出日時 2019-05-20 20:53:11
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,020 bytes
コンパイル時間 2,551 ms
コンパイル使用メモリ 111,712 KB
実行使用メモリ 56,280 KB
最終ジャッジ日時 2024-05-04 06:31:54
合計ジャッジ時間 7,951 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
18,048 KB
testcase_01 AC 25 ms
18,048 KB
testcase_02 AC 25 ms
17,920 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 25 ms
18,176 KB
testcase_06 AC 26 ms
18,048 KB
testcase_07 AC 26 ms
17,792 KB
testcase_08 AC 28 ms
18,176 KB
testcase_09 AC 26 ms
17,664 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 26 ms
17,664 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 26 ms
17,792 KB
testcase_16 AC 26 ms
17,792 KB
testcase_17 AC 26 ms
17,792 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 27 ms
17,664 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 218 ms
46,048 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var HW = ReadLine().Split();
        var H = int.Parse(HW[0]);
        var W = int.Parse(HW[1]);
        var map = new bool[H, W];
        var zero = 0;
        for (int i = 0; i < H; i++)
        {
            var line = ReadLine();
            for (int j = 0; j < W; j++)
            {
                if (line[j * 2] == '0') zero++;
                else map[i, j] = true;
            }
        }

        if (zero == 0)
        {
            WriteLine(1);
            return;
        }
        var ans = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (!map[i, j]) continue;
                var m = i * W + j;
                if (j != W - 1 && map[i, j + 1]) ans++;
                if (i != H - 1 && map[i + 1, j]) ans++;
            }
        }
        WriteLine(H * W - ans - zero);
    }
}
0