結果

問題 No.697 池の数はいくつか
ユーザー masayan_kazumasayan_kazu
提出日時 2018-06-09 17:24:10
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,722 bytes
コンパイル時間 2,876 ms
コンパイル使用メモリ 112,472 KB
実行使用メモリ 110,564 KB
最終ジャッジ日時 2024-05-04 05:13:51
合計ジャッジ時間 13,087 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 23 ms
26,028 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 21 ms
23,644 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
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 System.Text;
using System.Threading.Tasks;

namespace ichimatu
{
    class Program
    {
        static char[,] map = new char[3000, 3000];
        static int gyouMax;
        static int retuMax;

        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var d = input.Split(' ');
            gyouMax = Int32.Parse(d[0]);
            retuMax = Int32.Parse(d[1]);

            var input2list = new List<string>();
            for (int i = 0; i < gyouMax; i++)
            {
                input2list.Add(Console.ReadLine());
            }

            for (int i = 0; i < gyouMax; i++)
            {
                var dd = input2list[i].Split(' ');
                for (int j = 0; j < retuMax; j++)
                {
                    map[i, j] = char.Parse(dd[j]);
                }
            }

            var total = 0;
            for (int i = 0; i < gyouMax; i++)
            {
                for (int j = 0; j < retuMax; j++)
                {
                    // 「1」を見つける
                    if (map[i, j] == 1)
                    {
                        // 周辺探索
                        exec周辺探索(i, j);
                        total += 1;
                    }
                }
            }

            Console.WriteLine(total);

        }

        private static void exec周辺探索(int gyou, int retu)
        {
            //var tansaku_gyouList = new List<int>();
            //var tansaku_retuList = new List<int>();
            // 見つけた場所を探索済みにする
            map[gyou, retu] = (char)10;
            // 探索対象をキューに入れる
            // 右をチェックする
            if (retu + 1 < retuMax)
            {
                if (map[gyou, retu + 1] == 1)
                {
                    exec周辺探索(gyou, retu + 1);
                }
            }

            // 上をチェックする
            if (0 <= gyou - 1)
            {
                if (map[gyou - 1, retu] == 1)
                {
                    exec周辺探索(gyou - 1, retu);
                }
            }

            // 下をチェックする
            if (gyou + 1 < gyouMax)
            {
                if (map[gyou + 1, retu] == 1)
                {
                    exec周辺探索(gyou + 1, retu);
                }
            }

            // 左をチェックする
            if (0 <= retu - 1)
            {
                if (map[gyou, retu - 1] == 1)
                {
                    exec周辺探索(gyou, retu - 1);
                }
            }

        }

    }
}
0